Compare commits

..

16 Commits

Author SHA1 Message Date
Chee Yee 5a250a4182 display transfer speed 2024-06-13 23:44:19 -07:00
Chee Yee 89fa9aba69 fix install for large patch pkg 2024-06-13 18:38:18 -07:00
Chee Yee 0feff205d2 fix extracting from webdav 2024-04-29 00:13:07 -07:00
Chee Yee 5df5447eb0 improve speed of install pkg in zip on smb, nfs and sftp 2024-04-28 23:59:01 -07:00
Chee Yee b87dc91c6f fix install from url 2024-04-28 23:19:59 -07:00
Chee Yee 14b32504e0 more improvements to install speed for nfs, smb ans sftp 2024-04-28 18:11:22 -07:00
Chee Yee d35345a270 fix install from gdrive after refactor 2024-04-28 14:16:08 -07:00
Chee Yee f041172768 improve speed of installing from smb, nfs, sftp 2024-04-28 13:49:06 -07:00
Chee Yee 232a6233ca Merge branch 'master' of github.com:cy33hc/ps4-ezremote-client 2024-04-21 21:16:19 -07:00
Chee Yee c620478691 fix extraction of 7zip 2024-04-21 21:16:12 -07:00
cy33hc 2615372288 Update README.md 2024-04-04 01:21:34 -07:00
cy33hc 0889b0923d Update README.md 2024-04-04 01:21:03 -07:00
cy33hc a2b26102de Update README.md 2024-04-04 01:20:38 -07:00
cy33hc dff469a9d7 Update README.md 2024-04-04 01:20:16 -07:00
cy33hc 37074f0102 Update README.md 2024-04-04 01:19:56 -07:00
Chee Yee eb4184d488 fixed RPI for all remotes which was broken since 1.18 2024-03-17 15:26:26 -07:00
55 changed files with 1002 additions and 293 deletions
+2 -1
View File
@@ -62,11 +62,12 @@ add_executable(ezremote_client
source/windows.cpp
source/zip_util.cpp
source/split_file.cpp
source/mem_file.cpp
)
add_self(ezremote_client)
add_pkg(ezremote_client ${CMAKE_SOURCE_DIR}/data "RMTC00001" "ezRemote Client" "01.21" 32 0)
add_pkg(ezremote_client ${CMAKE_SOURCE_DIR}/data "RMTC00001" "ezRemote Client" "01.25" 32 0)
target_link_libraries(ezremote_client
c
+4
View File
@@ -2,6 +2,10 @@
ezRemote Client is an application that allows you to connect the PS4 to remote FTP/SFTP, SMB(Windows Share), NFS, WebDAV, HTTP servers and Google Drive to transfer files. The interface is inspired by Filezilla client which provides a commander like GUI.
**New: As of version 1.19**
- Install PKG inside Zip files from both local hdd and remote servers.
- Extact zip files directly from remote servers.
**New:** As of version 1.0.8, ezRemote Client has a Web Interface that can be access from any modern browser to manage the PS4 files.
**New:** As of version 1.0.9. Remote Package Installation does not require you to host an external Http Server. The embedded Web Server built into ezRemote Client acts as a Proxy Server between the PS4 and remote server (FTP, SFTP, SMB, NFS, WebDav, HttpServer(IIS/Nginx/Apache/Serve) and GoogleDrive). There's no data written to the PS4 hard drive in the process, rather everything is streamed via embedded Web Server directly to the PS4 installer.
+98 -26
View File
@@ -1,8 +1,8 @@
STR_CONNECTION_SETTINGS=连接设置
STR_SITE=
STR_LOCAL=当地的
STR_REMOTE=偏僻的
STR_MESSAGES=留言
STR_SITE=
STR_LOCAL=本地
STR_REMOTE=远程路径
STR_MESSAGES=信息
STR_UPDATE_SOFTWARE=更新软件
STR_CONNECT=连接
STR_DISCONNECT=断开
@@ -11,51 +11,123 @@ STR_REFRESH=刷新
STR_SERVER=服务器
STR_USERNAME=用户名
STR_PASSWORD=密码
STR_PORT=
STR_PASV=帕夫
STR_PORT=
STR_PASV=被动模式
STR_DIRECTORY=目录
STR_FILTER=筛选
STR_YES=
STR_NO=
STR_FILTER=过滤器
STR_YES=
STR_NO=
STR_CANCEL=取消
STR_CONTINUE=继续
STR_CLOSE=关闭
STR_FOLDER=文件夹
STR_FILE=文件
STR_TYPE=类型
STR_NAME=
STR_SIZE=尺寸
STR_NAME=
STR_SIZE=大小
STR_DATE=日期
STR_NEW_FOLDER=新建文件夹
STR_RENAME=
STR_RENAME=重命
STR_DELETE=删除
STR_UPLOAD=上传
STR_DOWNLOAD=下载
STR_SELECT_ALL=全选
STR_CLEAR_ALL=全部清除
STR_UPLOADING=上传
STR_DOWNLOADING=下载
STR_CLEAR_ALL=取消全选
STR_UPLOADING=上传
STR_DOWNLOADING=下载
STR_OVERWRITE=覆盖
STR_DONT_OVERWRITE=覆盖
STR_ASK_FOR_CONFIRM=要求确认
STR_DONT_ASK_CONFIRM=要要求确认
STR_DONT_OVERWRITE=不覆盖
STR_ASK_FOR_CONFIRM=确认请求
STR_DONT_ASK_CONFIRM=不确认请求
STR_ALLWAYS_USE_OPTION=始终使用此选项,不再询问
STR_ACTIONS=行动
STR_CONFIRM=确认
STR_OVERWRITE_OPTIONS=覆盖选项
STR_PROPERTIES=
STR_PROGRESS=
STR_PROPERTIES=
STR_PROGRESS=
STR_UPDATES=更新
STR_DEL_CONFIRM_MSG=您确定要删除此文件/文件夹
STR_CANCEL_ACTION_MSG=取消等待最后一个动作完成
STR_DEL_CONFIRM_MSG=您确定要删除此文件/文件夹?
STR_CANCEL_ACTION_MSG=取消中。请等待最后一个操作结束
STR_FAIL_UPLOAD_MSG=上传文件失败
STR_FAIL_DOWNLOAD_MSG=下载文件失败
STR_FAIL_READ_LOCAL_DIR_MSG=读取目录内容失败或文件夹不存在。
STR_CONNECTION_CLOSE_ERR_MSG=426 连接已关闭。
STR_REMOTE_TERM_CONN_MSG=426 远程服务器已终止连接。
STR_FAIL_LOGIN_MSG=300 登录失败。 请检查您的用户名或密码。
STR_FAIL_TIMEOUT_MSG=426 失败。 连接超时。
STR_FAIL_LOGIN_MSG=300 登录失败。请检查您的用户名或密码。
STR_FAIL_TIMEOUT_MSG=426 失败。连接超时。
STR_FAIL_DEL_DIR_MSG=删除目录失败
STR_DELETING=删除
STR_DELETING=删除
STR_FAIL_DEL_FILE_MSG=删除文件失败
STR_DELETED=删除
STR_DELETED=删除完毕
STR_LINK=链接
STR_SHARE=分享
STR_FAILED=310 失败
STR_FAIL_CREATE_LOCAL_FILE_MSG=310 无法本地创建文件
STR_INSTALL=安装
STR_INSTALLING=正在安装中
STR_INSTALL_SUCCESS=成功
STR_INSTALL_FAILED=失败
STR_INSTALL_SKIPPED=已忽略
STR_CHECK_HTTP_MSG=正在检查与远程HTTP服务器的连接
STR_FAILED_HTTP_CHECK=连接到HTTP服务器失败
STR_REMOTE_NOT_HTTP=远程不是HTTP服务器
STR_INSTALL_FROM_DATA_MSG=文件包不在/data或/mnt/usbX文件夹中
STR_ALREADY_INSTALLED_MSG=文件包已经安装
STR_INSTALL_FROM_URL=从网址安装
STR_CANNOT_READ_PKG_HDR_MSG=无法读取包文件头信息
STR_FAVORITE_URLS=收藏网址
STR_SLOT=槽位
STR_EDIT=编辑
STR_ONETIME_URL=一次性网址
STR_NOT_A_VALID_PACKAGE=不是有效的程序包
STR_WAIT_FOR_INSTALL_MSG=正在等待包完成安装
STR_FAIL_INSTALL_TMP_PKG_MSG=未能安装pkg文件。请手动删除tmp pkg
STR_AUTO_DELETE_TMP_PKG=安装后自动删除临时下载的pkg文件
STR_PROTOCOL_NOT_SUPPORTED=不支持该协议
STR_COULD_NOT_RESOLVE_HOST=无法解析主机名
STR_EXTRACT=提取
STR_EXTRACTING=提取中
STR_FAILED_TO_EXTRACT=提取失败
STR_EXTRACT_LOCATION=提取位置
STR_COMPRESS=压缩
STR_ZIP_FILE_PATH=Zip 文件名
STR_COMPRESSING=压缩中
STR_ERROR_CREATE_ZIP=正在创建zip文件时出现错误
STR_UNSUPPORTED_FILE_FORMAT=不支持的压缩文件格式
STR_CUT=剪切
STR_COPY=复制
STR_PASTE=粘贴
STR_MOVING=移动中
STR_COPYING=复制中
STR_FAIL_MOVE_MSG=移动文件失败
STR_FAIL_COPY_MSG=复制文件事变
STR_CANT_MOVE_TO_SUBDIR_MSG=无法将父目录移动到子目录
STR_CANT_COPY_TO_SUBDIR_MSG=无法将父目录复制到子目录
STR_UNSUPPORTED_OPERATION_MSG=不支持操作
STR_HTTP_PORT=Http 端口
STR_REINSTALL_CONFIRM_MSG=内容已安装。是否要继续安装
STR_REMOTE_NOT_SUPPORT_MSG=受保护的服务器不支持远程程序包安装。
STR_CANNOT_CONNECT_REMOTE_MSG=无法访问远程HTTP服务器。
STR_DOWNLOAD_INSTALL_MSG=无法安装远程程序包。是否下载软件包并进行安装?
STR_CHECKING_REMOTE_SERVER_MSG=正在检查远程服务器的远程包安装。
STR_FILES=文件
STR_EDITOR=编辑器
STR_SAVE=保存
STR_MAX_EDIT_FILE_SIZE_MSG=无法编辑大于全部的文件。
STR_DELETE_LINE=删除所选行
STR_INSERT_LINE=在所选行下方插入
STR_MODIFIED=已修改
STR_FAIL_GET_TOKEN_MSG=无法从获取访问令牌
STR_GET_TOKEN_SUCCESS_MSG=登录成功。您可以关闭浏览器并返回应用程序
STR_NEW_FILE=新文件
STR_SETTINGS=设置
STR_GLOBAL=全局
STR_COPY_LINE=复制所选行
STR_PASTE_LINE=粘贴到所选行
STR_SHOW_HIDDEN_FILES=显示隐藏文件
STR_SET_DEFAULT_DIRECTORY=设置默认文件夹
STR_SET_DEFAULT_DIRECTORY_MSG=已设置为默认目录
STR_NFS_EXP_PATH_MISSING_MSG=URL中缺少NFS导出路径
STR_FAIL_INIT_NFS_CONTEXT=无法初始化NFS上下文
STR_FAIL_MOUNT_NFS_MSG=挂在 NFS 共享失败
STR_VIEW_IMAGE=查看图片
+6 -1
View File
@@ -409,6 +409,7 @@ namespace Actions
snprintf(activity_message, 1024, "%s %s", lang_strings[STR_UPLOADING], entries[i].path);
bytes_to_download = entries[i].file_size;
bytes_transfered = 0;
sceRtcGetCurrentTick(&prev_tick);
ret = UploadFile(entries[i].path, new_path);
if (ret <= 0)
{
@@ -721,7 +722,7 @@ namespace Actions
skipped++;
}
}
else if (Util::EndsWith(path,".zip") || Util::EndsWith(path,".rar") ||
else if (Util::EndsWith(path,".zip") || Util::EndsWith(path,".rar") || Util::EndsWith(path,".7z") ||
Util::EndsWith(path,".tar.xz") || Util::EndsWith(path,".tar.gz"))
{
ArchiveEntry *entry = ZipUtil::GetPackageEntry(it->path, remoteclient);
@@ -1067,6 +1068,7 @@ namespace Actions
void *InstallUrlPkgThread(void *argp)
{
bytes_transfered = 0;
sceRtcGetCurrentTick(&prev_tick);
sprintf(status_message, "%s", "");
pkg_header header;
char filename[2000];
@@ -1384,6 +1386,7 @@ namespace Actions
snprintf(activity_message, 1024, "%s %s", isCopy ? lang_strings[STR_COPYING] : lang_strings[STR_MOVING], entries[i].path);
bytes_to_download = entries[i].file_size;
bytes_transfered = 0;
sceRtcGetCurrentTick(&prev_tick);
ret = CopyOrMoveLocalFile(entries[i].path, new_path, isCopy);
if (ret <= 0)
{
@@ -1633,6 +1636,7 @@ namespace Actions
snprintf(activity_message, 1024, "%s %s", lang_strings[STR_COPYING], entries[i].path);
bytes_to_download = entries[i].file_size;
bytes_transfered = 0;
sceRtcGetCurrentTick(&prev_tick);
ret = CopyOrMoveRemoteFile(entries[i].path, new_path, true);
if (ret <= 0)
{
@@ -1726,6 +1730,7 @@ namespace Actions
sprintf(activity_message, "%s %s to %s", lang_strings[STR_DOWNLOADING], filename.c_str(), local_file);
remoteclient->Size(filename, &bytes_to_download);
bytes_transfered = 0;
sceRtcGetCurrentTick(&prev_tick);
file_transfering = true;
int ret = remoteclient->Get(local_file, filename);
if (ret == 0)
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef ACTIONS_H
#define ACTIONS_H
#ifndef EZ_ACTIONS_H
#define EZ_ACTIONS_H
#include <pthread.h>
#include "installer.h"
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef BASE64_H_
#define BASE64_H_
#ifndef EZ_BASE64_H_
#define EZ_BASE64_H_
#include <string>
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef APACHE_H
#define APACHE_H
#ifndef EZ_APACHE_H
#define EZ_APACHE_H
#include <string>
#include <vector>
+25
View File
@@ -102,6 +102,8 @@ int BaseClient::Get(const std::string &outputfile, const std::string &path, uint
{
std::ofstream file_stream(outputfile, std::ios::binary);
bytes_transfered = 0;
sceRtcGetCurrentTick(&prev_tick);
if (auto res = client->Get(GetFullPath(path),
[&](const char *data, size_t data_length)
{
@@ -345,3 +347,26 @@ std::string BaseClient::UnEscape(const std::string &url)
}
return "";
}
void *BaseClient::Open(const std::string &path, int flags)
{
sprintf(this->response, "%s", lang_strings[STR_UNSUPPORTED_OPERATION_MSG]);
return nullptr;
}
void BaseClient::Close(void *fp)
{
sprintf(this->response, "%s", lang_strings[STR_UNSUPPORTED_OPERATION_MSG]);
}
int BaseClient::GetRange(void *fp, DataSink &sink, uint64_t size, uint64_t offset)
{
sprintf(this->response, "%s", lang_strings[STR_UNSUPPORTED_OPERATION_MSG]);
return -1;
}
int BaseClient::GetRange(void *fp, void *buffer, uint64_t size, uint64_t offset)
{
sprintf(this->response, "%s", lang_strings[STR_UNSUPPORTED_OPERATION_MSG]);
return -1;
}
+6 -2
View File
@@ -1,5 +1,5 @@
#ifndef BASESERVER_H
#define BASESERVER_H
#ifndef EZ_BASESERVER_H
#define EZ_BASESERVER_H
#include <string>
#include <vector>
@@ -23,6 +23,8 @@ public:
int Get(const std::string &outputfile, const std::string &path, uint64_t offset=0);
int GetRange(const std::string &path, void *buffer, uint64_t size, uint64_t offset);
int GetRange(const std::string &path, DataSink &sink, uint64_t size, uint64_t offset);
int GetRange(void *fp, void *buffer, uint64_t size, uint64_t offset);
int GetRange(void *fp, DataSink &sink, uint64_t size, uint64_t offset);
int Put(const std::string &inputfile, const std::string &path, uint64_t offset=0);
int Rename(const std::string &src, const std::string &dst);
int Delete(const std::string &path);
@@ -33,6 +35,8 @@ public:
std::vector<DirEntry> ListDir(const std::string &path);
std::string GetPath(std::string path1, std::string path2);
std::string GetFullPath(std::string path1);
void *Open(const std::string &path, int flags);
void Close(void *fp);
bool IsConnected();
bool Ping();
const char *LastResponse();
+21 -2
View File
@@ -1744,7 +1744,7 @@ ClientType FtpClient::clientType()
uint32_t FtpClient::SupportedActions()
{
return REMOTE_ACTION_ALL ^ REMOTE_ACTION_CUT ^ REMOTE_ACTION_COPY ^ REMOTE_ACTION_PASTE;
return REMOTE_ACTION_ALL ^ REMOTE_ACTION_CUT ^ REMOTE_ACTION_COPY ^ REMOTE_ACTION_PASTE ^ REMOTE_ACTION_RAW_READ;
}
std::string FtpClient::GetPath(std::string ppath1, std::string ppath2)
@@ -1783,4 +1783,23 @@ int FtpClient::Head(const std::string &path, void *buffer, uint64_t len)
if (l != len)
return 0;
return 1;
}
}
void *FtpClient::Open(const std::string &path, int flags)
{
return nullptr;
}
void FtpClient::Close(void *fp)
{
}
int FtpClient::GetRange(void *fp, DataSink &sink, uint64_t size, uint64_t offset)
{
return -1;
}
int FtpClient::GetRange(void *fp, void *buffer, uint64_t size, uint64_t offset)
{
return -1;
}
+6 -2
View File
@@ -1,5 +1,5 @@
#ifndef FTPCLIENT_H
#define FTPCLIENT_H
#ifndef EZ_FTPCLIENT_H
#define EZ_FTPCLIENT_H
#include <sys/socket.h>
#include <arpa/inet.h>
@@ -81,12 +81,16 @@ public:
int Get(const std::string &outputfile, const std::string &path, uint64_t offset = 0);
int GetRange(const std::string &path, void *buffer, uint64_t size, uint64_t offset);
int GetRange(const std::string &path, DataSink &sink, uint64_t size, uint64_t offset);
int GetRange(void *fp, void *buffer, uint64_t size, uint64_t offset);
int GetRange(void *fp, DataSink &sink, uint64_t size, uint64_t offset);
int Put(const std::string &inputfile, const std::string &path, uint64_t offset = 0);
int Rename(const std::string &src, const std::string &dst);
int Delete(const std::string &path);
int Copy(const std::string &from, const std::string &to);
int Move(const std::string &from, const std::string &to);
int Head(const std::string &path, void *buffer, uint64_t len);
void *Open(const std::string &path, int flags);
void Close(void *fp);
std::vector<DirEntry> ListDir(const std::string &path);
void SetCallbackXferFunction(FtpCallbackXfer pointer);
void SetCallbackArg(void *arg);
+28 -4
View File
@@ -307,6 +307,7 @@ int GDriveClient::Get(const std::string &outputfile, const std::string &path, ui
{
std::ofstream file_stream(outputfile, std::ios::binary);
bytes_transfered = 0;
sceRtcGetCurrentTick(&prev_tick);
std::string id = GetValue(path_id_map, path);
std::string drive_id = GetDriveId(path);
@@ -399,9 +400,9 @@ int GDriveClient::Update(const std::string &inputfile, const std::string &path)
{
bytes_to_download = FS::GetSize(inputfile);
bytes_transfered = 0;
sceRtcGetCurrentTick(&prev_tick);
std::ifstream file_stream(inputfile, std::ios::binary);
bytes_transfered = 0;
std::string id = GetValue(path_id_map, path);
std::string drive_id = GetDriveId(path);
@@ -473,9 +474,9 @@ int GDriveClient::Put(const std::string &inputfile, const std::string &path, uin
bytes_to_download = FS::GetSize(inputfile);
bytes_transfered = 0;
sceRtcGetCurrentTick(&prev_tick);
std::ifstream file_stream(inputfile, std::ios::binary);
bytes_transfered = 0;
size_t path_pos = path.find_last_of("/");
std::string parent_dir;
@@ -887,7 +888,7 @@ ClientType GDriveClient::clientType()
uint32_t GDriveClient::SupportedActions()
{
return REMOTE_ACTION_ALL ^ REMOTE_ACTION_CUT ^ REMOTE_ACTION_COPY ^ REMOTE_ACTION_PASTE;
return REMOTE_ACTION_ALL ^ REMOTE_ACTION_CUT ^ REMOTE_ACTION_COPY ^ REMOTE_ACTION_PASTE ^ REMOTE_ACTION_RAW_READ;
}
void *GDriveClient::RefreshTokenThread(void *argp)
@@ -941,4 +942,27 @@ void GDriveClient::SetAccessToken(const std::string &token)
{
if (this->client != nullptr)
this->client->set_bearer_token_auth(token);
}
}
void *GDriveClient::Open(const std::string &path, int flags)
{
sprintf(this->response, "%s", lang_strings[STR_UNSUPPORTED_OPERATION_MSG]);
return nullptr;
}
void GDriveClient::Close(void *fp)
{
sprintf(this->response, "%s", lang_strings[STR_UNSUPPORTED_OPERATION_MSG]);
}
int GDriveClient::GetRange(void *fp, DataSink &sink, uint64_t size, uint64_t offset)
{
sprintf(this->response, "%s", lang_strings[STR_UNSUPPORTED_OPERATION_MSG]);
return -1;
}
int GDriveClient::GetRange(void *fp, void *buffer, uint64_t size, uint64_t offset)
{
sprintf(this->response, "%s", lang_strings[STR_UNSUPPORTED_OPERATION_MSG]);
return -1;
}
+6 -2
View File
@@ -1,5 +1,5 @@
#ifndef GDRIVE_H
#define GDRIVE_H
#ifndef EZ_GDRIVE_H
#define EZ_GDRIVE_H
#include <string>
#include <vector>
@@ -22,6 +22,8 @@ public:
int Get(const std::string &outputfile, const std::string &path, uint64_t offset=0);
int GetRange(const std::string &path, void *buffer, uint64_t size, uint64_t offset);
int GetRange(const std::string &path, DataSink &sink, uint64_t size, uint64_t offset);
int GetRange(void *fp, void *buffer, uint64_t size, uint64_t offset);
int GetRange(void *fp, DataSink &sink, uint64_t size, uint64_t offset);
int Put(const std::string &inputfile, const std::string &path, uint64_t offset=0);
int Head(const std::string &path, void *buffer, uint64_t len);
int Update(const std::string &inputfile, const std::string &path);
@@ -32,6 +34,8 @@ public:
bool FileExists(const std::string &path);
void SetAccessToken(const std::string &token);
std::vector<DirEntry> ListDir(const std::string &path);
void *Open(const std::string &path, int flags);
void Close(void *fp);
static void *RefreshTokenThread(void *argp);
static void StartRefreshToken();
static void StopRefreshToken();
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef IIS_H
#define IIS_H
#ifndef EZ_IIS_H
#define EZ_IIS_H
#include <string>
#include <vector>
+36 -11
View File
@@ -213,6 +213,7 @@ int NfsClient::Get(const std::string &outputfile, const std::string &ppath, uint
void *buff = malloc(BUF_SIZE);
int count = 0;
bytes_transfered = 0;
sceRtcGetCurrentTick(&prev_tick);
while ((count = nfs_read(nfs, nfsfh, BUF_SIZE, buff)) > 0)
{
if (count < 0)
@@ -242,7 +243,17 @@ int NfsClient::GetRange(const std::string &path, DataSink &sink, uint64_t size,
return 0;
}
ret = nfs_lseek(nfs, nfsfh, offset, SEEK_SET, NULL);
ret = this->GetRange((void *)nfsfh, sink, size, offset);
nfs_close(nfs, nfsfh);
return ret;
}
int NfsClient::GetRange(void *fp, DataSink &sink, uint64_t size, uint64_t offset)
{
struct nfsfh *nfsfh = (struct nfsfh *)fp;
int ret = nfs_lseek(nfs, nfsfh, offset, SEEK_SET, NULL);
if (ret != 0)
{
return 0;
@@ -262,7 +273,6 @@ int NfsClient::GetRange(const std::string &path, DataSink &sink, uint64_t size,
if (!ok)
{
free((void *)buff);
nfs_close(nfs, nfsfh);
return 0;
}
}
@@ -273,18 +283,11 @@ int NfsClient::GetRange(const std::string &path, DataSink &sink, uint64_t size,
} while (1);
free((void *)buff);
nfs_close(nfs, nfsfh);
return 1;
}
int NfsClient::GetRange(const std::string &ppath, void *buffer, uint64_t size, uint64_t offset)
{
if (!FileExists(ppath))
{
return 0;
}
struct nfsfh *nfsfh = nullptr;
int ret = nfs_open(nfs, ppath.c_str(), 0400, &nfsfh);
if (ret != 0)
@@ -293,7 +296,17 @@ int NfsClient::GetRange(const std::string &ppath, void *buffer, uint64_t size, u
return 0;
}
ret = nfs_lseek(nfs, nfsfh, offset, SEEK_SET, NULL);
ret = this->GetRange(nfsfh, buffer, size, offset);
nfs_close(nfs, nfsfh);
return ret;
}
int NfsClient::GetRange(void *fp, void *buffer, uint64_t size, uint64_t offset)
{
struct nfsfh *nfsfh = (struct nfsfh *) fp;
int ret = nfs_lseek(nfs, nfsfh, offset, SEEK_SET, NULL);
if (ret != 0)
{
sprintf(response, "%s", nfs_get_error(nfs));
@@ -301,7 +314,6 @@ int NfsClient::GetRange(const std::string &ppath, void *buffer, uint64_t size, u
}
int count = nfs_read(nfs, nfsfh, size, buffer);
nfs_close(nfs, nfsfh);
if (count != size)
return 0;
@@ -371,6 +383,7 @@ int NfsClient::Put(const std::string &inputfile, const std::string &ppath, uint6
void* buff = malloc(BUF_SIZE);
uint64_t count = 0;
bytes_transfered = 0;
sceRtcGetCurrentTick(&prev_tick);
while ((count = FS::Read(in, buff, BUF_SIZE)) > 0)
{
if (count < 0)
@@ -553,6 +566,18 @@ int NfsClient::Head(const std::string &ppath, void *buffer, uint64_t len)
return 1;
}
void *NfsClient::Open(const std::string &path, int flags)
{
struct nfsfh *nfsfh = nullptr;
nfs_open(nfs, path.c_str(), 0400, &nfsfh);;
return nfsfh;
}
void NfsClient::Close(void *fp)
{
nfs_close(nfs, (struct nfsfh*)fp);
}
ClientType NfsClient::clientType()
{
return CLIENT_TYPE_NFS;
+6 -2
View File
@@ -1,5 +1,5 @@
#ifndef NFSCLIENT_H
#define NFSCLIENT_H
#ifndef EZ_NFSCLIENT_H
#define EZ_NFSCLIENT_H
#include <sys/socket.h>
#include <arpa/inet.h>
@@ -25,6 +25,8 @@ public:
int Get(const std::string &outputfile, const std::string &path, uint64_t offset=0);
int GetRange(const std::string &path, void *buffer, uint64_t size, uint64_t offset);
int GetRange(const std::string &path, DataSink &sink, uint64_t size, uint64_t offset);
int GetRange(void *fp, void *buffer, uint64_t size, uint64_t offset);
int GetRange(void *fp, DataSink &sink, uint64_t size, uint64_t offset);
int Put(const std::string &inputfile, const std::string &path, uint64_t offset=0);
int Rename(const std::string &src, const std::string &dst);
int Delete(const std::string &path);
@@ -32,6 +34,8 @@ public:
int Copy(const std::string &from, const std::string &to);
int Move(const std::string &from, const std::string &to);
std::vector<DirEntry> ListDir(const std::string &path);
void *Open(const std::string &path, int flags);
void Close(void *fp);
bool IsConnected();
bool Ping();
const char *LastResponse();
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef NGINX_H
#define NGINX_H
#ifndef EZ_NGINX_H
#define EZ_NGINX_H
#include <string>
#include <vector>
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef NPXSERVE_H
#define NPXSERVE_H
#ifndef EZ_NPXSERVE_H
#define EZ_NPXSERVE_H
#include <string>
#include <vector>
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef RCLONE_H
#define RCLONE_H
#ifndef EZ_RCLONE_H
#define EZ_RCLONE_H
#include <string>
#include <vector>
+8 -3
View File
@@ -1,5 +1,5 @@
#ifndef REMOTECLIENT_H
#define REMOTECLIENT_H
#ifndef EZ_REMOTECLIENT_H
#define EZ_REMOTECLIENT_H
#include <string>
#include <vector>
@@ -21,7 +21,8 @@ enum RemoteActions
REMOTE_ACTION_EDIT = 512,
REMOTE_ACTION_NEW_FILE = 1024,
REMOTE_ACTION_EXTRACT = 2048,
REMOTE_ACTION_ALL = 4095
REMOTE_ACTION_RAW_READ = 4096,
REMOTE_ACTION_ALL = 8191
};
enum ClientType
@@ -56,8 +57,12 @@ public:
virtual int Head(const std::string &path, void *buffer, uint64_t len) = 0;
virtual int GetRange(const std::string &path, void *buffer, uint64_t size, uint64_t offset) = 0;
virtual int GetRange(const std::string &path, DataSink &sink, uint64_t size, uint64_t offset) = 0;
virtual int GetRange(void *fp, void *buffer, uint64_t size, uint64_t offset) = 0;
virtual int GetRange(void *fp, DataSink &sink, uint64_t size, uint64_t offset) = 0;
virtual bool FileExists(const std::string &path) = 0;
virtual std::vector<DirEntry> ListDir(const std::string &path) = 0;
virtual void *Open(const std::string &path, int flags) = 0;
virtual void Close(void *fp) = 0;
virtual std::string GetPath(std::string path1, std::string path2) = 0;
virtual bool IsConnected() = 0;
virtual bool Ping() = 0;
+34 -3
View File
@@ -284,6 +284,8 @@ int SFTPClient::Get(const std::string &outputfile, const std::string &path, uint
char *buff = (char *)malloc(FTP_CLIENT_BUFSIZ);
int rc, count = 0;
bytes_transfered = 0;
sceRtcGetCurrentTick(&prev_tick);
do
{
rc = libssh2_sftp_read(sftp_handle, buff, FTP_CLIENT_BUFSIZ);
@@ -313,6 +315,16 @@ int SFTPClient::GetRange(const std::string &path, DataSink &sink, uint64_t size,
return 0;
}
int ret = this->GetRange((void *)sftp_handle, sink, size, offset);
libssh2_sftp_close(sftp_handle);
return ret;
}
int SFTPClient::GetRange(void *fp, DataSink &sink, uint64_t size, uint64_t offset)
{
LIBSSH2_SFTP_HANDLE *sftp_handle = (LIBSSH2_SFTP_HANDLE *) fp;
libssh2_sftp_seek64(sftp_handle, offset);
char *buff = (char *)malloc(FTP_CLIENT_BUFSIZ);
@@ -329,7 +341,6 @@ int SFTPClient::GetRange(const std::string &path, DataSink &sink, uint64_t size,
if (!ok)
{
free((char *)buff);
libssh2_sftp_close(sftp_handle);
return 0;
}
}
@@ -340,7 +351,6 @@ int SFTPClient::GetRange(const std::string &path, DataSink &sink, uint64_t size,
} while (1);
free((char *)buff);
libssh2_sftp_close(sftp_handle);
return 1;
}
@@ -359,9 +369,18 @@ int SFTPClient::GetRange(const std::string &path, void *buffer, uint64_t size, u
return 0;
}
int ret = this->GetRange(sftp_handle, buffer, size, offset);
libssh2_sftp_close(sftp_handle);
return ret;
}
int SFTPClient::GetRange(void *fp, void *buffer, uint64_t size, uint64_t offset)
{
LIBSSH2_SFTP_HANDLE *sftp_handle = (LIBSSH2_SFTP_HANDLE *) fp;
libssh2_sftp_seek64(sftp_handle, offset);
int count = libssh2_sftp_read(sftp_handle, (char *)buffer, size);
libssh2_sftp_close(sftp_handle);
if (count != size)
return 0;
@@ -401,6 +420,8 @@ int SFTPClient::Put(const std::string &inputfile, const std::string &path, uint6
buff = (char *)malloc(FTP_CLIENT_BUFSIZ);
int nread, count = 0;
bytes_transfered = 0;
sceRtcGetCurrentTick(&prev_tick);
do
{
nread = FS::Read(in, buff, FTP_CLIENT_BUFSIZ);
@@ -642,6 +663,16 @@ int SFTPClient::Quit()
return 1;
}
void *SFTPClient::Open(const std::string &path, int flags)
{
return libssh2_sftp_open(sftp_session, path.c_str(), LIBSSH2_FXF_READ, 0);
}
void SFTPClient::Close(void *fp)
{
libssh2_sftp_close((LIBSSH2_SFTP_HANDLE *)fp);
}
ClientType SFTPClient::clientType()
{
return CLIENT_TYPE_SFTP;
+6 -2
View File
@@ -1,5 +1,5 @@
#ifndef SFTPCLIENT_H
#define SFTPCLIENT_H
#ifndef EZ_SFTPCLIENT_H
#define EZ_SFTPCLIENT_H
#include <libssh2.h>
#include <libssh2_sftp.h>
@@ -22,6 +22,8 @@ public:
int Get(const std::string &outputfile, const std::string &path, uint64_t offset=0);
int GetRange(const std::string &path, void *buffer, uint64_t size, uint64_t offset);
int GetRange(const std::string &path, DataSink &sink, uint64_t size, uint64_t offset);
int GetRange(void *fp, void *buffer, uint64_t size, uint64_t offset);
int GetRange(void *fp, DataSink &sink, uint64_t size, uint64_t offset);
int Put(const std::string &inputfile, const std::string &path, uint64_t offset=0);
int Rename(const std::string &src, const std::string &dst);
int Delete(const std::string &path);
@@ -30,6 +32,8 @@ public:
int Head(const std::string &path, void *buffer, uint64_t len);
bool FileExists(const std::string &path);
std::vector<DirEntry> ListDir(const std::string &path);
void *Open(const std::string &path, int flags);
void Close(void *fp);
std::string GetPath(std::string path1, std::string path2);
bool IsConnected();
bool Ping();
+38 -3
View File
@@ -214,6 +214,8 @@ int SmbClient::Get(const std::string &outputfile, const std::string &ppath, uint
uint8_t *buff = (uint8_t*)malloc(max_read_size);
int count = 0;
bytes_transfered = 0;
sceRtcGetCurrentTick(&prev_tick);
while ((count = smb2_read(smb2, in, buff, max_read_size)) > 0)
{
if (count < 0)
@@ -243,6 +245,16 @@ int SmbClient::GetRange(const std::string &ppath, DataSink &sink, uint64_t size,
return 0;
}
int ret = this->GetRange((void *)in, sink, size, offset);
smb2_close(smb2, in);
return ret;
}
int SmbClient::GetRange(void *fp, DataSink &sink, uint64_t size, uint64_t offset)
{
struct smb2fh* in = (struct smb2fh*)fp;
smb2_lseek(smb2, in, offset, SEEK_SET, NULL);
uint8_t *buff = (uint8_t*)malloc(max_read_size);
@@ -259,7 +271,6 @@ int SmbClient::GetRange(const std::string &ppath, DataSink &sink, uint64_t size,
if (!ok)
{
free((uint8_t *)buff);
smb2_close(smb2, in);
return 0;
}
}
@@ -270,7 +281,6 @@ int SmbClient::GetRange(const std::string &ppath, DataSink &sink, uint64_t size,
} while (1);
free((char *)buff);
smb2_close(smb2, in);
return 1;
}
@@ -291,10 +301,19 @@ int SmbClient::GetRange(const std::string &ppath, void *buffer, uint64_t size, u
return 0;
}
int ret = this->GetRange(in, buffer, size, offset);
smb2_close(smb2, in);
return ret;
}
int SmbClient::GetRange(void *fp, void *buffer, uint64_t size, uint64_t offset)
{
struct smb2fh* in = (struct smb2fh*) fp;
smb2_lseek(smb2, in, offset, SEEK_SET, NULL);
int count = smb2_read(smb2, in, (uint8_t*)buffer, size);
smb2_close(smb2, in);
if (count != size)
return 0;
@@ -401,6 +420,8 @@ int SmbClient::Put(const std::string &inputfile, const std::string &ppath, uint6
uint8_t* buff = (uint8_t*)malloc(max_write_size);
int count = 0;
bytes_transfered = 0;
sceRtcGetCurrentTick(&prev_tick);
while ((count = FS::Read(in, buff, max_write_size)) > 0)
{
if (count < 0)
@@ -567,6 +588,20 @@ int SmbClient::Head(const std::string &ppath, void *buffer, uint64_t len)
return 1;
}
void *SmbClient::Open(const std::string &ppath, int flags)
{
std::string path = std::string(ppath);
path = Util::Trim(path, "/");
struct smb2fh* in = smb2_open(smb2, path.c_str(), flags);
return in;
}
void SmbClient::Close(void *fp)
{
smb2_close(smb2, (struct smb2fh*)fp);
}
ClientType SmbClient::clientType()
{
return CLIENT_TYPE_SMB;
+6 -2
View File
@@ -1,5 +1,5 @@
#ifndef SMBCLIENT_H
#define SMBCLIENT_H
#ifndef EZ_SMBCLIENT_H
#define EZ_SMBCLIENT_H
#include <sys/socket.h>
#include <arpa/inet.h>
@@ -26,6 +26,8 @@ public:
int Get(const std::string &outputfile, const std::string &path, uint64_t offset=0);
int GetRange(const std::string &path, void *buffer, uint64_t size, uint64_t offset);
int GetRange(const std::string &path, DataSink &sink, uint64_t size, uint64_t offset);
int GetRange(void *fp, void *buffer, uint64_t size, uint64_t offset);
int GetRange(void *fp, DataSink &sink, uint64_t size, uint64_t offset);
int Put(const std::string &inputfile, const std::string &path, uint64_t offset=0);
int Rename(const std::string &src, const std::string &dst);
int Delete(const std::string &path);
@@ -34,6 +36,8 @@ public:
int Move(const std::string &from, const std::string &to);
int CopyToSocket(const std::string &path, int socket_fd);
std::vector<DirEntry> ListDir(const std::string &path);
void *Open(const std::string &path, int flags);
void Close(void *fp);
bool IsConnected();
bool Ping();
const char *LastResponse();
+2 -1
View File
@@ -151,6 +151,7 @@ int WebDAVClient::Put(const std::string &inputfile, const std::string &path, uin
{
size_t bytes_remaining = FS::GetSize(inputfile);
bytes_transfered = 0;
sceRtcGetCurrentTick(&prev_tick);
FILE* in = FS::OpenRead(inputfile);
@@ -279,5 +280,5 @@ ClientType WebDAVClient::clientType()
uint32_t WebDAVClient::SupportedActions()
{
return REMOTE_ACTION_ALL;
return REMOTE_ACTION_ALL ^ REMOTE_ACTION_RAW_READ;
}
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef WEBDAV_H
#define WEBDAV_H
#ifndef EZ_WEBDAV_H
#define EZ_WEBDAV_H
#include <string>
#include <vector>
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef COMMON_H
#define COMMON_H
#ifndef EZ_COMMON_H
#define EZ_COMMON_H
#include <string>
#include <vector>
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef LAUNCHER_CONFIG_H
#define LAUNCHER_CONFIG_H
#ifndef EZ_CONFIG_H
#define EZ_CONFIG_H
#include <string>
#include <vector>
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef FICHIER_HOST_H
#define FICHIER_HOST_H
#ifndef EZ_FICHIER_HOST_H
#define EZ_FICHIER_HOST_H
#include "filehost.h"
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef ALLDEBRID_HOST_H
#define ALLDEBRID_HOST_H
#ifndef EZ_ALLDEBRID_HOST_H
#define EZ_ALLDEBRID_HOST_H
#include "filehost.h"
-2
View File
@@ -1,6 +1,4 @@
#include <regex>
#include <lexbor/html/parser.h>
#include <lexbor/dom/interfaces/element.h>
#include <http/httplib.h>
#include "common.h"
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef DIRECT_HOST_H
#define DIRECT_HOST_H
#ifndef EZ_DIRECT_HOST_H
#define EZ_DIRECT_HOST_H
#include "filehost.h"
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef FILEHOST_H
#define FILEHOST_H
#ifndef EZ_FILEHOST_H
#define EZ_FILEHOST_H
#include <string>
#include <vector>
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef GDRIVE_HOST_H
#define GDRIVE_HOST_H
#ifndef EZ_GDRIVE_HOST_H
#define EZ_GDRIVE_HOST_H
#include "filehost.h"
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef MEDIAFIRE_HOST_H
#define MEDIAFIRE_HOST_H
#ifndef EZ_MEDIAFIRE_HOST_H
#define EZ_MEDIAFIRE_HOST_H
#include "filehost.h"
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef PIXELDRAIN_HOST_H
#define PIXELDRAIN_HOST_H
#ifndef EZ_PIXELDRAIN_HOST_H
#define EZ_PIXELDRAIN_HOST_H
#include "filehost.h"
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef REALDEBRID_HOST_H
#define REALDEBRID_HOST_H
#ifndef EZ_REALDEBRID_HOST_H
#define EZ_REALDEBRID_HOST_H
#include "filehost.h"
+2
View File
@@ -510,6 +510,8 @@ namespace FS
size_t bytes_read = 0;
bytes_transfered = 0;
sceRtcGetCurrentTick(&prev_tick);
const size_t buf_size = 0x10000;
unsigned char *buf = new unsigned char[buf_size];
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef LAUNCHER_FS_H
#define LAUNCHER_FS_H
#ifndef EZ_FS_H
#define EZ_FS_H
#pragma once
#include <string.h>
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef LAUNCHER_GUI_H
#define LAUNCHER_GUI_H
#ifndef EZ_GUI_H
#define EZ_GUI_H
#include <string>
#include "SDL2/SDL.h"
+2 -2
View File
@@ -16,8 +16,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __IME_DIALOG_H__
#define __IME_DIALOG_H__
#ifndef __EZ_IME_DIALOG_H__
#define __EZ_IME_DIALOG_H__
#define IME_DIALOG_RESULT_NONE 0
#define IME_DIALOG_RESULT_RUNNING 1
+8 -3
View File
@@ -221,8 +221,7 @@ namespace INSTALLER
{
std::string encoded_path = httplib::detail::encode_url(path);
std::string encoded_site_name = httplib::detail::encode_url(remote_settings->site_name);
std::string full_url = std::string("http://localhost:") + std::to_string(http_server_port) + "/rmt_inst" + encoded_site_name + encoded_path;
std::string full_url = std::string("http://localhost:") + std::to_string(http_server_port) + "/rmt_inst/" + encoded_site_name + encoded_path;
return full_url;
}
@@ -386,12 +385,13 @@ namespace INSTALLER
}
Util::Notify("%s queued", display_title.c_str());
if (prompt)
{
file_transfering = true;
bytes_to_download = 100;
bytes_transfered = 0;
sceRtcGetCurrentTick(&prev_tick);
while (!completed)
{
memset(&progress_info, 0, sizeof(progress_info));
@@ -491,6 +491,7 @@ namespace INSTALLER
file_transfering = true;
bytes_to_download = 100;
bytes_transfered = 0;
while (!completed)
{
memset(&progress_info, 0, sizeof(progress_info));
@@ -602,6 +603,8 @@ namespace INSTALLER
sprintf(activity_message, "%s", lang_strings[STR_WAIT_FOR_INSTALL_MSG]);
bytes_to_download = 1;
bytes_transfered = 0;
sceRtcGetCurrentTick(&prev_tick);
while (!completed)
{
memset(&progress_info, 0, sizeof(progress_info));
@@ -918,6 +921,8 @@ namespace INSTALLER
file_transfering = true;
bytes_to_download = 100;
bytes_transfered = 0;
sceRtcGetCurrentTick(&prev_tick);
while (!completed)
{
memset(&progress_info, 0, sizeof(progress_info));
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef __LANG_H__
#define __LANG_H__
#ifndef __EZ_LANG_H__
#define __EZ_LANG_H__
#include "config.h"
+197
View File
@@ -0,0 +1,197 @@
#include <stdio.h>
#include <stdio.h>
#include <string>
#include "common.h"
#include "mem_file.h"
MemFile::MemFile(const std::string &path, size_t block_size)
{
this->block_size = block_size;
this->complete = false;
sem_init(&this->block_ready, 0, 0);
}
MemFile::~MemFile()
{
for (int i = 0; i < this->mem_blocks.size(); i++)
{
if (this->mem_blocks[i] != nullptr && this->mem_blocks[i]->status != MEM_BLOCK_STATUS_DELETED)
{
if (this->mem_blocks[i]->buf != nullptr)
{
free(this->mem_blocks[i]->buf);
this->mem_blocks[i]->buf = nullptr;
}
free(this->mem_blocks[i]);
}
}
sem_destroy(&this->block_ready);
};
int MemFile::Open()
{
this->block_in_progress = NewBlock();
this->block_in_progress->buf = malloc(block_size);
return (block_in_progress->buf == nullptr);
}
size_t MemFile::Read(char *buf, size_t buf_size, size_t offset)
{
int first_block_num, block_num;
size_t block_offset;
size_t remaining;
size_t bytes_read;
size_t total_bytes_read;
MemBlock *block;
char *p;
first_block_num= offset / this->block_size;
block_num = first_block_num;
block_offset = offset % this->block_size;
while ((block_num >= this->mem_blocks.size() && !this->complete) ||
(block_num < this->mem_blocks.size() && this->mem_blocks[block_num]->status == MEM_BLOCK_STATUS_NOT_EXISTS))
{
sem_wait(&this->block_ready);
}
block = this->mem_blocks[block_num];
if (block->status == MEM_BLOCK_STATUS_DELETED)
{
return -1;
}
if (block_offset > block->size - 1 && this->complete)
{
// requested offset is pass the end of split file
return 0;
}
remaining = buf_size;
bool eof = false;
total_bytes_read = 0;
p = buf;
while (remaining > 0 && !eof)
{
uint8_t *src = (uint8_t*)block->buf;
src += block_offset;
bytes_read = block_size - block_offset;
memcpy(p, src, bytes_read);
if (bytes_read == remaining)
{
p += bytes_read;
total_bytes_read += bytes_read;
}
else
{
p += bytes_read;
total_bytes_read += bytes_read;
if (block->is_last)
{
eof = true;
continue;
}
}
remaining -= bytes_read;
if (remaining == 0)
continue;
block_num++;
block_offset = 0;
while ((block_num > this->mem_blocks.size() - 1 && !this->complete) ||
this->mem_blocks[block_num]->status == MEM_BLOCK_STATUS_NOT_EXISTS)
{
sem_wait(&this->block_ready);
}
block = this->mem_blocks[block_num];
}
// delete blocks before the first read offset block. Assumuption, that reads are always
// forward and won't read previously already read blocks. For safety, keeping only current block and 2 previous blocks
for (int j=0; j < first_block_num - 2; j++)
{
if (this->mem_blocks[j]->status == MEM_BLOCK_STATUS_CREATED)
{
if (this->mem_blocks[j]->buf != nullptr)
{
free(this->mem_blocks[j]->buf);
this->mem_blocks[j]->buf = nullptr;
}
this->mem_blocks[j]->status = MEM_BLOCK_STATUS_DELETED;
}
}
return total_bytes_read;
}
size_t MemFile::Write(char *buf, size_t buf_size)
{
size_t bytes_written;
size_t block_space_remaining;
size_t bytes_to_write;
char *p = buf;
size_t total_bytes_written = 0;
size_t remaining_to_write = buf_size;
while (remaining_to_write > 0)
{
block_space_remaining = this->block_size - block_in_progress->size;
bytes_to_write = MIN(remaining_to_write, block_space_remaining);
memcpy(block_in_progress->buf, p, bytes_to_write);
bytes_written = bytes_to_write;
block_in_progress->size += bytes_written;
total_bytes_written += bytes_written;
remaining_to_write -= bytes_written;
block_space_remaining -= bytes_written;
p += bytes_written;
// error if bytes_to_write != bytes_written
if (bytes_written != bytes_to_write)
{
break;
}
if (block_space_remaining == 0)
{
block_in_progress->status = MEM_BLOCK_STATUS_CREATED;
this->mem_blocks.push_back(block_in_progress);
sem_post(&this->block_ready);
block_in_progress = NewBlock();
}
}
return total_bytes_written;
}
int MemFile::Close()
{
block_in_progress->status = MEM_BLOCK_STATUS_CREATED;
block_in_progress->is_last = true;
this->mem_blocks.push_back(block_in_progress);
this->complete = true;
sem_post(&this->block_ready);
return 0;
}
MemBlock *MemFile::NewBlock()
{
MemBlock *block = (MemBlock *)malloc(sizeof(MemBlock));
memset(block, 0, sizeof(MemBlock));
block->is_last = false;
block->size = 0;
block->buf = malloc(block_size);
return block;
}
+46
View File
@@ -0,0 +1,46 @@
#ifndef EZ_MEM_FILE_H
#define EZ_MEM_FILE_H
#include <string>
#include <vector>
#include <mutex>
#include <pthread.h>
enum MemBlockStatus
{
MEM_BLOCK_STATUS_NOT_EXISTS,
MEM_BLOCK_STATUS_CREATED,
MEM_BLOCK_STATUS_DELETED
};
typedef struct
{
size_t size;
void* buf;
bool is_last;
MemBlockStatus status;
} MemBlock;
class MemFile
{
public:
MemFile(const std::string& path, size_t block_size);
~MemFile();
size_t Read(char* buf, size_t buf_size, size_t offset);
size_t Write(char* buf, size_t buf_size);
int Open();
int Close();
private:
std::vector<MemBlock*> mem_blocks;
size_t write_offset;
size_t block_size;
int write_error;
bool complete;
MemBlock *block_in_progress;
sem_t block_ready;
MemBlock *NewBlock();
};
#endif
+220 -160
View File
@@ -8,6 +8,12 @@
#include "clients/smbclient.h"
#include "clients/ftpclient.h"
#include "clients/nfsclient.h"
#include "clients/webdav.h"
#include "clients/apache.h"
#include "clients/iis.h"
#include "clients/nginx.h"
#include "clients/npxserve.h"
#include "clients/rclone.h"
#include "filehost/filehost.h"
#include "config.h"
#include "fs.h"
@@ -17,6 +23,7 @@
#include "zip_util.h"
#include "util.h"
#include "installer.h"
// #include "dbglogger.h"
#define SERVER_CERT_FILE "/app0/assets/certs/domain.crt"
#define SERVER_PRIVATE_KEY_FILE "/app0/assets/certs/domain.key"
@@ -24,9 +31,18 @@
#define SUCCESS_MSG "{ \"result\": { \"success\": true, \"error\": null } }"
#define FAILURE_MSG "{ \"result\": { \"success\": false, \"error\": \"%s\" } }"
#define SUCCESS_MSG_LEN 48
#define PKG_INITIAL_REQUEST_SIZE 8388608ul
using namespace httplib;
struct RemoteDownloadData
{
RemoteClient *client = nullptr;
std::map<std::string, void *> fp_handles;
};
static RemoteDownloadData remote_data[100];
Server *svr;
int http_server_port = 8080;
char compressed_file_path[1024];
@@ -91,22 +107,22 @@ namespace HttpServer
return s;
}
void failed(Response & res, int status, const std::string &msg)
void failed(Response &res, int status, const std::string &msg)
{
res.status = status;
char response_msg[msg.length()+strlen(FAILURE_MSG)+2];
char response_msg[msg.length() + strlen(FAILURE_MSG) + 2];
snprintf(response_msg, sizeof(response_msg), "{ \"result\": { \"success\": false, \"error\": \"%s\" } }", msg.c_str());
res.set_content(response_msg, strlen(response_msg), "application/json");
return;
}
void bad_request(Response & res, const std::string &msg)
void bad_request(Response &res, const std::string &msg)
{
failed(res, 200, msg);
return;
}
void success(Response & res)
void success(Response &res)
{
res.status = 200;
res.set_content(SUCCESS_MSG, SUCCESS_MSG_LEN, "application/json");
@@ -182,15 +198,87 @@ namespace HttpServer
return 1;
}
static RemoteClient *GetRemoteClient(int site_idx, bool new_client)
{
RemoteClient *tmp_client;
RemoteSettings *tmp_settings = &site_settings[sites[site_idx]];
if (!new_client)
{
tmp_client = remote_data[site_idx].client;
if (tmp_client != nullptr)
return tmp_client;
}
if (tmp_settings->type == CLIENT_TYPE_SFTP)
{
tmp_client = new SFTPClient();
}
else if (tmp_settings->type == CLIENT_TYPE_SMB)
{
tmp_client = new SmbClient();
}
else if (tmp_settings->type == CLIENT_TYPE_FTP)
{
tmp_client = new FtpClient();
}
else if (tmp_settings->type == CLIENT_TYPE_NFS)
{
tmp_client = new NfsClient();
}
else if (tmp_settings->type == CLIENT_TYPE_WEBDAV)
{
tmp_client = new WebDAVClient();
}
else if (tmp_settings->type == CLIENT_TYPE_GOOGLE)
{
if (remoteclient != nullptr && remoteclient->clientType() == CLIENT_TYPE_GOOGLE)
tmp_client = remoteclient;
else
tmp_client = new GDriveClient();
tmp_client->Connect("", "", "");
}
else if (tmp_settings->type == CLIENT_TYPE_HTTP_SERVER)
{
if (strcmp(remote_settings->http_server_type, HTTP_SERVER_APACHE) == 0)
tmp_client = new ApacheClient();
else if (strcmp(remote_settings->http_server_type, HTTP_SERVER_MS_IIS) == 0)
tmp_client = new IISClient();
else if (strcmp(remote_settings->http_server_type, HTTP_SERVER_NGINX) == 0)
tmp_client = new NginxClient();
else if (strcmp(remote_settings->http_server_type, HTTP_SERVER_NPX_SERVE) == 0)
tmp_client = new NpxServeClient();
else if (strcmp(remote_settings->http_server_type, HTTP_SERVER_RCLONE) == 0)
tmp_client = new RCloneClient();
}
if (tmp_client->clientType() != CLIENT_TYPE_GOOGLE)
tmp_client->Connect(tmp_settings->server, tmp_settings->username, tmp_settings->password);
if (!new_client && tmp_client->clientType() != CLIENT_TYPE_FTP)
{
remote_data[site_idx].client = tmp_client;
}
return tmp_client;
}
static void DeleteRemoteClient(RemoteClient *tmp_client, int site_idx)
{
if (tmp_client != nullptr && tmp_client->clientType() != CLIENT_TYPE_GOOGLE)
{
tmp_client->Quit();
delete tmp_client;
}
}
void *ServerThread(void *argp)
{
svr->Get("/", [&](const Request & req, Response & res)
{
res.set_redirect("/index.html");
});
svr->Get("/", [&](const Request &req, Response &res)
{ res.set_redirect("/index.html"); });
svr->Get("/index.html", [&](const Request & req, Response & res)
{
svr->Get("/index.html", [&](const Request &req, Response &res)
{
FILE *in = FS::OpenRead("/mnt/sandbox/pfsmnt/RMTC00001-app0/assets/index.html");
size_t size = FS::GetSize("/mnt/sandbox/pfsmnt/RMTC00001-app0/assets/index.html");
res.set_content_provider(
@@ -206,11 +294,10 @@ namespace HttpServer
},
[in](bool success) {
FS::Close(in);
});
});
}); });
svr->Get("/favicon.ico", [&](const Request & req, Response & res)
{
svr->Get("/favicon.ico", [&](const Request &req, Response &res)
{
FILE *in = FS::OpenRead("/mnt/sandbox/pfsmnt/RMTC00001-app0/assets/favicon.ico");
size_t size = FS::GetSize("/mnt/sandbox/pfsmnt/RMTC00001-app0/assets/favicon.ico");
res.set_content_provider(
@@ -226,11 +313,10 @@ namespace HttpServer
},
[in](bool success) {
FS::Close(in);
});
});
}); });
svr->Post("/__local__/list", [&](const Request & req, Response & res)
{
svr->Post("/__local__/list", [&](const Request &req, Response &res)
{
const char *path;
bool onlyFolders = false;
json_object *jobj = json_tokener_parse(req.body.c_str());
@@ -276,11 +362,10 @@ namespace HttpServer
json_object_object_add(results, "result", json_files);
const char *results_str = json_object_to_json_string(results);
res.status = 200;
res.set_content(results_str, strlen(results_str), "application/json");
});
res.set_content(results_str, strlen(results_str), "application/json"); });
svr->Post("/__local__/rename", [&](const Request & req, Response & res)
{
svr->Post("/__local__/rename", [&](const Request &req, Response &res)
{
const char *item;
const char *newItemPath;
json_object *jobj = json_tokener_parse(req.body.c_str());
@@ -302,11 +387,10 @@ namespace HttpServer
FS::Rename(item, newItemPath);
success(res);
return;
});
return; });
svr->Post("/__local__/move", [&](const Request & req, Response & res)
{
svr->Post("/__local__/move", [&](const Request &req, Response &res)
{
const json_object *items;
const char *newPath;
json_object *jobj = json_tokener_parse(req.body.c_str());
@@ -357,11 +441,10 @@ namespace HttpServer
failed(res, 200, error_msg);
}
else
success(res);
});
success(res); });
svr->Post("/__local__/copy", [&](const Request & req, Response & res)
{
svr->Post("/__local__/copy", [&](const Request &req, Response &res)
{
const json_object *items;
const char *newPath;
const char *singleFilename;
@@ -432,11 +515,10 @@ namespace HttpServer
failed(res, 200, error_msg);
}
else
success(res);
});
success(res); });
svr->Post("/__local__/remove", [&](const Request & req, Response & res)
{
svr->Post("/__local__/remove", [&](const Request &req, Response &res)
{
json_object *items;
json_object *jobj = json_tokener_parse(req.body.c_str());
if (jobj != nullptr)
@@ -472,11 +554,10 @@ namespace HttpServer
failed(res, 200, error_msg);
}
else
success(res);
});
success(res); });
svr->Post("/__local__/install", [&](const Request & req, Response & res)
{
svr->Post("/__local__/install", [&](const Request &req, Response &res)
{
json_object *items;
json_object *jobj = json_tokener_parse(req.body.c_str());
if (jobj != nullptr)
@@ -509,11 +590,10 @@ namespace HttpServer
failed(res, 200, error_msg);
}
else
success(res);
});
success(res); });
svr->Post("/__local__/edit", [&](const Request & req, Response & res)
{
svr->Post("/__local__/edit", [&](const Request &req, Response &res)
{
const char *item;
const char *content;
size_t content_len;
@@ -543,11 +623,10 @@ namespace HttpServer
return;
}
success(res);
});
success(res); });
svr->Post("/__local__/getContent", [&](const Request & req, Response & res)
{
svr->Post("/__local__/getContent", [&](const Request &req, Response &res)
{
const char *item;
json_object *jobj = json_tokener_parse(req.body.c_str());
if (jobj != nullptr)
@@ -570,11 +649,10 @@ namespace HttpServer
json_object_object_add(result, "result", json_object_new_string(content.data()));
const char *result_str = json_object_to_json_string(result);
res.status = 200;
res.set_content(result_str, strlen(result_str), "application/json");
});
res.set_content(result_str, strlen(result_str), "application/json"); });
svr->Post("/__local__/createFolder", [&](const Request & req, Response & res)
{
svr->Post("/__local__/createFolder", [&](const Request &req, Response &res)
{
const char *newPath;
json_object *jobj = json_tokener_parse(req.body.c_str());
if (jobj != nullptr)
@@ -593,16 +671,13 @@ namespace HttpServer
}
FS::MkDirs(newPath);
success(res);
});
success(res); });
svr->Post("/__local__/permission", [&](const Request & req, Response & res)
{
failed(res, 200, "Operation not supported");
});
svr->Post("/__local__/permission", [&](const Request &req, Response &res)
{ failed(res, 200, "Operation not supported"); });
svr->Post("/__local__/compress", [&](const Request & req, Response & res)
{
svr->Post("/__local__/compress", [&](const Request &req, Response &res)
{
json_object *items;
const char* destination;
const char* compressedFilename;
@@ -652,11 +727,10 @@ namespace HttpServer
else
{
failed(res, 200, "Failed to create zip");
}
});
} });
svr->Post("/__local__/extract", [&](const Request & req, Response & res)
{
svr->Post("/__local__/extract", [&](const Request &req, Response &res)
{
const char* item;
const char* destination;
const char* folderName;
@@ -692,11 +766,10 @@ namespace HttpServer
else if (ret == -1)
failed(res, 200, "Unsupported compressed file format");
else
success(res);
});
success(res); });
svr->Get("/__local__/uploadResumeSize", [&](const Request &req, Response &res)
{
{
std::string destination = req.get_param_value("destination");
std::string filename = req.get_param_value("filename");
std::string file_path = destination + "/" + filename;
@@ -705,11 +778,10 @@ namespace HttpServer
size = FS::GetSize(file_path);
std::string result_str = "{\"size\":" + std::to_string(size) + "}";
res.status = 200;
res.set_content(result_str.c_str(), result_str.length(), "application/json");
});
res.set_content(result_str.c_str(), result_str.length(), "application/json"); });
svr->Post("/__local__/upload", [&](const Request &req, Response &res, const ContentReader &content_reader)
{
{
MultipartFormDataItems items;
std::string destination;
size_t chunk_size = 0;
@@ -775,12 +847,11 @@ namespace HttpServer
{
FS::Close(out);
}
success(res);
});
success(res); });
// Download multiple files as ZIP
svr->Get("/__local__/downloadMultiple", [&](const Request & req, Response & res)
{
svr->Get("/__local__/downloadMultiple", [&](const Request &req, Response &res)
{
if (req.get_param_value_count("items") == 0 || req.get_param_value_count("toFilename") == 0)
{
failed(res, 200, "Required items and toFilename parameter missing");
@@ -834,12 +905,11 @@ namespace HttpServer
else
{
failed(res, 200, "Failed to create zip");
}
});
} });
// Download single file
svr->Get("/__local__/downloadFile", [&](const Request & req, Response & res)
{
svr->Get("/__local__/downloadFile", [&](const Request &req, Response &res)
{
std::string path = req.get_param_value("path", 0);
if (path.empty())
{
@@ -869,11 +939,10 @@ namespace HttpServer
},
[in](bool success) {
FS::Close(in);
});
});
}); });
svr->Get("/google_auth", [](const Request &req, Response &res)
{
{
std::string auth_code = req.get_param_value("code");
Client client(GOOGLE_OAUTH_HOST);
client.set_follow_location(true);
@@ -919,12 +988,11 @@ namespace HttpServer
}
login_state = -1;
std::string str = std::string(lang_strings[STR_FAIL_GET_TOKEN_MSG]) + " Google";
res.set_content(str.c_str(), "text/plain");
});
res.set_content(str.c_str(), "text/plain"); });
svr->Get("/rmt_inst/Site (\\d+)(/)(.*)", [&](const Request & req, Response & res)
{
RemoteClient *tmp_client;
svr->Get("/rmt_inst/Site (\\d+)(/)(.*)", [&](const Request &req, Response &res)
{
RemoteClient *tmp_client = nullptr;
RemoteSettings *tmp_settings;
auto site_idx = std::stoi(req.matches[1])-1;
std::string path;
@@ -932,33 +1000,6 @@ namespace HttpServer
if (site_idx != 98)
{
path = std::string("/") + std::string(req.matches[3]);
tmp_settings = &site_settings[sites[site_idx]];
if (tmp_settings->type == CLIENT_TYPE_SFTP)
{
tmp_client = new SFTPClient();
tmp_client->Connect(tmp_settings->server, tmp_settings->username, tmp_settings->password);
}
else if (tmp_settings->type == CLIENT_TYPE_SMB)
{
tmp_client = new SmbClient();
tmp_client->Connect(tmp_settings->server, tmp_settings->username, tmp_settings->password);
}
else if (tmp_settings->type == CLIENT_TYPE_FTP)
{
tmp_client = new FtpClient();
tmp_client->Connect(tmp_settings->server, tmp_settings->username, tmp_settings->password);
}
else if (tmp_settings->type == CLIENT_TYPE_NFS)
{
tmp_client = new NfsClient();
tmp_client->Connect(tmp_settings->server, tmp_settings->username, tmp_settings->password);
}
else
{
tmp_client = remoteclient;
}
}
else
{
@@ -973,33 +1014,34 @@ namespace HttpServer
tmp_client->Connect(host, "", "");
}
if (tmp_client == nullptr || !tmp_client->IsConnected())
{
res.status = 404;
return;
}
if (req.method == "HEAD")
{
int64_t file_size;
int ret;
if (site_idx != 98)
tmp_client = GetRemoteClient(site_idx, true);
ret = tmp_client->Size(path, &file_size);
if (!ret)
{
res.status = 500;
DeleteRemoteClient(tmp_client, site_idx);
return;
}
res.status = 204;
res.set_header("Content-Length", std::to_string(file_size));
res.set_header("Accept-Ranges", "bytes");
DeleteRemoteClient(tmp_client, site_idx);
return;
}
if (req.ranges.empty())
{
res.status = 200;
if (site_idx != 98)
tmp_client = GetRemoteClient(site_idx, true);
res.set_content_provider(
(1024*128), "application/octet-stream",
[tmp_client, path](size_t offset, size_t length, DataSink &sink) {
@@ -1007,15 +1049,7 @@ namespace HttpServer
return (ret == 1);
},
[tmp_client, path, site_idx](bool success) {
if (tmp_client != nullptr && (tmp_client->clientType() == CLIENT_TYPE_SFTP
|| tmp_client->clientType() == CLIENT_TYPE_SMB
|| tmp_client->clientType() == CLIENT_TYPE_FTP
|| tmp_client->clientType() == CLIENT_TYPE_NFS
|| (tmp_client->clientType() == CLIENT_TYPE_HTTP_SERVER && site_idx == 98)))
{
tmp_client->Quit();
delete tmp_client;
}
DeleteRemoteClient(tmp_client, site_idx);
});
}
else
@@ -1024,33 +1058,61 @@ namespace HttpServer
size_t range_len = (req.ranges[0].second - req.ranges[0].first) + 1;
if (req.ranges[0].second >= 18000000000000000000ul)
{
range_len = 524288ul;
range_len = PKG_INITIAL_REQUEST_SIZE;
res.set_header("Content-Length", std::to_string(range_len));
res.set_header("Content-Range", std::string("bytes ") + std::to_string(req.ranges[0].first)+"-" + std::to_string(req.ranges[0].first+524288ul-1) + "/"+std::to_string(range_len));
res.set_header("Content-Range", std::string("bytes ") + std::to_string(req.ranges[0].first)+"-" + std::to_string(req.ranges[0].first+PKG_INITIAL_REQUEST_SIZE-1) + "/"+std::to_string(range_len));
sceRtcGetCurrentTick(&prev_tick);
if (site_idx != 98)
tmp_client = GetRemoteClient(site_idx, true);
}
else
{
if (site_idx != 98)
tmp_client = GetRemoteClient(site_idx, false);
}
std::pair<ssize_t, ssize_t> range = req.ranges[0];
res.set_content_provider(
range_len, "application/octet-stream",
[tmp_client, path, range, range_len](size_t offset, size_t length, DataSink &sink) {
int ret = tmp_client->GetRange(path, sink, range_len, range.first);
return (ret == 1);
},
[tmp_client, site_idx, path, range, range_len](bool success) {
if (tmp_client != nullptr && (tmp_client->clientType() == CLIENT_TYPE_SFTP
|| tmp_client->clientType() == CLIENT_TYPE_SMB
|| tmp_client->clientType() == CLIENT_TYPE_FTP
|| tmp_client->clientType() == CLIENT_TYPE_NFS
|| (tmp_client->clientType() == CLIENT_TYPE_HTTP_SERVER && site_idx == 98)))
[tmp_client, path, range, range_len, site_idx](size_t offset, size_t length, DataSink &sink) {
int ret;
if (range_len == PKG_INITIAL_REQUEST_SIZE)
{
tmp_client->Quit();
delete tmp_client;
ret = tmp_client->GetRange(path, sink, range_len, range.first);
}
else if ((tmp_client->SupportedActions() & REMOTE_ACTION_RAW_READ) == 0)
{
ret = tmp_client->GetRange(path, sink, range_len, range.first);
}
else
{
std::map<std::string, void *>::iterator it = remote_data[site_idx].fp_handles.find(path);
void *fp;
if (it == remote_data[site_idx].fp_handles.end())
{
fp = tmp_client->Open(path, O_RDONLY);
remote_data[site_idx].fp_handles[path] = fp;
}
else
{
fp = it->second;
}
ret = tmp_client->GetRange(fp, sink, range_len, range.first);
}
return (ret==1);
},
[tmp_client, path, range, site_idx](bool success) {
if (range.second >= 18000000000000000000ul ||
(tmp_client->clientType() == CLIENT_TYPE_HTTP_SERVER && site_idx == 98) ||
tmp_client->clientType() == CLIENT_TYPE_FTP)
{
DeleteRemoteClient(tmp_client, site_idx);
}
});
}
});
} });
svr->Get("/archive_inst/(.*)", [&](const Request & req, Response & res)
{
svr->Get("/archive_inst/(.*)", [&](const Request &req, Response &res)
{
RemoteClient *tmp_client;
RemoteSettings *tmp_settings;
std::string hash = req.matches[1];
@@ -1087,9 +1149,10 @@ namespace HttpServer
size_t range_len = (req.ranges[0].second - req.ranges[0].first) + 1;
if (req.ranges[0].second >= 18000000000000000000ul)
{
range_len = 524288ul;
range_len = PKG_INITIAL_REQUEST_SIZE;
res.set_header("Content-Length", std::to_string(range_len));
res.set_header("Content-Range", std::string("bytes ") + std::to_string(req.ranges[0].first)+"-" + std::to_string(req.ranges[0].first+524288ul-1) + "/"+std::to_string(range_len));
res.set_header("Content-Range", std::string("bytes ") + std::to_string(req.ranges[0].first)+"-" + std::to_string(req.ranges[0].first+PKG_INITIAL_REQUEST_SIZE-1) + "/"+std::to_string(range_len));
sceRtcGetCurrentTick(&prev_tick);
}
std::pair<ssize_t, ssize_t> range = req.ranges[0];
res.set_content_provider(
@@ -1104,11 +1167,10 @@ namespace HttpServer
[](bool success) {
return true;
});
}
});
} });
svr->Post("/__local__/install_url", [&](const Request & req, Response & res)
{
svr->Post("/__local__/install_url", [&](const Request &req, Response &res)
{
std::string url;
const char *url_param;
bool use_alldebrid = false;
@@ -1153,6 +1215,8 @@ namespace HttpServer
file_transfering = true;
bytes_to_download = 100;
bytes_transfered = 0;
sceRtcGetCurrentTick(&prev_tick);
Windows::SetModalMode(true);
std::string download_url = filehost->GetDownloadUrl();
@@ -1231,21 +1295,17 @@ namespace HttpServer
return;
}
}
success(res);
});
success(res); });
svr->Get("/stop", [&](const Request & /*req*/, Response & /*res*/)
{
svr->stop();
});
{ svr->stop(); });
svr->set_error_handler([](const Request & /*req*/, Response &res)
{
{
const char *fmt = "<p>Error Status: <span style='color:red;'>%d</span></p>";
char buf[BUFSIZ];
snprintf(buf, sizeof(buf), fmt, res.status);
res.set_content(buf, "text/html");
});
res.set_content(buf, "text/html"); });
/*
svr->set_logger([](const Request &req, const Response &res)
@@ -1257,7 +1317,7 @@ namespace HttpServer
svr->set_payload_max_length(1024 * 1024 * 12);
svr->set_tcp_nodelay(true);
svr->set_mount_point("/", "/");
if (web_server_enabled)
svr->listen("0.0.0.0", http_server_port);
else
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef HTTP_SERVER_H
#define HTTP_SERVER_H
#ifndef EZ_HTTP_SERVER_H
#define EZ_HTTP_SERVER_H
#include "http/httplib.h"
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef LAUNCHER_SFO_H
#define LAUNCHER_SFO_H
#ifndef EZ_SFO_H
#define EZ_SFO_H
#pragma once
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef SPLIT_FILE_H
#define SPLIT_FILE_H
#ifndef EZ_SPLIT_FILE_H
#define EZ_SPLIT_FILE_H
#include <string>
#include <vector>
+5
View File
@@ -1,3 +1,6 @@
#ifndef EZ_SYSTEM_H
#define EZ_SYSTEM_H
#include <stdint.h>
#ifdef __cplusplus
@@ -42,3 +45,5 @@ void convertLocalTimeToUtc(const OrbisDateTime *local_time, OrbisDateTime *utc);
#ifdef __cplusplus
}
#endif
#endif
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef LAUNCHER_TEXTURES_H
#define LAUNCHER_TEXTURES_H
#ifndef EZ_TEXTURES_H
#define EZ_TEXTURES_H
#include <string>
#include <SDL2/SDL.h>
+63 -2
View File
@@ -14,10 +14,11 @@
#include "util.h"
#include "lang.h"
#include "ime_dialog.h"
#include "IconsFontAwesome6.h"
#include "IconsFontAwesome6.h"
#include "OpenFontIcons.h"
#include "textures.h"
#include "sfo.h"
#include "system.h"
#define MAX_IMAGE_HEIGHT 980
#define MAX_IMAGE_WIDTH 1820
@@ -30,6 +31,9 @@ extern "C"
bool paused = false;
int view_mode;
static float scroll_direction = 0.0f;
static int selected_local_position = -1;
static int selected_remote_position = -1;
static ime_callback_t ime_callback = nullptr;
static ime_callback_t ime_after_update = nullptr;
static ime_callback_t ime_before_update = nullptr;
@@ -43,6 +47,8 @@ static char txt_http_server_port[6];
bool handle_updates = false;
int64_t bytes_transfered;
int64_t bytes_to_download;
OrbisTick prev_tick;
std::vector<DirEntry> local_files;
std::vector<DirEntry> remote_files;
std::set<DirEntry> multi_selected_local_files;
@@ -614,6 +620,22 @@ namespace Windows
ImGui::Text("%s", item.name);
ImGui::EndTooltip();
}
if (ImGui::IsKeyPressed(ImGuiKey_GamepadDpadUp) && !paused)
{
if (j == 0)
{
selected_local_position = local_files.size()-1;
scroll_direction = 0.0f;
}
}
else if (ImGui::IsKeyPressed(ImGuiKey_GamepadDpadDown) && !paused)
{
if (j == local_files.size()-1)
{
selected_local_position = 0;
scroll_direction = 1.0f;
}
}
}
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows))
{
@@ -623,6 +645,12 @@ namespace Windows
ImGui::SetScrollHereY(0.5f);
sprintf(local_file_to_select, "");
}
if (selected_local_position == j && !paused)
{
SetNavFocusHere();
ImGui::SetScrollHereY(scroll_direction);
selected_local_position = -1;
}
selected_browser |= LOCAL_BROWSER;
}
ImGui::NextColumn();
@@ -779,6 +807,22 @@ namespace Windows
ImGui::Text("%s", item.name);
ImGui::EndTooltip();
}
if (ImGui::IsKeyPressed(ImGuiKey_GamepadDpadUp) && !paused)
{
if (j == 0)
{
selected_remote_position = remote_files.size()-1;
scroll_direction = 0.0f;
}
}
else if (ImGui::IsKeyPressed(ImGuiKey_GamepadDpadDown) && !paused)
{
if (j == remote_files.size()-1)
{
selected_remote_position = 0;
scroll_direction = 1.0f;
}
}
}
ImGui::PopID();
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows))
@@ -789,6 +833,12 @@ namespace Windows
ImGui::SetScrollHereY(0.5f);
sprintf(remote_file_to_select, "");
}
if (selected_remote_position == j && !paused)
{
SetNavFocusHere();
ImGui::SetScrollHereY(scroll_direction);
selected_remote_position = -1;
}
selected_browser |= REMOTE_BROWSER;
}
ImGui::NextColumn();
@@ -1356,8 +1406,19 @@ namespace Windows
if (file_transfering)
{
static float progress = 0.0f;
static double transfer_speed = 0.0f;
static char progress_text[32];
static OrbisTick cur_tick;
static double tick_delta;
sceRtcGetCurrentTick(&cur_tick);
tick_delta = (cur_tick.mytick - prev_tick.mytick) * 1.0f / 1000000.0f;
progress = bytes_transfered * 1.0f / (float)bytes_to_download;
ImGui::ProgressBar(progress, ImVec2(625, 0));
transfer_speed = (bytes_transfered * 1.0f / tick_delta) / 1048576.0f;
sprintf(progress_text, "%.2fMB/s", transfer_speed);
ImGui::ProgressBar(progress, ImVec2(625, 0), progress_text);
}
ImGui::Separator();
+4 -2
View File
@@ -1,5 +1,5 @@
#ifndef LAUNCHER_WINDOWS_H
#define LAUNCHER_WINDOWS_H
#ifndef EZ_WINDOWS_H
#define EZ_WINDOWS_H
#define IMGUI_DEFINE_MATH_OPERATORS
#include <set>
@@ -7,6 +7,7 @@
#include "imgui_internal.h"
#include "common.h"
#include "actions.h"
#include "system.h"
#include "SDL2/SDL.h"
#define LOCAL_BROWSER 1
@@ -16,6 +17,7 @@ extern int view_mode;
extern bool handle_updates;
extern int64_t bytes_transfered;
extern int64_t bytes_to_download;
extern OrbisTick prev_tick;
extern std::vector<DirEntry> local_files;
extern std::vector<DirEntry> remote_files;
extern std::set<DirEntry> multi_selected_local_files;
+64 -3
View File
@@ -72,6 +72,8 @@ namespace ZipUtil
convertToZipTime(file_stat.st_mtim.tv_sec, &zi.tmz_date);
bytes_transfered = 0;
sceRtcGetCurrentTick(&prev_tick);
bytes_to_download = file_stat.st_size;
// Large file?
@@ -290,6 +292,7 @@ namespace ZipUtil
ssize_t len;
unsigned char *buffer = (unsigned char *) malloc(ARCHIVE_TRANSFER_SIZE);
bytes_transfered = 0;
sceRtcGetCurrentTick(&prev_tick);
/* loop over file contents and write to fd */
for (int n = 0;; n++)
@@ -451,6 +454,10 @@ namespace ZipUtil
client->Size(file, &data->size);
data->client = client;
data->path = file;
if (client->SupportedActions() & REMOTE_ACTION_RAW_READ)
{
data->fp = client->Open(file, O_RDONLY);
}
return data;
}
@@ -468,7 +475,11 @@ namespace ZipUtil
return 0;
to_read = MIN(to_read, ARCHIVE_TRANSFER_SIZE);
ret = data->client->GetRange(data->path, data->buf, to_read, data->offset);
if (data->client->SupportedActions() & REMOTE_ACTION_RAW_READ)
ret = data->client->GetRange((data->fp), data->buf, to_read, data->offset);
else
ret = data->client->GetRange(data->path, data->buf, to_read, data->offset);
if (ret == 0)
return -1;
data->offset = data->offset + to_read;
@@ -479,10 +490,46 @@ namespace ZipUtil
static int CloseRemoteArchive(struct archive *a, void *client_data)
{
if (client_data != nullptr)
{
RemoteArchiveData *data = (RemoteArchiveData *)client_data;
if (data->client->SupportedActions() & REMOTE_ACTION_RAW_READ)
data->client->Close(data->fp);
free(client_data);
}
return 0;
}
int64_t SeekRemoteArchive(struct archive *, void *client_data, int64_t offset, int whence)
{
RemoteArchiveData *data = (RemoteArchiveData *)client_data;
if (whence == SEEK_SET)
{
data->offset = offset;
}
else if (whence == SEEK_CUR)
{
data->offset = data->offset + offset - 1;
}
else if (whence == SEEK_END)
{
data->offset = data->size - 1;
}
else
return ARCHIVE_FATAL;
return data->offset;
}
int64_t SkipRemoteArchive(struct archive *, void *client_data, int64_t request)
{
RemoteArchiveData *data = (RemoteArchiveData *)client_data;
data->offset = data->offset + request - 1;
return request;
}
/*
* Main loop: open the zipfile, iterate over its contents and decide what
* to do with each entry.
@@ -520,7 +567,14 @@ namespace ZipUtil
return 0;
}
ret = archive_read_open(a, client_data, NULL, ReadRemoteArchive, CloseRemoteArchive);
ret = archive_read_set_seek_callback(a, SeekRemoteArchive);
if (ret < ARCHIVE_OK)
{
sprintf(status_message, "archive_read_set_seek_callback failed - %s", archive_error_string(a));
return 0;
}
ret = archive_read_open2(a, client_data, NULL, ReadRemoteArchive, SkipRemoteArchive, CloseRemoteArchive);
if (ret < ARCHIVE_OK)
{
if (client_data != nullptr)
@@ -592,7 +646,14 @@ namespace ZipUtil
return nullptr;
}
ret = archive_read_open(a, client_data, NULL, ReadRemoteArchive, CloseRemoteArchive);
ret = archive_read_set_seek_callback(a, SeekRemoteArchive);
if (ret < ARCHIVE_OK)
{
sprintf(status_message, "archive_read_set_seek_callback failed - %s", archive_error_string(a));
return 0;
}
ret = archive_read_open2(a, client_data, NULL, ReadRemoteArchive, SkipRemoteArchive, CloseRemoteArchive);
if (ret < ARCHIVE_OK)
{
if (client_data != nullptr)
+3 -2
View File
@@ -1,5 +1,5 @@
#ifndef ZIP_UTIL_H
#define ZIP_UTIL_H
#ifndef EZ_ZIP_UTIL_H
#define EZ_ZIP_UTIL_H
#include <string.h>
#include <stdlib.h>
@@ -30,6 +30,7 @@ enum CompressFileType {
struct RemoteArchiveData
{
void *fp;
std::string path;
ssize_t size;
ssize_t offset;