Fix deletePathFromFilename returning cutoff filenames (#15211)

This commit is contained in:
swagtoy 2024-09-30 16:41:53 -04:00 committed by GitHub
parent bca44574d5
commit c6fc694ea6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 9 deletions

@ -63,7 +63,7 @@ inline io::path &getFileNameExtension(io::path &dest, const io::path &source)
} }
//! delete path from filename //! delete path from filename
inline io::path &deletePathFromFilename(io::path &filename) inline io::path deletePathFromFilename(const io::path &filename)
{ {
// delete path from filename // delete path from filename
const fschar_t *s = filename.c_str(); const fschar_t *s = filename.c_str();
@ -73,11 +73,10 @@ inline io::path &deletePathFromFilename(io::path &filename)
while (*p != '/' && *p != '\\' && p != s) while (*p != '/' && *p != '\\' && p != s)
p--; p--;
if (p != s) { if (p != s)
++p; ++p;
filename = p;
} return p;
return filename;
} }
//! trim paths //! trim paths

@ -80,7 +80,7 @@ u32 CFileList::addItem(const io::path &fullPath, u32 offset, u32 size, bool isDi
entry.FullName = entry.Name; entry.FullName = entry.Name;
core::deletePathFromFilename(entry.Name); entry.Name = core::deletePathFromFilename(entry.Name);
if (IgnorePaths) if (IgnorePaths)
entry.FullName = entry.Name; entry.FullName = entry.Name;
@ -140,7 +140,7 @@ s32 CFileList::findFile(const io::path &filename, bool isDirectory = false) cons
entry.FullName.make_lower(); entry.FullName.make_lower();
if (IgnorePaths) if (IgnorePaths)
core::deletePathFromFilename(entry.FullName); entry.FullName = core::deletePathFromFilename(entry.FullName);
return Files.binary_search(entry); return Files.binary_search(entry);
} }

@ -191,8 +191,7 @@ bool CZipReader::scanGZipHeader()
} }
} else { } else {
// no file name? // no file name?
ZipFileName = Path; ZipFileName = core::deletePathFromFilename(Path);
core::deletePathFromFilename(ZipFileName);
// rename tgz to tar or remove gz extension // rename tgz to tar or remove gz extension
if (core::hasFileExtension(ZipFileName, "tgz")) { if (core::hasFileExtension(ZipFileName, "tgz")) {