int EbrStat64i32(const char* filename, struct _stat64i32* ret) { CPathMapper map(filename); if (!map) { TraceError(TAG, L"EbrStat failure!"); return -1; } if (_EbrIsDir(map)) { memset(ret, 0, sizeof(struct _stat64i32)); ret->st_size = 0; ret->st_mode = 0x1B6 | 0040000; return 0; } return _wstat64i32(map, ret); }
PSPFileInfo DirectoryFileSystem::GetFileInfo(std::string filename) { PSPFileInfo x; x.name = filename; std::string fullName = GetLocalPath(filename); if (! File::Exists(fullName)) { #if HOST_IS_CASE_SENSITIVE if (! FixPathCase(basePath,filename, FPC_FILE_MUST_EXIST)) return x; fullName = GetLocalPath(filename); if (! File::Exists(fullName)) return x; #else return x; #endif } x.type = File::IsDirectory(fullName) ? FILETYPE_DIRECTORY : FILETYPE_NORMAL; x.exists = true; if (x.type != FILETYPE_DIRECTORY) { #ifdef _WIN32_NO_MINGW struct _stat64i32 s; _wstat64i32(ConvertUTF8ToWString(fullName).c_str(), &s); #else struct stat s; stat(fullName.c_str(), &s); #endif x.size = File::GetSize(fullName); x.access = s.st_mode & 0x1FF; 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; }
static inline int CS_stat (const char* path, struct stat* buf) { #if defined (__CYGWIN32__) return stat(path, buf); #elif defined(CS_COMPILER_MSVC) size_t pathLen (strlen (path)); size_t pathWlen (pathLen + 1); CS_ALLOC_STACK_ARRAY(wchar_t, pathW, pathWlen); csUnicodeTransform::UTF8toWC (pathW, pathWlen, (utf8_char*)path, pathLen); /* Note: the cast works as struct stat and struct _stat64i32 effectively have the same layout */ return _wstat64i32 (pathW, reinterpret_cast<struct _stat64i32*> (buf)); #else size_t pathLen (strlen (path)); size_t pathWlen (pathLen + 1); CS_ALLOC_STACK_ARRAY(wchar_t, pathW, pathWlen); csUnicodeTransform::UTF8toWC (pathW, pathWlen, (utf8_char*)path, pathLen); /* Note: the cast works as struct stat and struct _stat64i32 effectively have the same layout */ return _wstat (pathW, reinterpret_cast<struct _stat*> (buf)); #endif }