diff options
| author | dranull <150595692+dranull@users.noreply.github.com> | 2023-12-12 16:43:38 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-12 16:43:38 +0000 |
| commit | 934112af5bed36a1273cc0d5588e27ab4825922b (patch) | |
| tree | e6f0d206e8afe89c7083a6768c0dc13e6fb2b3d1 /src/main.cpp | |
| parent | ba2af6f86d26fbf4b51aa37bf901e0118f46bbe3 (diff) | |
config: Use canonical instead of read_symlink (#4136)
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/main.cpp b/src/main.cpp index 0f68c3b2..86c44857 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -52,19 +52,21 @@ int main(int argc, char** argv) { return 1; } - std::string next_arg = std::next(it)->c_str(); + configPath = std::next(it)->c_str(); - if (std::filesystem::is_symlink(next_arg)) - next_arg = std::filesystem::read_symlink(next_arg); + try { + configPath = std::filesystem::canonical(configPath); - if (!std::filesystem::is_regular_file(next_arg)) { - std::cerr << "[ ERROR ] Config file '" << next_arg << "' doesn't exist!\n"; + if (!std::filesystem::is_regular_file(configPath)) { + throw std::exception(); + } + } catch (...) { + std::cerr << "[ ERROR ] Config file '" << configPath << "' doesn't exist!\n"; help(); return 1; } - configPath = std::filesystem::weakly_canonical(next_arg); Debug::log(LOG, "User-specified config location: '{}'", configPath); it++; |
