Skip to content

Commit aa56130

Browse files
committed
bugfix(filesystem): Use native separators in archive listings
1 parent 8803fbc commit aa56130

2 files changed

Lines changed: 6 additions & 9 deletions

File tree

‎Core/GameEngine/Source/Common/System/ArchiveFile.cpp‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "PreRTS.h"
3030

3131
#include "Common/ArchiveFile.h"
32+
#include "Common/FileSystem.h"
3233
#include "Common/ArchiveFileSystem.h"
3334
#include "Common/LocalFileSystem.h"
3435
#include "Common/file.h"
@@ -154,9 +155,7 @@ void ArchiveFile::getFileListInDirectory(const DetailedArchivedDirectoryInfo *di
154155
for (; diriter != dirInfo->m_directories.end(); ++diriter) {
155156
const DetailedArchivedDirectoryInfo *tempDirInfo = &(diriter->second);
156157
AsciiString tempDirName = currentDirectory;
157-
if (!tempDirName.isEmpty() && !tempDirName.endsWith("\\")) {
158-
tempDirName.concat('\\');
159-
}
158+
FileSystem::appendPathSeparator(tempDirName);
160159
tempDirName.concat(tempDirInfo->m_directoryName);
161160
getFileListInDirectory(tempDirInfo, tempDirName, searchName, filenameList, searchSubdirectories);
162161
}
@@ -167,9 +166,7 @@ void ArchiveFile::getFileListInDirectory(const DetailedArchivedDirectoryInfo *di
167166
if (SearchStringMatches(fileInfo.m_filename, searchName)) {
168167
AsciiString tempfilename;
169168
tempfilename = currentDirectory;
170-
if (!tempfilename.isEmpty() && !tempfilename.endsWith("\\")) {
171-
tempfilename.concat('\\');
172-
}
169+
FileSystem::appendPathSeparator(tempfilename);
173170
tempfilename.concat(fileInfo.m_filename);
174171
if (filenameList.find(tempfilename) == filenameList.end()) {
175172
// only insert into the list if its not already in there.

‎Core/GameEngine/Source/GameClient/MapUtil.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -533,11 +533,10 @@ Bool MapCache::loadMapsFromDisk( const AsciiString &mapDir, Bool isOfficial, Boo
533533
const char *szFilenameLower = getLastPathSeparator(filepathLower.str());
534534
if (!szFilenameLower)
535535
{
536-
DEBUG_CRASH(("Couldn't find \\ in map name!"));
536+
DEBUG_CRASH(("Couldn't find path separator in map name!"));
537537
continue;
538538
}
539539

540-
AsciiString endingStr;
541540
AsciiString filenameLower = szFilenameLower+1;
542541
filenameLower.truncateBy(strlen(mapExtension));
543542

@@ -547,7 +546,8 @@ Bool MapCache::loadMapsFromDisk( const AsciiString &mapDir, Bool isOfficial, Boo
547546
continue;
548547
}
549548

550-
endingStr.format("%s\\%s%s", filenameLower.str(), filenameLower.str(), mapExtension);
549+
AsciiString endingStr;
550+
endingStr.format("%s%c%s%s", filenameLower.str(), *szFilenameLower, filenameLower.str(), mapExtension);
551551

552552
if (!filepathLower.endsWithNoCase(endingStr.str()))
553553
{

0 commit comments

Comments
 (0)