MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / fs_list

Function fs_list

subprojects/llama.cpp/common/common.cpp:944–983  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

942}
943
944std::vector<common_file_info> fs_list(const std::string & path, bool include_directories) {
945 std::vector<common_file_info> files;
946 if (path.empty()) return files;
947
948 std::filesystem::path dir(path);
949 if (!std::filesystem::exists(dir) || !std::filesystem::is_directory(dir)) {
950 return files;
951 }
952
953 for (const auto & entry : std::filesystem::directory_iterator(dir)) {
954 try {
955 // Only include regular files (skip directories)
956 const auto & p = entry.path();
957 if (std::filesystem::is_regular_file(p)) {
958 common_file_info info;
959 info.path = p.string();
960 info.name = p.filename().string();
961 info.is_dir = false;
962 try {
963 info.size = static_cast<size_t>(std::filesystem::file_size(p));
964 } catch (const std::filesystem::filesystem_error &) {
965 info.size = 0;
966 }
967 files.push_back(std::move(info));
968 } else if (include_directories && std::filesystem::is_directory(p)) {
969 common_file_info info;
970 info.path = p.string();
971 info.name = p.filename().string();
972 info.size = 0; // Directories have no size
973 info.is_dir = true;
974 files.push_back(std::move(info));
975 }
976 } catch (const std::filesystem::filesystem_error &) {
977 // skip entries we cannot inspect
978 continue;
979 }
980 }
981
982 return files;
983}
984
985//
986// TTY utils

Callers 2

load_from_models_dirMethod · 0.85

Calls 4

emptyMethod · 0.65
pathMethod · 0.45
stringMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected