diff --git a/Common/CommonPaths.h b/Common/CommonPaths.h index cdc0304d7f..0fdf5f887c 100644 --- a/Common/CommonPaths.h +++ b/Common/CommonPaths.h @@ -23,7 +23,11 @@ // Directory seperators, do we need this? #define DIR_SEP "/" -#define DIR_SEP_CHR '/' +#ifdef _WIN32 + #define DIR_SEP_CHRS "/\\" +#else + #define DIR_SEP_CHRS "/" +#endif // The user data dir #define ROOT_DIR "." diff --git a/Common/FileSearch.cpp b/Common/FileSearch.cpp index bf816a0529..b5075c3ad2 100644 --- a/Common/FileSearch.cpp +++ b/Common/FileSearch.cpp @@ -102,7 +102,7 @@ void CFileSearch::FindFiles(const std::string& _searchString, const std::string& ((s.size() > ext.size()) && (!strcasecmp(s.substr(s.size() - ext.size()).c_str(), ext.c_str())) )) { std::string full_name; - if (_strPath.c_str()[_strPath.size()-1] == DIR_SEP_CHR) + if (strchr(DIR_SEP_CHRS, _strPath.c_str()[_strPath.size()-1])) full_name = _strPath + s; else full_name = _strPath + DIR_SEP + s; diff --git a/Common/FileUtil.cpp b/Common/FileUtil.cpp index e17b6f4bfb..f1d7a74b7b 100644 --- a/Common/FileUtil.cpp +++ b/Common/FileUtil.cpp @@ -66,7 +66,7 @@ static void StripTailDirSlashes(std::string &fname) if (fname.length() > 1) { size_t i = fname.length() - 1; - while (fname[i] == DIR_SEP_CHR) + while (strchr(DIR_SEP_CHRS, fname[i])) fname[i--] = '\0'; } return; @@ -188,10 +188,16 @@ bool CreateFullPath(const std::string &fullPath) } size_t position = 0; + +#ifdef _WIN32 + // Skip the drive letter, no need to create C:\. + position = 3; +#endif + while (true) { // Find next sub path - position = fullPath.find(DIR_SEP_CHR, position); + position = fullPath.find_first_of(DIR_SEP_CHRS, position); // we're done, yay! if (position == fullPath.npos) @@ -507,7 +513,7 @@ bool DeleteDirRecursively(const std::string &directory) (virtualName[2] == '\0'))) continue; - std::string newPath = directory + DIR_SEP_CHR + virtualName; + std::string newPath = directory + DIR_SEP + virtualName; if (IsDirectory(newPath)) { if (!DeleteDirRecursively(newPath)) diff --git a/Common/StringUtil.cpp b/Common/StringUtil.cpp index d42933acfd..ffa9434ef1 100644 --- a/Common/StringUtil.cpp +++ b/Common/StringUtil.cpp @@ -211,8 +211,8 @@ void BuildCompleteFilename(std::string& _CompleteFilename, const std::string& _P _CompleteFilename = _Path; // check for seperator - if (DIR_SEP_CHR != *_CompleteFilename.rbegin()) - _CompleteFilename += DIR_SEP_CHR; + if (!strchr(DIR_SEP_CHRS, *_CompleteFilename.rbegin())) + _CompleteFilename += DIR_SEP; // add the filename _CompleteFilename += _Filename;