drop unused fs_list_files

This commit is contained in:
Olivier Chafik 2025-01-22 02:22:03 +00:00
parent 9e8b43f993
commit 03fe80f1bb
2 changed files with 0 additions and 39 deletions

View file

@ -49,7 +49,6 @@
#include <fcntl.h>
#include <io.h>
#else
#include <dirent.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <unistd.h>
@ -855,43 +854,6 @@ bool fs_create_directory_with_parents(const std::string & path) {
#endif // _WIN32
}
std::vector<std::string> fs_list_files(const std::string & folder, const std::string & ext) {
std::vector<std::string> 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) {

View file

@ -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<std::string> 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);