From: Kazuhiro Fujieda Date: Thu, 7 Jun 2018 12:35:09 +0000 (+0900) Subject: 設定のファイル名にインストールフォルダを補うのを徹底する X-Git-Tag: v10.11~10 X-Git-Url: http://git.osdn.net/view?p=kancollesniffer%2FKancolleSniffer.git;a=commitdiff_plain;h=f1efc5579046b163990c5502c3e6b49c980d8e54 設定のファイル名にインストールフォルダを補うのを徹底する --- diff --git a/KancolleSniffer/ConfigDialog.cs b/KancolleSniffer/ConfigDialog.cs index 721f7e8..7183cd3 100644 --- a/KancolleSniffer/ConfigDialog.cs +++ b/KancolleSniffer/ConfigDialog.cs @@ -195,7 +195,7 @@ namespace KancolleSniffer _config.Sounds.Volume = (int)numericUpDownSoundVolume.Value; foreach (var name in Config.NotificationNames) - _config.Sounds[name] = _soundSettings[name]; + _config.Sounds[name] = MakePathRooted(_soundSettings[name]); } private bool ValidatePorts(out int listen, out int outbound, out int server) @@ -231,17 +231,33 @@ namespace KancolleSniffer { _config.Log.On = checkBoxOutput.Checked; _config.Log.MaterialLogInterval = (int)numericUpDownMaterialLogInterval.Value; - _config.Log.OutputDir = textBoxOutput.Text; + _config.Log.OutputDir = MakePathRooted(textBoxOutput.Text); _main.ApplyLogSetting(); } private void ApplyDebugSettings() { _config.DebugLogging = checkBoxDebugLog.Checked; - _config.DebugLogFile = textBoxDebugLog.Text; + _config.DebugLogFile = MakePathRooted(textBoxDebugLog.Text); _main.ApplyDebugLogSetting(); } + private string MakePathRooted(string path) + { + try + { + return string.IsNullOrWhiteSpace(path) + ? "" + : Path.IsPathRooted(path) + ? path + : Path.Combine(Config.BaseDir, path); + } + catch (ArgumentException) + { + return ""; + } + } + private void textBoxSoundFile_TextChanged(object sender, EventArgs e) { _soundSettings[(string)listBoxSoundFile.SelectedItem] = textBoxSoundFile.Text;