From 682fd9406cc8ee99a263ebc0f69a635c0201a80c Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Thu, 7 Oct 2010 17:18:00 +0000 Subject: [PATCH] Check for both forward and back slashes in the windows version of util::DirName Originally committed to SVN as r4792. --- aegisub/libaegisub/windows/util.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/aegisub/libaegisub/windows/util.cpp b/aegisub/libaegisub/windows/util.cpp index 51bc59264..437518751 100644 --- a/aegisub/libaegisub/windows/util.cpp +++ b/aegisub/libaegisub/windows/util.cpp @@ -39,11 +39,12 @@ namespace agi { using agi::charset::ConvertW; const std::string DirName(const std::string& path) { - if (path.find('/') == std::string::npos) { - return "."; - } + std::string::size_type pos = path.rfind('/'); - return path.substr(0, path.rfind("/")+1); + if (pos == std::string::npos) pos = path.rfind('\\'); + if (pos == std::string::npos) return "."; + + return path.substr(0, pos+1); } void Rename(const std::string& from, const std::string& to) {