diff --git a/lib/filelister_unix.cpp b/lib/filelister_unix.cpp index 4bdcfd730..a761782ec 100644 --- a/lib/filelister_unix.cpp +++ b/lib/filelister_unix.cpp @@ -37,7 +37,10 @@ ////// This code is POSIX-style systems /////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -void FileListerUnix::recursiveAddFiles(std::vector &filenames, const std::string &path) + +void FileListerUnix::recursiveAddFiles2(std::vector &relative, + std::vector &absolute, + const std::string &path) { std::ostringstream oss; oss << path; @@ -59,26 +62,37 @@ void FileListerUnix::recursiveAddFiles(std::vector &filenames, cons if (!fname) continue; - if (std::find(filenames.begin(), filenames.end(), std::string(fname)) != filenames.end()) + // Does absolute path exist? then bail out + if (std::find(absolute.begin(), absolute.end(), std::string(fname)) != absolute.end()) { free(fname); continue; } - if (sameFileName(path,fname) || FileLister::acceptFile(filename)) - filenames.push_back(fname); + if (sameFileName(path,filename) || FileListerUnix::acceptFile(filename)) + { + relative.push_back(filename); + absolute.push_back(fname); + } free(fname); } else { // Directory - getFileLister()->recursiveAddFiles(filenames, filename); + recursiveAddFiles2(relative, absolute, filename); } } globfree(&glob_results); } + +void FileListerUnix::recursiveAddFiles(std::vector &filenames, const std::string &path) +{ + std::vector abs; + recursiveAddFiles2(filenames, abs, path); +} + bool FileListerUnix::sameFileName(const std::string &fname1, const std::string &fname2) { #if defined(__linux__) || defined(__sun) diff --git a/lib/filelister_unix.h b/lib/filelister_unix.h index 73df8e5f6..7effade0a 100644 --- a/lib/filelister_unix.h +++ b/lib/filelister_unix.h @@ -34,7 +34,11 @@ public: virtual bool sameFileName(const std::string &fname1, const std::string &fname2); // virtual static bool acceptFile(const std::string &filename); private: - +#ifndef _WIN32 + void recursiveAddFiles2(std::vector &relative, + std::vector &absolute, + const std::string &path); +#endif }; /// @}