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 20, 2023
1 parent a631070 commit 8922e9b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libosmscout-client/src/osmscoutclient/MapManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ CancelableFuture<bool> MapManager::LookupDatabases()
std::vector<std::filesystem::path> databaseFsDirectories;

for (const auto &lookupDir:databaseLookupDirs){
auto resolvedSymlink = std::filesystem::is_symlink(lookupDir) ? std::filesystem::read_symlink(lookupDir) : lookupDir;
if (!std::filesystem::exists(lookupDir) || !std::filesystem::is_directory(lookupDir)) {
osmscout::log.Warn() << "Lookup dir" << lookupDir.string() << "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 8922e9b

Please sign in to comment.