diff --git a/inc/files.h b/inc/files.h index a6069df..50e31bb 100644 --- a/inc/files.h +++ b/inc/files.h @@ -25,7 +25,9 @@ enum class FileType : unsigned char { }; typedef std::function fileNameFilter; +typedef std::function fileCallback; template bool scan(const std::string& path, std::insert_iterator it, bool prefixdir = false, fileNameFilter fnf = fileNameFilter(nullptr)); +bool scan(const std::string& path, fileCallback clb, bool prefixdir = false, fileNameFilter fnf = fileNameFilter(nullptr)); } \ No newline at end of file diff --git a/src/Files.cpp b/src/Files.cpp index 9c18f27..06c92f6 100644 --- a/src/Files.cpp +++ b/src/Files.cpp @@ -42,6 +42,15 @@ void mrbesen::Files::extention(const std::string& path, std::string& ext) { template bool mrbesen::Files::scan(const std::string& path, std::insert_iterator it, bool prefixdir, fileNameFilter fnf) { + return scan(path, [&](const std::string& p, FileType t){ it = p; }, prefixdir, fnf); +} + +//curently only these are supported, because iterators may break on others upon insertion +template bool mrbesen::Files::scan>(const std::string&, std::insert_iterator>, bool, fileNameFilter); +template bool mrbesen::Files::scan>(const std::string&, std::insert_iterator>, bool, fileNameFilter); +template bool mrbesen::Files::scan>(const std::string&, std::insert_iterator>, bool, fileNameFilter); + +bool mrbesen::Files::scan(const std::string& path, fileCallback clb, bool prefixdir, fileNameFilter fnf) { std::string path_ = path; mrbesen::Util::insertEnd(path_, "/"); @@ -62,18 +71,10 @@ bool mrbesen::Files::scan(const std::string& path, std::insert_iterator>(const std::string&, std::insert_iterator>, bool, fileNameFilter); -template bool mrbesen::Files::scan>(const std::string&, std::insert_iterator>, bool, fileNameFilter); -template bool mrbesen::Files::scan>(const std::string&, std::insert_iterator>, bool, fileNameFilter); - -