mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-07 01:23:52 +00:00
fix(wcp): normalize path separators on pack for cross-platform reads
WCP packs created on Windows would store paths with backslashes;
unpack on Linux/macOS would either fail the path-traversal check
('\' treated as absolute prefix) or land each file as a single
opaque filename rather than a directory tree. Normalize to '/' on
write so the format is portable in both directions.
This commit is contained in:
parent
ad65b2ad36
commit
ebb7e0f831
1 changed files with 6 additions and 1 deletions
|
|
@ -4,6 +4,7 @@
|
|||
#include <fstream>
|
||||
#include <filesystem>
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
|
||||
namespace wowee {
|
||||
namespace editor {
|
||||
|
|
@ -26,11 +27,15 @@ bool ContentPacker::packZone(const std::string& outputDir, const std::string& ma
|
|||
return false;
|
||||
}
|
||||
|
||||
// Collect all files
|
||||
// Collect all files. Normalize path separators to '/' so packs created
|
||||
// on Windows are readable on Linux/macOS and vice versa — the unpack
|
||||
// path-traversal check rejects '\' as an absolute prefix, so a Windows
|
||||
// path leaks would silently fail to extract.
|
||||
std::vector<std::pair<std::string, std::string>> files; // relative path, full path
|
||||
for (auto& entry : fs::recursive_directory_iterator(srcDir)) {
|
||||
if (!entry.is_regular_file()) continue;
|
||||
std::string rel = fs::relative(entry.path(), srcDir).string();
|
||||
std::replace(rel.begin(), rel.end(), '\\', '/');
|
||||
files.push_back({rel, entry.path().string()});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue