mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Common: Use Path for GetFileSize().
This commit is contained in:
parent
2558022afe
commit
82cd904e99
4 changed files with 9 additions and 9 deletions
|
@ -562,10 +562,10 @@ bool Move(const Path &srcFilename, const Path &destFilename) {
|
|||
|
||||
// Returns the size of file (64bit)
|
||||
// TODO: Add a way to return an error.
|
||||
uint64_t GetFileSize(const std::string &filename) {
|
||||
uint64_t GetFileSize(const Path &filename) {
|
||||
#if defined(_WIN32) && defined(UNICODE)
|
||||
WIN32_FILE_ATTRIBUTE_DATA attr;
|
||||
if (!GetFileAttributesEx(ConvertUTF8ToWString(filename).c_str(), GetFileExInfoStandard, &attr))
|
||||
if (!GetFileAttributesEx(filename.ToWString().c_str(), GetFileExInfoStandard, &attr))
|
||||
return 0;
|
||||
if (attr.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
return 0;
|
||||
|
@ -579,14 +579,14 @@ uint64_t GetFileSize(const std::string &filename) {
|
|||
int result = stat64(filename.c_str(), &file_info);
|
||||
#endif
|
||||
if (result != 0) {
|
||||
WARN_LOG(COMMON, "GetSize: failed %s: No such file", filename.c_str());
|
||||
WARN_LOG(COMMON, "GetSize: failed %s: No such file", filename.ToVisualString().c_str());
|
||||
return 0;
|
||||
}
|
||||
if (S_ISDIR(file_info.st_mode)) {
|
||||
WARN_LOG(COMMON, "GetSize: failed %s: is a directory", filename.c_str());
|
||||
WARN_LOG(COMMON, "GetSize: failed %s: is a directory", filename.ToVisualString().c_str());
|
||||
return 0;
|
||||
}
|
||||
DEBUG_LOG(COMMON, "GetSize: %s: %lld", filename.c_str(), (long long)file_info.st_size);
|
||||
DEBUG_LOG(COMMON, "GetSize: %s: %lld", filename.ToVisualString().c_str(), (long long)file_info.st_size);
|
||||
return file_info.st_size;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ bool IsDirectory(const Path &filename);
|
|||
bool GetModifTime(const Path &filename, tm &return_time);
|
||||
|
||||
// Returns the size of filename (64bit)
|
||||
uint64_t GetFileSize(const std::string &filename);
|
||||
uint64_t GetFileSize(const Path &filename);
|
||||
|
||||
// Overloaded GetSize, accepts FILE*
|
||||
uint64_t GetFileSize(FILE *f);
|
||||
|
|
|
@ -142,7 +142,7 @@ void VirtualDiscFileSystem::LoadFileListIndex() {
|
|||
ERROR_LOG(FILESYS, "Unable to open virtual file: %s", entry.fileName.c_str());
|
||||
}
|
||||
} else {
|
||||
entry.totalSize = File::GetFileSize(GetLocalPath(entry.fileName).ToString());
|
||||
entry.totalSize = File::GetFileSize(GetLocalPath(entry.fileName));
|
||||
}
|
||||
|
||||
// Try to keep currentBlockIndex sane, in case there are other files.
|
||||
|
@ -291,7 +291,7 @@ int VirtualDiscFileSystem::getFileListIndex(std::string &fileName)
|
|||
|
||||
FileListEntry entry = {""};
|
||||
entry.fileName = normalized;
|
||||
entry.totalSize = File::GetFileSize(fullName.ToString());
|
||||
entry.totalSize = File::GetFileSize(fullName);
|
||||
entry.firstBlock = currentBlockIndex;
|
||||
currentBlockIndex += (entry.totalSize+2047)/2048;
|
||||
|
||||
|
|
|
@ -159,7 +159,7 @@ static Path LocalFromRemotePath(const std::string &path) {
|
|||
}
|
||||
|
||||
static void DiscHandler(const http::Request &request, const Path &filename) {
|
||||
s64 sz = File::GetFileSize(filename.ToString());
|
||||
s64 sz = File::GetFileSize(filename);
|
||||
|
||||
std::string range;
|
||||
if (request.Method() == http::RequestHeader::HEAD) {
|
||||
|
|
Loading…
Add table
Reference in a new issue