From fed013310992cef0534f680967078f45420323af Mon Sep 17 00:00:00 2001 From: Conrad Pankoff Date: Thu, 1 Aug 2019 00:23:53 +1000 Subject: FileManager: Show home directory by default, or command line argument FileManager used to open up with the root directory loaded by default. Now it will try to load either 1) the first argument specified on the command line, 2) the user's home directory, or 3) the root directory. Fixes #389 --- Applications/FileManager/main.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'Applications') diff --git a/Applications/FileManager/main.cpp b/Applications/FileManager/main.cpp index 8849e6a140..6761505535 100644 --- a/Applications/FileManager/main.cpp +++ b/Applications/FileManager/main.cpp @@ -222,7 +222,23 @@ int main(int argc, char** argv) progressbar->set_visible(true); }; - directory_view->open("/"); + // our initial location is defined as, in order of precedence: + // 1. the first command-line argument (e.g. FileManager /bin) + // 2. the user's home directory + // 3. the root directory + + String initial_location; + + if (argc >= 2) + initial_location = argv[1]; + + if (initial_location.is_empty()) + initial_location = get_current_user_home_path(); + + if (initial_location.is_empty()) + initial_location = "/"; + + directory_view->open(initial_location); directory_view->set_focus(true); window->set_main_widget(widget); -- cgit v1.2.3