convert relative to absolute

This commit is contained in:
jason 2025-12-21 20:01:59 +00:00
parent 65bbde5c0e
commit 85b7ba00f6

View File

@ -54,8 +54,11 @@ int main(int argc, char* argv[]) {
if (argc > 1) if (argc > 1)
{ {
directory_path = argv[1]; //directory_path = argv[1];
current_path = directory_path; // Convert relative input (like "../../..") into a full absolute path
std::filesystem::path directory_path = std::filesystem::absolute(argv[1]).lexically_normal();
current_path = directory_path.string();
//current_path = directory_path;
} }
// Check if the directory exists // Check if the directory exists
@ -105,6 +108,7 @@ int main(int argc, char* argv[]) {
} }
std::string selected_name; std::string selected_name;
std::filesystem::path new_path; std::filesystem::path new_path;
if (clean_names.size() > 0) if (clean_names.size() > 0)
selected_name = clean_names[selected]; selected_name = clean_names[selected];
// Construct the new path // Construct the new path
@ -114,6 +118,8 @@ int main(int argc, char* argv[]) {
else { else {
new_path = std::filesystem::path(current_path) / selected_name; new_path = std::filesystem::path(current_path) / selected_name;
} }
new_path = std::filesystem::absolute(new_path).lexically_normal();
new_path.make_preferred(); new_path.make_preferred();
current_path = new_path.string(); current_path = new_path.string();