Skip to content

Commit

Permalink
Check if lookupDir exists before iterating
Browse files Browse the repository at this point in the history
std::filesystem::recursive_directory_iterator throws if the directory
doesn't exist.
  • Loading branch information
syyyr committed Nov 15, 2023
1 parent e749cff commit 1c560ae
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions libosmscout-client/src/osmscoutclient/MapManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ CancelableFuture<bool> MapManager::LookupDatabases()
std::vector<std::filesystem::path> databaseFsDirectories;

for (const auto &lookupDir:databaseLookupDirs){
if (!std::filesystem::exists(lookupDir) || !std::filesystem::is_directory(lookupDir)) {
osmscout::log.Warn() << "Lookup dir" << lookupDir << "doesn't exist";
continue;
}

for (const auto & fInfo : std::filesystem::recursive_directory_iterator(lookupDir)) {
auto entryPath = fInfo.path();
if (fInfo.is_regular_file() && entryPath.has_filename() && entryPath.has_parent_path() && entryPath.filename() == TypeConfig::FILE_TYPES_DAT){
Expand Down

0 comments on commit 1c560ae

Please sign in to comment.