Skip to content

Commit

Permalink
CommandLine: Resolve exe path before use
Browse files Browse the repository at this point in the history
  • Loading branch information
Royna2544 committed Nov 20, 2024
1 parent 82f17a6 commit 445e677
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/utils/CommandLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <CommandLine.hpp>
#include <filesystem>
#include <stdexcept>
#include <system_error>

CommandLine::CommandLine(CommandLine::argc_type argc,
CommandLine::argv_type argv)
Expand All @@ -12,6 +13,12 @@ CommandLine::CommandLine(CommandLine::argc_type argc,
throw std::invalid_argument("Invalid argv passed");
}
exePath = std::filesystem::current_path() / std::filesystem::path(argv[0]);
std::error_code ec;
exePath = std::filesystem::canonical(exePath, ec);
if (ec) {
LOG(WARNING) << "Cannot fully resolve path";
}
DLOG(INFO) << "exePath: " << exePath;
}

CommandLine::argv_type CommandLine::argv() const { return _argv; }
Expand Down

0 comments on commit 445e677

Please sign in to comment.