Keep the dir trailing slash in split_path

This commit is contained in:
Maxime Coste 2015-03-13 13:09:54 +00:00
parent 762643d320
commit 52cd08915d

View File

@ -60,7 +60,7 @@ std::pair<StringView, StringView> split_path(StringView path)
if (it == path.rend()) if (it == path.rend())
return { {}, path }; return { {}, path };
const char* slash = it.base()-1; const char* slash = it.base()-1;
return { {path.begin(), slash}, {slash+1, path.end()} }; return { {path.begin(), slash+1}, {slash+1, path.end()} };
} }
String real_path(StringView filename) String real_path(StringView filename)
@ -278,7 +278,7 @@ String find_file(StringView filename, ConstArrayView<String> paths)
template<typename Filter> template<typename Filter>
Vector<String> list_files(StringView prefix, StringView dirname, Vector<String> list_files(StringView prefix, StringView dirname,
Filter filter) Filter filter)
{ {
kak_assert(dirname.empty() or dirname.back() == '/'); kak_assert(dirname.empty() or dirname.back() == '/');
DIR* dir = opendir(dirname.empty() ? "./" : dirname.zstr()); DIR* dir = opendir(dirname.empty() ? "./" : dirname.zstr());