summaryrefslogtreecommitdiff
path: root/src/common/file_util.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2016-04-19 17:40:13 -0400
committerGravatar bunnei2016-04-19 17:40:13 -0400
commit6d29c202089e154186e796fd8fe85dae1ea26a1b (patch)
treea31fc8af3e98e6879ffe374ffb55396787d2aeb3 /src/common/file_util.cpp
parentMerge pull request #1612 from ObsidianX/get-set-sockopt (diff)
parentfix driver root identification on Windows (diff)
downloadyuzu-6d29c202089e154186e796fd8fe85dae1ea26a1b.tar.gz
yuzu-6d29c202089e154186e796fd8fe85dae1ea26a1b.tar.xz
yuzu-6d29c202089e154186e796fd8fe85dae1ea26a1b.zip
Merge pull request #1672 from wwylele/win-driver-fix
Fix driver root identification on Windows
Diffstat (limited to '')
-rw-r--r--src/common/file_util.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp
index 53700c865..6e2867658 100644
--- a/src/common/file_util.cpp
+++ b/src/common/file_util.cpp
@@ -69,9 +69,10 @@ static void StripTailDirSlashes(std::string &fname)
69{ 69{
70 if (fname.length() > 1) 70 if (fname.length() > 1)
71 { 71 {
72 size_t i = fname.length() - 1; 72 size_t i = fname.length();
73 while (fname[i] == DIR_SEP_CHR) 73 while (i > 0 && fname[i - 1] == DIR_SEP_CHR)
74 fname[i--] = '\0'; 74 --i;
75 fname.resize(i);
75 } 76 }
76 return; 77 return;
77} 78}
@@ -85,6 +86,10 @@ bool Exists(const std::string &filename)
85 StripTailDirSlashes(copy); 86 StripTailDirSlashes(copy);
86 87
87#ifdef _WIN32 88#ifdef _WIN32
89 // Windows needs a slash to identify a driver root
90 if (copy.size() != 0 && copy.back() == ':')
91 copy += DIR_SEP_CHR;
92
88 int result = _wstat64(Common::UTF8ToUTF16W(copy).c_str(), &file_info); 93 int result = _wstat64(Common::UTF8ToUTF16W(copy).c_str(), &file_info);
89#else 94#else
90 int result = stat64(copy.c_str(), &file_info); 95 int result = stat64(copy.c_str(), &file_info);
@@ -102,6 +107,10 @@ bool IsDirectory(const std::string &filename)
102 StripTailDirSlashes(copy); 107 StripTailDirSlashes(copy);
103 108
104#ifdef _WIN32 109#ifdef _WIN32
110 // Windows needs a slash to identify a driver root
111 if (copy.size() != 0 && copy.back() == ':')
112 copy += DIR_SEP_CHR;
113
105 int result = _wstat64(Common::UTF8ToUTF16W(copy).c_str(), &file_info); 114 int result = _wstat64(Common::UTF8ToUTF16W(copy).c_str(), &file_info);
106#else 115#else
107 int result = stat64(copy.c_str(), &file_info); 116 int result = stat64(copy.c_str(), &file_info);