diff --git a/src/file.cc b/src/file.cc index d38c9563..ee358be0 100644 --- a/src/file.cc +++ b/src/file.cc @@ -435,8 +435,8 @@ void make_directory(StringView dir, mode_t mode) } } -template -Vector list_files(StringView dirname, Filter filter) +template +Vector list_files(StringView dirname, Filter filter) { char buffer[PATH_MAX+1]; format_to(buffer, "{}", dirname); @@ -446,7 +446,7 @@ Vector list_files(StringView dirname, Filter filter) auto close_dir = on_scope_end([dir]{ closedir(dir); }); - Vector result; + Vector result; while (dirent* entry = readdir(dir)) { StringView filename = entry->d_name; @@ -466,13 +466,19 @@ Vector list_files(StringView dirname, Filter filter) return result; } -Vector list_files(StringView directory) +template +Vector list_files(StringView directory) { return list_files(directory, [](const dirent& entry, const struct stat&) { return StringView{entry.d_name}.substr(0_byte, 1_byte) != "."; }); } +Vector list_files(StringView directory) +{ + return list_files<>(directory); +} + static CandidateList candidates(ConstArrayView matches, StringView dirname) { CandidateList res; @@ -547,7 +553,7 @@ CandidateList complete_command(StringView prefix, ByteCount cursor_pos) struct CommandCache { TimeSpec mtim = {}; - Vector commands; + Vector commands; }; static HashMap command_cache; @@ -570,7 +576,7 @@ CandidateList complete_command(StringView prefix, ByteCount cursor_pos) return S_ISREG(st.st_mode) and executable; }; - cache.commands = list_files(dirname, filter); + cache.commands = list_files(dirname, filter); memcpy(&cache.mtim, &st.st_mtim, sizeof(TimeSpec)); } for (auto& cmd : cache.commands)