implement ScanDirectoryTree for POSIX

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1710 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
bushing 2008-12-29 02:11:56 +00:00
parent 5f1f968e21
commit 20e14bebc4
1 changed files with 28 additions and 3 deletions

View File

@ -403,9 +403,34 @@ u32 ScanDirectoryTree(const std::string& _Directory, FSTEntry& parentEntry)
#else #else
u32 ScanDirectoryTree(const std::string& _Directory, FSTEntry& parentEntry) u32 ScanDirectoryTree(const std::string& _Directory, FSTEntry& parentEntry)
{ {
PanicAlert("Scan directory not implemanted yet\n"); u32 foundEntries = 0;
// TODO - Insert linux stuff here
return 0; struct dirent dirent, *result = NULL;
// Find the first file in the directory.
DIR *dirp = opendir(_Directory.c_str());
while (!readdir_r(dirp, &dirent, &result) && result) {
FSTEntry entry;
if (result->d_name[0]=='.') continue;
entry.virtualName = result->d_name;
entry.physicalName = _Directory + "/" + entry.virtualName;
if (IsDirectory(entry.physicalName.c_str())) {
entry.isDirectory = true;
entry.size = ScanDirectoryTree(entry.physicalName, entry);
foundEntries += entry.size;
} else {
entry.isDirectory = false;
entry.size = GetSize(entry.physicalName.c_str());
}
++foundEntries;
parentEntry.children.push_back(entry);
}
closedir(dirp);
return foundEntries;
} }
#endif #endif