From 45478a717811fd9c94dcffa32a8b2741b909d6b2 Mon Sep 17 00:00:00 2001 From: Nicolas Le Cam Date: Sun, 18 Jan 2009 23:51:31 +0000 Subject: [PATCH] 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 --- src/filelister.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/filelister.cpp b/src/filelister.cpp index 7038670bb..1df1d9be4 100644 --- a/src/filelister.cpp +++ b/src/filelister.cpp @@ -156,19 +156,27 @@ void FileLister::RecursiveAddFiles(std::vector &filenames, const st void FileLister::RecursiveAddFiles(std::vector &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;