Skip to content

gnss: add error handling to filesystem iteration in get_available_geoids#383

Closed
Copilot wants to merge 2 commits intomp/proj2from
copilot/sub-pr-373
Closed

gnss: add error handling to filesystem iteration in get_available_geoids#383
Copilot wants to merge 2 commits intomp/proj2from
copilot/sub-pr-373

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 1, 2026

get_available_geoids iterated candidate directories using std::filesystem::directory_iterator without any error handling, causing uncaught std::filesystem::filesystem_error exceptions on permission errors or broken symlinks — crashing the app at startup.

Changes

  • core/src/gnss.cpp — replace all throwing filesystem calls with std::error_code overloads:
    • exists(path, ec) — avoids throw on unresolvable symlinks
    • directory_iterator(path, ec) — logs and skips the candidate path if it cannot be opened
    • dir_it.increment(ec) — logs and breaks the inner loop if a mid-iteration error occurs
    • entry.is_regular_file(ec) — silently skips entries that cannot be stat'd
std::filesystem::directory_iterator dir_it(proj_path, ec);
if (ec)
{
    std::cerr << "cannot open directory " << proj_path << ": " << ec.message() << std::endl;
    continue;
}
for (; dir_it != std::filesystem::directory_iterator(); dir_it.increment(ec))
{
    if (ec) { /* log + break */ }
    const auto& entry = *dir_it;
    if (entry.is_regular_file(ec) && !ec && entry.path().extension() == ".gtx")
        unique.insert(entry.path().filename().string());
}

Errors are reported to std::cerr; unreadable paths are skipped without interrupting the search over remaining candidates.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: michalpelka <3209244+michalpelka@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on Proj integration implementation gnss: add error handling to filesystem iteration in get_available_geoids Mar 1, 2026
@michalpelka michalpelka closed this Mar 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants