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
This commit is contained in:
Conrad Pankoff 2019-08-01 00:23:53 +10:00 committed by Andreas Kling
parent 9b6e99f17e
commit fed0133109
Notes: sideshowbarker 2024-07-19 12:58:31 +09:00

View file

@ -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);