diff options
| author | Rozelette <Rozelette@users.noreply.github.com> | 2024-04-12 22:45:25 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-12 23:45:25 -0400 |
| commit | 6cd066f5afd61f2171f57d95b69f1e0f3204588c (patch) | |
| tree | 6e749acdcced33c8d42cc45df7195f1cb9ab237c /ZAPD | |
| parent | 8c88631bf691f0abbab48127cabc55d2a704e022 (diff) | |
Track the files uses to populate each segment (#13)
We can not use the overall list of files because that can have
duplicates in the case of certain include patterns and isn't
necessarily 1-1 with the segments.
Diffstat (limited to 'ZAPD')
| -rw-r--r-- | ZAPD/FileWorker.h | 1 | ||||
| -rw-r--r-- | ZAPD/Globals.cpp | 10 | ||||
| -rw-r--r-- | ZAPD/Globals.h | 1 | ||||
| -rw-r--r-- | ZAPD/Main.cpp | 2 |
4 files changed, 12 insertions, 2 deletions
diff --git a/ZAPD/FileWorker.h b/ZAPD/FileWorker.h index 6ceae80..273e8b8 100644 --- a/ZAPD/FileWorker.h +++ b/ZAPD/FileWorker.h @@ -11,5 +11,6 @@ public: std::vector<ZFile*> files; std::vector<ZFile*> externalFiles; std::vector<int32_t> segments; + std::vector<ZFile*> segmentFiles; std::map<int32_t, std::vector<ZFile*>> segmentRefFiles; };
\ No newline at end of file diff --git a/ZAPD/Globals.cpp b/ZAPD/Globals.cpp index b3eafe0..7838d2f 100644 --- a/ZAPD/Globals.cpp +++ b/ZAPD/Globals.cpp @@ -46,7 +46,10 @@ void Globals::AddSegment(int32_t segment, ZFile* file, int workerID) if (std::find(worker->segments.begin(), worker->segments.end(), segment) == worker->segments.end()) + { worker->segments.push_back(segment); + worker->segmentFiles.push_back(file); + } if (worker->segmentRefFiles.find(segment) == worker->segmentRefFiles.end()) worker->segmentRefFiles[segment] = std::vector<ZFile*>(); @@ -55,7 +58,10 @@ void Globals::AddSegment(int32_t segment, ZFile* file, int workerID) else { if (std::find(segments.begin(), segments.end(), segment) == segments.end()) + { segments.push_back(segment); + segmentFiles.push_back(file); + } if (cfg.segmentRefFiles.find(segment) == cfg.segmentRefFiles.end()) cfg.segmentRefFiles[segment] = std::vector<ZFile*>(); @@ -81,7 +87,7 @@ ZFile* Globals::GetSegment(int32_t segment, int workerID) int idx = std::find(workerData[workerID]->segments.begin(), workerData[workerID]->segments.end(), segment) - workerData[workerID]->segments.begin(); - return workerData[workerID]->files[idx]; + return workerData[workerID]->segmentFiles[idx]; } else return nullptr; @@ -91,7 +97,7 @@ ZFile* Globals::GetSegment(int32_t segment, int workerID) if (HasSegment(segment, workerID)) { int idx = std::find(segments.begin(), segments.end(), segment) - segments.begin(); - return files[idx]; + return segmentFiles[idx]; } else return nullptr; diff --git a/ZAPD/Globals.h b/ZAPD/Globals.h index 95c22c2..b1d9f65 100644 --- a/ZAPD/Globals.h +++ b/ZAPD/Globals.h @@ -48,6 +48,7 @@ public: std::vector<ZFile*> files; std::vector<ZFile*> externalFiles; std::vector<int32_t> segments; + std::vector<ZFile*> segmentFiles; std::map<int, FileWorker*> workerData; diff --git a/ZAPD/Main.cpp b/ZAPD/Main.cpp index 811f499..1bc7599 100644 --- a/ZAPD/Main.cpp +++ b/ZAPD/Main.cpp @@ -271,6 +271,7 @@ int ExtractFunc(int workerID, int fileListSize, std::string fileListItem, ZFileM Globals::Instance->externalFiles.clear(); Globals::Instance->segments.clear(); + Globals::Instance->segmentFiles.clear(); Globals::Instance->cfg.segmentRefFiles.clear(); } else @@ -286,6 +287,7 @@ int ExtractFunc(int workerID, int fileListSize, std::string fileListItem, ZFileM Globals::Instance->workerData[workerID]->externalFiles.clear(); Globals::Instance->workerData[workerID]->segments.clear(); + Globals::Instance->workerData[workerID]->segmentFiles.clear(); Globals::Instance->workerData[workerID]->segmentRefFiles.clear(); numWorkersLeft--; |
