Permalink
Browse files

Merge pull request #11297 from unknownbrackets/fs-root

Io: Prevent cur/parent dir in listing of root
  • Loading branch information...
hrydgard committed Aug 13, 2018
2 parents 7aa71fc + 7a05818 commit a495537164607593d9c7fc385c8797ec7081b8ea
Showing with 7 additions and 3 deletions.
  1. +7 −3 Core/FileSystems/DirectoryFileSystem.cpp
@@ -825,6 +825,8 @@ static std::string SimulateVFATBug(std::string filename) {
std::vector<PSPFileInfo> DirectoryFileSystem::GetDirListing(std::string path) {
std::vector<PSPFileInfo> myVector;
bool listingRoot = path == "/" || path == "\\";
#ifdef _WIN32
WIN32_FIND_DATA findData;
HANDLE hFind;
@@ -849,15 +851,16 @@ std::vector<PSPFileInfo> DirectoryFileSystem::GetDirListing(std::string path) {
entry.access = entry.type == FILETYPE_NORMAL ? 0666 : 0777;
// TODO: is this just for .. or all subdirectories? Need to add a directory to the test
// to find out. Also why so different than the old test results?
if (!wcscmp(findData.cFileName, L"..") )
if (!wcscmp(findData.cFileName, L".."))
entry.size = 4096;
else
entry.size = findData.nFileSizeLow | ((u64)findData.nFileSizeHigh<<32);
entry.name = SimulateVFATBug(ConvertWStringToUTF8(findData.cFileName));
tmFromFiletime(entry.atime, findData.ftLastAccessTime);
tmFromFiletime(entry.ctime, findData.ftCreationTime);
tmFromFiletime(entry.mtime, findData.ftLastWriteTime);
myVector.push_back(entry);
if (!listingRoot || (wcscmp(findData.cFileName, L"..") && wcscmp(findData.cFileName, L".")))
myVector.push_back(entry);
int retval = FindNextFile(hFind, &findData);
if (!retval)
@@ -897,7 +900,8 @@ std::vector<PSPFileInfo> DirectoryFileSystem::GetDirListing(std::string path) {
localtime_r((time_t*)&s.st_atime,&entry.atime);
localtime_r((time_t*)&s.st_ctime,&entry.ctime);
localtime_r((time_t*)&s.st_mtime,&entry.mtime);
myVector.push_back(entry);
if (!listingRoot || (wcscmp(findData.cFileName, L"..") && wcscmp(findData.cFileName, L".")))
myVector.push_back(entry);
}
closedir(dp);
#endif

0 comments on commit a495537

Please sign in to comment.