Files
SimpleRemoter/common/file_upload.h
2025-11-08 18:00:21 +01:00

34 lines
1.2 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
#include <string>
#include <vector>
#pragma pack(push, 1)
struct FileChunkPacket {
unsigned char cmd; // COMMAND_SEND_FILE
uint32_t fileIndex; // 文件编号
uint32_t totalNum; // 文件总数
uint64_t fileSize; // 整个文件大小
uint64_t offset; // 当前块在文件中的偏移
uint64_t dataLength; // 本块数据长度
uint64_t nameLength; // 文件名长度(不含 '\0'
};
#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);
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);
int RecvFileChunk(char* buf, size_t len, void* user, OnFinish f, const std::string& hash, const std::string& hmac);