summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Src/FileUtil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core/Common/Src/FileUtil.cpp')
-rw-r--r--Source/Core/Common/Src/FileUtil.cpp28
1 files changed, 23 insertions, 5 deletions
diff --git a/Source/Core/Common/Src/FileUtil.cpp b/Source/Core/Common/Src/FileUtil.cpp
index 742ec097ee..bc141a5517 100644
--- a/Source/Core/Common/Src/FileUtil.cpp
+++ b/Source/Core/Common/Src/FileUtil.cpp
@@ -48,6 +48,10 @@ bool Exists(const char *filename)
bool IsDirectory(const char *filename)
{
#ifdef _WIN32
+ DWORD Attribs = GetFileAttributes(filename);
+ if (Attribs == INVALID_FILE_ATTRIBUTES)
+ return false;
+
return (GetFileAttributes(filename) & FILE_ATTRIBUTE_DIRECTORY) != 0;
#else
struct stat file_info;
@@ -163,11 +167,15 @@ std::string GetUserDirectory()
u64 GetSize(const char *filename)
{
- FILE *f = fopen(filename, "rb");
- fseek(f, 0, SEEK_END);
- u64 pos = ftell(f);
- fclose(f);
- return pos;
+ FILE *pFile = fopen(filename, "rb");
+ if (pFile)
+ {
+ fseek(pFile, 0, SEEK_END);
+ u64 pos = ftell(pFile);
+ fclose(pFile);
+ return pos;
+ }
+ return 0;
}
#ifdef _WIN32
@@ -236,4 +244,14 @@ u32 ScanDirectoryTree(const std::string& _Directory, FSTEntry& parentEntry)
}
#endif
+bool CreateEmptyFile(const char *filename)
+{
+ FILE* pFile = fopen(filename, "wb");
+ if (pFile == NULL)
+ return false;
+
+ fclose(pFile);
+ return true;
+}
+
} // namespace