diff options
Diffstat (limited to 'src/common/file_util.cpp')
| -rw-r--r-- | src/common/file_util.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index d8812837e..2d9374783 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp | |||
| @@ -78,13 +78,15 @@ namespace FileUtil { | |||
| 78 | // Remove any ending forward slashes from directory paths | 78 | // Remove any ending forward slashes from directory paths |
| 79 | // Modifies argument. | 79 | // Modifies argument. |
| 80 | static void StripTailDirSlashes(std::string& fname) { | 80 | static void StripTailDirSlashes(std::string& fname) { |
| 81 | if (fname.length() > 1) { | 81 | if (fname.length() <= 1) { |
| 82 | std::size_t i = fname.length(); | 82 | return; |
| 83 | while (i > 0 && fname[i - 1] == DIR_SEP_CHR) | 83 | } |
| 84 | --i; | 84 | |
| 85 | fname.resize(i); | 85 | std::size_t i = fname.length(); |
| 86 | while (i > 0 && fname[i - 1] == DIR_SEP_CHR) { | ||
| 87 | --i; | ||
| 86 | } | 88 | } |
| 87 | return; | 89 | fname.resize(i); |
| 88 | } | 90 | } |
| 89 | 91 | ||
| 90 | bool Exists(const std::string& filename) { | 92 | bool Exists(const std::string& filename) { |