OSDN Git Service

設定のファイル名にインストールフォルダを補うのを徹底する
authorKazuhiro Fujieda <fujieda@users.osdn.me>
Thu, 7 Jun 2018 12:35:09 +0000 (21:35 +0900)
committerKazuhiro Fujieda <fujieda@users.osdn.me>
Thu, 7 Jun 2018 12:35:09 +0000 (21:35 +0900)
KancolleSniffer/ConfigDialog.cs

index 721f7e8..7183cd3 100644 (file)
@@ -195,7 +195,7 @@ namespace KancolleSniffer
 \r
             _config.Sounds.Volume = (int)numericUpDownSoundVolume.Value;\r
             foreach (var name in Config.NotificationNames)\r
-                _config.Sounds[name] = _soundSettings[name];\r
+                _config.Sounds[name] = MakePathRooted(_soundSettings[name]);\r
         }\r
 \r
         private bool ValidatePorts(out int listen, out int outbound, out int server)\r
@@ -231,17 +231,33 @@ namespace KancolleSniffer
         {\r
             _config.Log.On = checkBoxOutput.Checked;\r
             _config.Log.MaterialLogInterval = (int)numericUpDownMaterialLogInterval.Value;\r
-            _config.Log.OutputDir = textBoxOutput.Text;\r
+            _config.Log.OutputDir = MakePathRooted(textBoxOutput.Text);\r
             _main.ApplyLogSetting();\r
         }\r
 \r
         private void ApplyDebugSettings()\r
         {\r
             _config.DebugLogging = checkBoxDebugLog.Checked;\r
-            _config.DebugLogFile = textBoxDebugLog.Text;\r
+            _config.DebugLogFile = MakePathRooted(textBoxDebugLog.Text);\r
             _main.ApplyDebugLogSetting();\r
         }\r
 \r
+        private string MakePathRooted(string path)\r
+        {\r
+            try\r
+            {\r
+                return string.IsNullOrWhiteSpace(path)\r
+                    ? ""\r
+                    : Path.IsPathRooted(path)\r
+                        ? path\r
+                        : Path.Combine(Config.BaseDir, path);\r
+            }\r
+            catch (ArgumentException)\r
+            {\r
+                return "";\r
+            }\r
+        }\r
+\r
         private void textBoxSoundFile_TextChanged(object sender, EventArgs e)\r
         {\r
             _soundSettings[(string)listBoxSoundFile.SelectedItem] = textBoxSoundFile.Text;\r