[vcpkg] Fix crash when trying to enumerate nonexistent directory.

This commit is contained in:
Robert Schumacher 2018-02-03 21:24:30 -08:00
parent 6609d3d32e
commit 0ef1bbb38c

View File

@ -74,6 +74,7 @@ namespace vcpkg::Files
std::error_code ec; std::error_code ec;
fs::stdfs::recursive_directory_iterator b(dir, ec), e{}; fs::stdfs::recursive_directory_iterator b(dir, ec), e{};
if (ec) return ret;
for (; b != e; ++b) for (; b != e; ++b)
{ {
ret.push_back(b->path()); ret.push_back(b->path());
@ -86,7 +87,9 @@ namespace vcpkg::Files
{ {
std::vector<fs::path> ret; std::vector<fs::path> ret;
fs::stdfs::directory_iterator b(dir), e{}; std::error_code ec;
fs::stdfs::directory_iterator b(dir, ec), e{};
if (ec) return ret;
for (; b != e; ++b) for (; b != e; ++b)
{ {
ret.push_back(b->path()); ret.push_back(b->path());