summaryrefslogtreecommitdiff
path: root/Applications
diff options
context:
space:
mode:
authorConrad Pankoff <deoxxa@fknsrs.biz>2019-08-01 00:23:53 +1000
committerAndreas Kling <awesomekling@gmail.com>2019-07-31 16:33:21 +0200
commitfed013310992cef0534f680967078f45420323af (patch)
treef5b50502f7b80fda4fc2400e0943d5772e8180d6 /Applications
parent9b6e99f17eedcad2b2bf0bc3fbb9300feeb63c5c (diff)
downloadserenity-fed013310992cef0534f680967078f45420323af.zip
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
Diffstat (limited to 'Applications')
-rw-r--r--Applications/FileManager/main.cpp18
1 files changed, 17 insertions, 1 deletions
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);