Code cleanup in list_files
This commit is contained in:
parent
b01ba59911
commit
0df088be20
14
src/file.cc
14
src/file.cc
|
@ -275,15 +275,12 @@ std::vector<String> list_files(const String& prefix,
|
||||||
{
|
{
|
||||||
kak_assert(dirname.empty() or dirname.back() == '/');
|
kak_assert(dirname.empty() or dirname.back() == '/');
|
||||||
DIR* dir = opendir(dirname.empty() ? "./" : dirname.c_str());
|
DIR* dir = opendir(dirname.empty() ? "./" : dirname.c_str());
|
||||||
auto closeDir = on_scope_end([=]{
|
if (not dir)
|
||||||
if (dir != NULL)
|
return {};
|
||||||
closedir(dir);
|
|
||||||
});
|
auto closeDir = on_scope_end([=]{ closedir(dir); });
|
||||||
|
|
||||||
std::vector<String> result;
|
std::vector<String> result;
|
||||||
if (not dir)
|
|
||||||
return result;
|
|
||||||
|
|
||||||
std::vector<String> subseq_result;
|
std::vector<String> subseq_result;
|
||||||
while (dirent* entry = readdir(dir))
|
while (dirent* entry = readdir(dir))
|
||||||
{
|
{
|
||||||
|
@ -309,8 +306,7 @@ std::vector<String> list_files(const String& prefix,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto& real_result = result.empty() ? subseq_result : result;
|
return result.empty() ? subseq_result : result;
|
||||||
return real_result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<String> complete_filename(const String& prefix,
|
std::vector<String> complete_filename(const String& prefix,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user