累计更新:

cos上传
补丁压缩
This commit is contained in:
2025-12-06 16:29:26 +08:00
parent 5a2211d217
commit b78ee53326
11 changed files with 483 additions and 49 deletions
+33 -8
View File
@@ -60,7 +60,8 @@ static void printUsage(const char* moduleName)
printf(" MakeDiff\tCreates a binary diff patch file between two input files using BSDIFF43.\n");
printf(" ApplyPatch\tApplies a BSDIFF43 binary patch to an input file and writes the patched result to an output file.\n");
printf(" HashFile\tCalculates the hash(MD5|SHA256) of the contents of a specified file.\n");
printf(" HttpDownload\tDownloads a file from a specified URL and saves it to a local file.\n");
printf(" Download\tDownloads a file from a specified URL and saves it to a local file.\n");
printf(" Upload\tUpload a local file to a specified cos server.\n");
printf(" RunLuaFile\t xxxx \n");
printf("\nSample:\n");
printf(" -m GenRandFile -min 500 -max 1k -o rand.bin\n");
@@ -71,7 +72,8 @@ static void printUsage(const char* moduleName)
printf(" -m ApplyPatch -i ver01.bin -i2 patch_ver01_ver02.diff -o ver02.bin\n");
printf(" -m HashFile -t md5 -i ver01.bin\n");
printf(" -m HashFile -t sha256 -i ver01.bin\n");
printf(" -m HttpDownload -i http://download.com/file.txt -o file.txt\n");
printf(" -m Download -i http://download.com/file.txt -o file.txt\n");
printf(" -m Upload -i file.txt -o cos:\\path\file.txt \n");
printf(" -m RunLuaFile -i script.lua\n");
}
@@ -85,7 +87,8 @@ enum WorkMode {
WM_MAKE_DIFF,
WM_APPLY_PATCH,
WM_HASH_FILE,
WM_HTTP_DOWNLOAD,
WM_DOWNLOAD,
WM_UPLOAD,
WM_RUN_LUA_FILE,
};
@@ -124,8 +127,11 @@ WorkMode parserWorkMode(const char* modeStr)
else if (_stricmp(modeStr, "HashFile") == 0) {
return WM_HASH_FILE;
}
else if (_stricmp(modeStr, "HttpDownload") == 0) {
return WM_HTTP_DOWNLOAD;
else if (_stricmp(modeStr, "Download") == 0) {
return WM_DOWNLOAD;
}
else if (_stricmp(modeStr, "Upload") == 0) {
return WM_UPLOAD;
}
else if (_stricmp(modeStr, "RunLuaFile") == 0) {
return WM_RUN_LUA_FILE;
@@ -151,6 +157,8 @@ HashType parserHashType(const char* typeStr)
return HT_NONE; // default to HT_NONE
}
const int kDiffCompressMethod = 2;
int main(int argc, char* argv[])
{
CSimpleOptA args(argc, argv, g_rgOptions);
@@ -336,7 +344,7 @@ int main(int argc, char* argv[])
return 1;
}
printf("Creating diff between %s and %s, output: %s\n", inputFilename, inputFilename2, outputFilename);
if (!createDiff(inputFilename, inputFilename2, outputFilename))
if (!createDiff(inputFilename, inputFilename2, outputFilename, kDiffCompressMethod))
{
printf("Error: Failed to create diff file.\n");
return 1;
@@ -353,14 +361,14 @@ int main(int argc, char* argv[])
return 1;
}
printf("Applying patch from %s with patch %s, output: %s\n", inputFilename, inputFilename2, outputFilename);
if (!applyPatch(inputFilename, inputFilename2, outputFilename))
if (!applyPatch(inputFilename, inputFilename2, outputFilename, kDiffCompressMethod))
{
printf("Error: Failed to apply patch.\n");
return 1;
}
}
break;
case WM_HTTP_DOWNLOAD:
case WM_DOWNLOAD:
{
if (inputFilename == nullptr || outputFilename == nullptr)
{
@@ -377,6 +385,23 @@ int main(int argc, char* argv[])
}
break;
case WM_UPLOAD:
{
if (inputFilename == nullptr || outputFilename == nullptr)
{
printf("Error: For 'upload' mode, you must specify input local file and output cos path.\n");
printUsage(::PathFindFileNameA(argv[0]));
return 1;
}
printf("Uploading from %s to %s\n", inputFilename, outputFilename);
if(!uploadFile(inputFilename, outputFilename))
{
printf("Error: Failed to upload file.\n");
return 1;
}
}
break;
case WM_RUN_LUA_FILE:
{
if (inputFilename == nullptr)