From 35e6f5df829a088fc18f1f9e72ecde0263f4cb4b Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sat, 26 Dec 2015 22:48:20 +0100 Subject: [PATCH] GTK: validate arguments to main program --- src/GUI/Gtk.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/GUI/Gtk.hs b/src/GUI/Gtk.hs index c86c139..42bfabf 100644 --- a/src/GUI/Gtk.hs +++ b/src/GUI/Gtk.hs @@ -218,9 +218,13 @@ startMainWindow startdir = do "refreshView" -- create initial list store model with unsorted data + -- we check that the startdir passed by the user is valid + -- TODO: maybe move this to a separate function + sd <- (\x -> if (failed . file $ x) || (not . isAbsolute . anchor $ x) + then Data.DirTree.readFile "/" + else return x) =<< Data.DirTree.readFile startdir rawModel <- newTVarIO =<< listStoreNew - =<< Data.DirTree.getContents - =<< Data.DirTree.readFile startdir + =<< Data.DirTree.getContents sd filteredModel <- newTVarIO =<< (\x -> treeModelFilterNew x []) =<< readTVarIO rawModel