2025-10-25 16:13:18 +08:00
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
|
|
#pragma pack(push, 1)
|
2025-11-09 00:49:34 +08:00
|
|
|
|
struct FileChunkPacket {
|
|
|
|
|
|
unsigned char cmd; // COMMAND_SEND_FILE
|
|
|
|
|
|
uint32_t fileIndex; // <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
uint32_t totalNum; // <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
uint64_t fileSize; // <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>С
|
|
|
|
|
|
uint64_t offset; // <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>е<EFBFBD>ƫ<EFBFBD><C6AB>
|
|
|
|
|
|
uint64_t dataLength; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
|
|
|
|
|
uint64_t nameLength; // <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȣ<EFBFBD><C8A3><EFBFBD><EFBFBD><EFBFBD> '\0'<27><>
|
2025-10-25 16:13:18 +08:00
|
|
|
|
};
|
|
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
|
|
|
|
int InitFileUpload(const std::string hmac, int chunkSizeKb = 64, int sendDurationMs = 50);
|
|
|
|
|
|
|
|
|
|
|
|
int UninitFileUpload();
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<std::string> GetClipboardFiles();
|
|
|
|
|
|
|
|
|
|
|
|
bool GetCurrentFolderPath(std::string& outDir);
|
|
|
|
|
|
|
|
|
|
|
|
typedef bool (*OnTransform)(void* user, FileChunkPacket* chunk, unsigned char* data, int size);
|
|
|
|
|
|
|
|
|
|
|
|
typedef void (*OnFinish)(void* user);
|
|
|
|
|
|
|
2025-11-09 00:49:34 +08:00
|
|
|
|
int FileBatchTransferWorker(const std::vector<std::string>& files, const std::string& targetDir,
|
|
|
|
|
|
void* user, OnTransform f, OnFinish finish, const std::string& hash, const std::string& hmac);
|
2025-10-25 16:13:18 +08:00
|
|
|
|
|
|
|
|
|
|
int RecvFileChunk(char* buf, size_t len, void* user, OnFinish f, const std::string& hash, const std::string& hmac);
|