Skip to content

Commit 03fe80f

Browse files
author
Olivier Chafik
committed
drop unused fs_list_files
1 parent 9e8b43f commit 03fe80f

File tree

2 files changed

+0
-39
lines changed

2 files changed

+0
-39
lines changed

common/common.cpp

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
#include <fcntl.h>
5050
#include <io.h>
5151
#else
52-
#include <dirent.h>
5352
#include <sys/ioctl.h>
5453
#include <sys/stat.h>
5554
#include <unistd.h>
@@ -855,43 +854,6 @@ bool fs_create_directory_with_parents(const std::string & path) {
855854
#endif // _WIN32
856855
}
857856

858-
859-
std::vector<std::string> fs_list_files(const std::string & folder, const std::string & ext) {
860-
std::vector<std::string> files;
861-
// Note: once we can use C++17 this becomes:
862-
// for (const auto & entry : std::filesystem::directory_iterator(folder))
863-
// if (entry.path().extension() == ext) files.push_back(entry.path().string());
864-
#ifdef _WIN32
865-
std::string search_path = folder + "\\*" + ext;
866-
WIN32_FIND_DATA fd;
867-
HANDLE hFind = ::FindFirstFile(search_path.c_str(), &fd);
868-
if (hFind != INVALID_HANDLE_VALUE) {
869-
do {
870-
if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
871-
files.push_back(folder + "\\" + fd.cFileName);
872-
}
873-
} while (::FindNextFile(hFind, &fd));
874-
::FindClose(hFind);
875-
}
876-
#else
877-
DIR* dir = opendir(folder.c_str());
878-
if (dir != nullptr) {
879-
struct dirent* entry;
880-
while ((entry = readdir(dir)) != nullptr) {
881-
if (entry->d_type == DT_REG) { // If it's a regular file
882-
std::string filename = entry->d_name;
883-
if (filename.length() >= ext.length() &&
884-
filename.compare(filename.length() - ext.length(), ext.length(), ext) == 0) {
885-
files.push_back(folder + "/" + filename);
886-
}
887-
}
888-
}
889-
closedir(dir);
890-
}
891-
#endif
892-
return files;
893-
}
894-
895857
std::string fs_get_cache_directory() {
896858
std::string cache_directory = "";
897859
auto ensure_trailing_slash = [](std::string p) {

common/common.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,6 @@ std::string string_from(const struct llama_context * ctx, const struct llama_bat
492492

493493
bool fs_validate_filename(const std::string & filename);
494494
bool fs_create_directory_with_parents(const std::string & path);
495-
std::vector<std::string> fs_list_files(const std::string & path, const std::string & ext);
496495

497496
std::string fs_get_cache_directory();
498497
std::string fs_get_cache_file(const std::string & filename);

0 commit comments

Comments
 (0)