From 409c87653a6f6b019a61cdb301399c6a34a86166 Mon Sep 17 00:00:00 2001 From: morkt Date: Sun, 20 Sep 2015 05:20:42 +0400 Subject: [PATCH] fallback to current directory if path specified in command line is inaccessible. --- MainWindow.xaml.cs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index 986e04ca..1ed13070 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -90,7 +90,20 @@ namespace GARbro.GUI void WindowRendered () { - ViewModel = CreateViewModel (m_app.InitPath); + DirectoryViewModel vm = null; + try + { + vm = GetNewViewModel (m_app.InitPath); + } + catch (Exception X) + { + PopupError (X.Message, guiStrings.MsgErrorOpening); + } + if (null == vm) + { + vm = CreateViewModel (Directory.GetCurrentDirectory(), true); + } + ViewModel = vm; lv_SelectItem (0); SetStatusText (guiStrings.MsgReady); } @@ -297,7 +310,7 @@ namespace GARbro.GUI /// Create view model corresponding to or empty view model if there was /// an error accessing path. /// - DirectoryViewModel CreateViewModel (string path) + DirectoryViewModel CreateViewModel (string path, bool suppress_warning = false) { try { @@ -305,7 +318,8 @@ namespace GARbro.GUI } catch (Exception X) { - PopupError (X.Message, guiStrings.MsgErrorOpening); + if (!suppress_warning) + PopupError (X.Message, guiStrings.MsgErrorOpening); return new DirectoryViewModel (new string[] { "" }, new Entry[0], false); } }