diff options
author | wwylele <wwylele@gmail.com> | 2016-04-15 10:50:50 +0200 |
---|---|---|
committer | wwylele <wwylele@gmail.com> | 2016-04-15 13:50:34 +0200 |
commit | 43b6cbd762aa9158e44484f728aa828f22b7811a (patch) | |
tree | 76344e0e35935cb30e9e63503a5cdd91fa60959d /src/common | |
parent | Merge pull request #1660 from MerryMage/file_util (diff) | |
download | yuzu-43b6cbd762aa9158e44484f728aa828f22b7811a.tar yuzu-43b6cbd762aa9158e44484f728aa828f22b7811a.tar.gz yuzu-43b6cbd762aa9158e44484f728aa828f22b7811a.tar.bz2 yuzu-43b6cbd762aa9158e44484f728aa828f22b7811a.tar.lz yuzu-43b6cbd762aa9158e44484f728aa828f22b7811a.tar.xz yuzu-43b6cbd762aa9158e44484f728aa828f22b7811a.tar.zst yuzu-43b6cbd762aa9158e44484f728aa828f22b7811a.zip |
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/file_util.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index 9ada09f8a..687b7ae5a 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); |