Merge pull request 'Do not prefix filenames with slash if in archive directory is empty' (#200) from misc2 into master

Reviewed-on: https://git.madvoxel.net/OpenVulkano/OpenVulkano/pulls/200
Reviewed-by: Georg Hagen <georg.hagen@madvoxel.com>
This commit is contained in:
Oleksii_Hyzha
2025-02-18 12:11:29 +01:00

View File

@@ -80,15 +80,19 @@ namespace OpenVulkano
bool AddFiles(const std::filesystem::path& dirName, const std::string& inArchiveDirName) bool AddFiles(const std::filesystem::path& dirName, const std::string& inArchiveDirName)
{ {
std::string sDirName = dirName.string(); const std::string sDirName = dirName.string();
const std::string prefix = inArchiveDirName.empty() ? "" : inArchiveDirName + "/";
if (!inArchiveDirName.empty())
{
AddFile(sDirName.c_str(), inArchiveDirName.c_str()); AddFile(sDirName.c_str(), inArchiveDirName.c_str());
}
for(const auto& entry : std::filesystem::directory_iterator(dirName)) for(const auto& entry : std::filesystem::directory_iterator(dirName))
{ {
std::string fPath = inArchiveDirName + "/" + entry.path().filename().string(); const std::string fPath = prefix + entry.path().filename().string();
if (entry.is_directory()) AddFiles(entry, fPath); if (entry.is_directory()) AddFiles(entry, fPath);
else else
{ {
std::string entryName = entry.path().string(); const std::string entryName = entry.path().string();
AddFile(entryName.c_str(), fPath.c_str()); AddFile(entryName.c_str(), fPath.c_str());
} }
} }