summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Src/FileUtil.cpp
diff options
context:
space:
mode:
authorJohn Peterson <jpeterson57@gmail.com>2008-12-07 10:51:48 +0000
committerJohn Peterson <jpeterson57@gmail.com>2008-12-07 10:51:48 +0000
commit3b20086dc361fa04fbba2d4ac91f89badf583c2f (patch)
treee7cb36d15dcc8f67ab925efb8ba11005221c615e /Source/Core/Common/Src/FileUtil.cpp
parent9d9c2fc983a7e54ea659c99a8ada1542f7fba0cf (diff)
Fixed Homebrew again
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1423 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/Common/Src/FileUtil.cpp')
-rw-r--r--Source/Core/Common/Src/FileUtil.cpp21
1 files 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)