summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalkierian <malkierian@live.com>2025-12-03 09:21:39 -0700
committerGitHub <noreply@github.com>2025-12-03 16:21:39 +0000
commit2be9bcbf5ca7d47749eb67e079113ec94450b25e (patch)
treee2da191a737b6a0981759f6a3f6e9fbfa1bb7824
parentf64c54f6bc0243ee724897075c615048cc1c1c7d (diff)
External Progress Reporting (#33)
-rw-r--r--ZAPD/ExecutableMain.cpp5
-rw-r--r--ZAPD/Main.cpp18
2 files changed, 18 insertions, 5 deletions
diff --git a/ZAPD/ExecutableMain.cpp b/ZAPD/ExecutableMain.cpp
index 303ea24..1bb0192 100644
--- a/ZAPD/ExecutableMain.cpp
+++ b/ZAPD/ExecutableMain.cpp
@@ -1,5 +1,8 @@
+#include <stdio.h>
+
extern "C" int zapd_main(int argc, char* argv[]);
+extern "C" int zapd_report(int argc, char* argv[], size_t* extractCount, size_t* totalExtract);
int main(int argc, char* argv[]) {
- return zapd_main(argc, argv);
+ return zapd_report(argc, argv, nullptr, nullptr);
}
diff --git a/ZAPD/Main.cpp b/ZAPD/Main.cpp
index 4598da9..d2d8feb 100644
--- a/ZAPD/Main.cpp
+++ b/ZAPD/Main.cpp
@@ -132,7 +132,7 @@ void BuildAssetTexture(const fs::path& pngFilePath, TextureType texType, const f
void BuildAssetBackground(const fs::path& imageFilePath, const fs::path& outPath);
void BuildAssetBlob(const fs::path& blobFilePath, const fs::path& outPath);
ZFileMode ParseFileMode(const std::string& buildMode, ExporterSet* exporterSet);
-int HandleExtract(ZFileMode fileMode, ExporterSet* exporterSet);
+int HandleExtract(ZFileMode fileMode, ExporterSet* exporterSet, size_t* extractCount = nullptr, size_t* totalExtract = nullptr);
int ExtractFunc(int workerID, int fileListSize, std::string fileListItem, ZFileMode fileMode);
std::atomic<unsigned int> numWorkersLeft = 0;
@@ -141,7 +141,7 @@ extern const char gBuildHash[];
extern void ImportExporters();
-extern "C" int zapd_main(int argc, char* argv[])
+extern "C" int zapd_report(int argc, char* argv[], size_t* extractCount, size_t* totalExtract)
{
int returnCode = 0;
@@ -217,7 +217,7 @@ extern "C" int zapd_main(int argc, char* argv[])
WarningHandler::PrintWarningsDebugInfo();
if (fileMode == ZFileMode::Extract || fileMode == ZFileMode::BuildSourceFile || fileMode == ZFileMode::ExtractDirectory)
- returnCode = HandleExtract(fileMode, exporterSet);
+ returnCode = HandleExtract(fileMode, exporterSet, extractCount, totalExtract);
else if (fileMode == ZFileMode::BuildTexture)
BuildAssetTexture(Globals::Instance->inputPath, Globals::Instance->texType,
Globals::Instance->outputPath);
@@ -233,6 +233,10 @@ extern "C" int zapd_main(int argc, char* argv[])
return returnCode;
}
+extern "C" int zapd_main(int argc, char* argv[]) {
+ return zapd_report(argc, argv, nullptr, nullptr);
+}
+
int ExtractFunc(int workerID, int fileListSize, std::string fileListItem, ZFileMode fileMode)
{
bool parseSuccessful;
@@ -635,7 +639,7 @@ void Arg_SetXMLMode(int& i, char* argv[])
}
}
-int HandleExtract(ZFileMode fileMode, ExporterSet* exporterSet)
+int HandleExtract(ZFileMode fileMode, ExporterSet* exporterSet, size_t* extractCount, size_t* totalExtract)
{
bool procFileModeSuccess = false;
@@ -666,12 +670,18 @@ int HandleExtract(ZFileMode fileMode, ExporterSet* exporterSet)
Globals::Instance->workerData[i] = new FileWorker();
numWorkersLeft = fileListSize;
+ if (totalExtract != nullptr) {
+ *totalExtract = fileListSize;
+ }
for (size_t i = 0; i < fileListSize; i++)
{
if (Globals::Instance->singleThreaded)
{
ExtractFunc(i, fileList.size(), fileList[i], fileMode);
+ if (extractCount != nullptr) {
+ *extractCount = i;
+ }
}
else
{