[chronojump] Open logs directory creates it if doesn't exist
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Open logs directory creates it if doesn't exist
- Date: Sun, 29 Jun 2014 09:53:42 +0000 (UTC)
commit 9cc2b95aa33a60b870b56d740ff20c003caf8de1
Author: Xavier de Blas <xaviblas gmail com>
Date: Sun Jun 29 11:52:31 2014 +0200
Open logs directory creates it if doesn't exist
src/constants.cs | 2 +-
src/gui/preferences.cs | 20 ++++++++++++++++----
2 files changed, 17 insertions(+), 5 deletions(-)
---
diff --git a/src/constants.cs b/src/constants.cs
index a13c87c..ea7e715 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -569,7 +569,7 @@ public class Constants
};
public static string DatabaseNotFound = Catalog.GetString("Error. Cannot find database.");
- public static string LogNotFound = Catalog.GetString("Error. Cannot find logs directory.");
+ public static string DirectoryCannotOpen = Catalog.GetString("Error. Cannot open directory.");
public static string ChronopicDefaultPortWindows = "COM?";
public static string ChronopicDefaultPortLinux = "/dev/ttyUSB?";
diff --git a/src/gui/preferences.cs b/src/gui/preferences.cs
index 2ba2ec8..4529d4e 100644
--- a/src/gui/preferences.cs
+++ b/src/gui/preferences.cs
@@ -368,12 +368,24 @@ public class PreferencesWindow {
{
string dir = Util.GetLogsDir();
Log.WriteLine(dir);
-
- if(new System.IO.DirectoryInfo(dir).Exists)
+
+ if( ! new System.IO.DirectoryInfo(dir).Exists) {
+ try {
+ Directory.CreateDirectory (dir);
+ } catch {
+ new DialogMessage(Constants.MessageTypes.WARNING,
+ Catalog.GetString("Cannot create directory.") + "\n\n" + dir);
+ return;
+ }
+ }
+
+ try {
System.Diagnostics.Process.Start(dir);
- else
+ }
+ catch {
new DialogMessage(Constants.MessageTypes.WARNING,
- Constants.LogNotFound + "\n\n" + dir);
+ Constants.DirectoryCannotOpen + "\n\n" + dir);
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]