From 3b20086dc361fa04fbba2d4ac91f89badf583c2f Mon Sep 17 00:00:00 2001 From: John Peterson Date: Sun, 7 Dec 2008 10:51:48 +0000 Subject: [PATCH] Fixed Homebrew again git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1423 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/FileUtil.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/Source/Core/Common/Src/FileUtil.cpp b/Source/Core/Common/Src/FileUtil.cpp index 7fd81d3ae0..a6f7533942 100644 --- a/Source/Core/Common/Src/FileUtil.cpp +++ b/Source/Core/Common/Src/FileUtil.cpp @@ -42,17 +42,28 @@ namespace File { -inline void stripTailDirSlashes(std::string& fname) { - while(fname.at(fname.length() - 1) == DIR_SEP_CHR) - fname.resize(fname.length() - 1); + +// ======================================================= +// Remove any ending forward slashes from directory paths +// ------------- +inline void StripTailDirSlashes(std::string& fname) +{ + // Make sure it's not a blank string + if(fname.length() > 0) + { + while(fname.at(fname.length() - 1) == DIR_SEP_CHR) + fname.resize(fname.length() - 1); + } } +// ============= + bool Exists(const char *filename) { struct stat file_info; std::string copy = filename; - stripTailDirSlashes(copy); + StripTailDirSlashes(copy); int result = stat(copy.c_str(), &file_info); return (result == 0); @@ -62,7 +73,7 @@ bool IsDirectory(const char *filename) { struct stat file_info; std::string copy = filename; - stripTailDirSlashes(copy); + StripTailDirSlashes(copy); int result = stat(copy.c_str(), &file_info); if (result == 0)