Handle both \ and / on Windows paths.

This commit is contained in:
Unknown W. Brackets committed 2012-12-10 22:55:56 -08:00
1 parent c3643077f8
commit 3ae4acc7d6
4 files changed
+17 -7

No files matched your search

+5 -1
View File
@@ -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 "."
+1 -1
View File
@@ -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;
+9 -3
View File
@@ -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))
+2 -2
View File
@@ -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;