diff --git a/joomer-ftxui-file-browser.cpp b/joomer-ftxui-file-browser.cpp index 8bdf44e..c724167 100644 --- a/joomer-ftxui-file-browser.cpp +++ b/joomer-ftxui-file-browser.cpp @@ -54,8 +54,11 @@ int main(int argc, char* argv[]) { if (argc > 1) { - directory_path = argv[1]; - current_path = directory_path; + //directory_path = argv[1]; + // 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 @@ -105,6 +108,7 @@ int main(int argc, char* argv[]) { } std::string selected_name; std::filesystem::path new_path; + if (clean_names.size() > 0) selected_name = clean_names[selected]; // Construct the new path @@ -114,6 +118,8 @@ int main(int argc, char* argv[]) { else { new_path = std::filesystem::path(current_path) / selected_name; } + + new_path = std::filesystem::absolute(new_path).lexically_normal(); new_path.make_preferred(); current_path = new_path.string();