diff options
Diffstat (limited to 'src')
| -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 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); |