Get rid of remaining uses of stat() on Windows

This commit is contained in:
Henrik Rydgard
2015-09-23 11:34:22 +02:00
parent 51a5adfff2
commit 77e9ea38aa
4 changed files with 101 additions and 55 deletions

View File

@@ -595,25 +595,28 @@ PSPFileInfo VirtualDiscFileSystem::GetFileInfo(std::string filename) {
}
if (x.type != FILETYPE_DIRECTORY) {
#ifdef _WIN32
struct _stat64i32 s;
// TODO: Find a Win32 way to get the atime, ctime etc.
if (_wstat64i32(ConvertUTF8ToWString(fullName).c_str(), &s) != 0) {
ERROR_LOG(FILESYS, "DirectoryFileSystem::GetFileInfo: _wstat64i32 failed: %s", fullName.c_str());
}
#else
struct stat s;
stat(fullName.c_str(), &s);
#endif
File::FileDetails details;
if (!File::GetFileDetails(fullName, &details)) {
ERROR_LOG(FILESYS, "DirectoryFileSystem::GetFileInfo: GetFileDetails failed: %s", fullName.c_str());
x.size = 0;
x.access = 0;
memset(&x.atime, 0, sizeof(x.atime));
memset(&x.ctime, 0, sizeof(x.ctime));
memset(&x.mtime, 0, sizeof(x.mtime));
} else {
x.size = details.size;
x.access = details.access;
time_t atime = details.st_atime;
time_t ctime = details.st_ctime;
time_t mtime = details.st_mtime;
x.size = File::GetFileSize(fullName);
localtime_r((time_t*)&atime, &x.atime);
localtime_r((time_t*)&ctime, &x.ctime);
localtime_r((time_t*)&mtime, &x.mtime);
}
x.startSector = fileList[fileIndex].firstBlock;
x.numSectors = (x.size+2047)/2048;
localtime_r((time_t*)&s.st_atime,&x.atime);
localtime_r((time_t*)&s.st_ctime,&x.ctime);
localtime_r((time_t*)&s.st_mtime,&x.mtime);
}
return x;