summaryrefslogtreecommitdiffstats
path: root/src/ninja_jumble.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/ninja_jumble.cc')
-rwxr-xr-x[-rw-r--r--]src/ninja_jumble.cc11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/ninja_jumble.cc b/src/ninja_jumble.cc
index 34fcc6d..c4399d1 100644..100755
--- a/src/ninja_jumble.cc
+++ b/src/ninja_jumble.cc
@@ -42,10 +42,17 @@ int RealDiskInterface::Stat(const string& path) {
}
string DirName(const string& path) {
- string::size_type slash_pos = path.rfind('/');
+
+#ifdef WIN32
+ const char kPathSeparator = '\\';
+#else
+ const char kPathSeparator = '/';
+#endif
+
+ string::size_type slash_pos = path.rfind(kPathSeparator);
if (slash_pos == string::npos)
return ""; // Nothing to do.
- while (slash_pos > 0 && path[slash_pos - 1] == '/')
+ while (slash_pos > 0 && path[slash_pos - 1] == kPathSeparator)
--slash_pos;
return path.substr(0, slash_pos);
}