diff --git a/common/common.cpp b/common/common.cpp index 76365c5c0..d286b963e 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -49,7 +49,6 @@ #include #include #else -#include #include #include #include @@ -855,43 +854,6 @@ bool fs_create_directory_with_parents(const std::string & path) { #endif // _WIN32 } - -std::vector fs_list_files(const std::string & folder, const std::string & ext) { - std::vector files; - // Note: once we can use C++17 this becomes: - // for (const auto & entry : std::filesystem::directory_iterator(folder)) - // if (entry.path().extension() == ext) files.push_back(entry.path().string()); -#ifdef _WIN32 - std::string search_path = folder + "\\*" + ext; - WIN32_FIND_DATA fd; - HANDLE hFind = ::FindFirstFile(search_path.c_str(), &fd); - if (hFind != INVALID_HANDLE_VALUE) { - do { - if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { - files.push_back(folder + "\\" + fd.cFileName); - } - } while (::FindNextFile(hFind, &fd)); - ::FindClose(hFind); - } -#else - DIR* dir = opendir(folder.c_str()); - if (dir != nullptr) { - struct dirent* entry; - while ((entry = readdir(dir)) != nullptr) { - if (entry->d_type == DT_REG) { // If it's a regular file - std::string filename = entry->d_name; - if (filename.length() >= ext.length() && - filename.compare(filename.length() - ext.length(), ext.length(), ext) == 0) { - files.push_back(folder + "/" + filename); - } - } - } - closedir(dir); - } -#endif - return files; -} - std::string fs_get_cache_directory() { std::string cache_directory = ""; auto ensure_trailing_slash = [](std::string p) { diff --git a/common/common.h b/common/common.h index e33ba8a90..830a56fa7 100644 --- a/common/common.h +++ b/common/common.h @@ -492,7 +492,6 @@ std::string string_from(const struct llama_context * ctx, const struct llama_bat bool fs_validate_filename(const std::string & filename); bool fs_create_directory_with_parents(const std::string & path); -std::vector fs_list_files(const std::string & path, const std::string & ext); std::string fs_get_cache_directory(); std::string fs_get_cache_file(const std::string & filename);