aboutsummaryrefslogtreecommitdiff
path: root/src/common/file_util.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2016-04-19 17:40:13 -0400
committerbunnei <bunneidev@gmail.com>2016-04-19 17:40:13 -0400
commitaf0f444b5aa5a0ae596ee5425c1a00164c3d930b (patch)
treea31fc8af3e98e6879ffe374ffb55396787d2aeb3 /src/common/file_util.cpp
parent023e567b3eed08c060e924001ce1123d42179f55 (diff)
parent1656473b42a6f367f9cd366903f79c7cb0efec71 (diff)
Merge pull request #1672 from wwylele/win-driver-fix
Fix driver root identification on Windows
Diffstat (limited to 'src/common/file_util.cpp')
-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 53700c8651..6e28676589 100644
--- a/src/common/file_util.cpp
+++ b/src/common/file_util.cpp
@@ -69,9 +69,10 @@ static void StripTailDirSlashes(std::string &fname)
{
if (fname.length() > 1)
{
- size_t i = fname.length() - 1;
- while (fname[i] == DIR_SEP_CHR)
- fname[i--] = '\0';
+ size_t i = fname.length();
+ while (i > 0 && fname[i - 1] == DIR_SEP_CHR)
+ --i;
+ fname.resize(i);
}
return;
}
@@ -85,6 +86,10 @@ bool Exists(const std::string &filename)
StripTailDirSlashes(copy);
#ifdef _WIN32
+ // Windows needs a slash to identify a driver root
+ if (copy.size() != 0 && copy.back() == ':')
+ copy += DIR_SEP_CHR;
+
int result = _wstat64(Common::UTF8ToUTF16W(copy).c_str(), &file_info);
#else
int result = stat64(copy.c_str(), &file_info);
@@ -102,6 +107,10 @@ bool IsDirectory(const std::string &filename)
StripTailDirSlashes(copy);
#ifdef _WIN32
+ // Windows needs a slash to identify a driver root
+ if (copy.size() != 0 && copy.back() == ':')
+ copy += DIR_SEP_CHR;
+
int result = _wstat64(Common::UTF8ToUTF16W(copy).c_str(), &file_info);
#else
int result = stat64(copy.c_str(), &file_info);