FileLister: Fix bug that prevent a file passed by with paths to be checked; Add the possibility to use \ as a directory separator on Windows closing issue #22

This commit is contained in:
Nicolas Le Cam 2009-01-18 23:51:31 +00:00
parent 3cb51d6946
commit 45478a7178
1 changed files with 13 additions and 5 deletions

View File

@ -156,19 +156,27 @@ void FileLister::RecursiveAddFiles(std::vector<std::string> &filenames, const st
void FileLister::RecursiveAddFiles(std::vector<std::string> &filenames, const std::string &path, bool recursive)
{
std::ostringstream bdir, oss;
oss << path;
if (path.length() > 0)
std::string cleanedPath = path;
std::replace(cleanedPath.begin(), cleanedPath.end(), '\\', '/');
oss << cleanedPath;
if (cleanedPath.length() > 0)
{
// Windows doesn't recognize "." as current folder by default
if (path == ".")
if (cleanedPath == ".")
{
oss << "/*";
}
else if (path[path.length() - 1] == '/')
else if (cleanedPath[cleanedPath.length() - 1] == '/')
{
bdir << path;
bdir << cleanedPath;
oss << "*";
}
else
{
bdir << cleanedPath.substr(0, cleanedPath.rfind('/') + 1);
}
}
WIN32_FIND_DATA ffd;