[fix?:] windows paths (ai-based since windows is boring)

This commit is contained in:
2026-05-18 11:42:32 +02:00
parent 67d007bb31
commit b3ab21ae38
4 changed files with 58 additions and 33 deletions
+33 -19
View File
@@ -57,7 +57,7 @@ public partial class MainWindow : Window
try
{
if (!string.IsNullOrWhiteSpace(Global._instance.wiki_storage_path))
TbWikiPath.Text = Global._instance.wiki_storage_path;
TbWikiPath.Text = PathUtilities.NormalizeFileSystemPath(Global._instance.wiki_storage_path);
}
catch (Exception ex)
{
@@ -275,7 +275,7 @@ public partial class MainWindow : Window
{
try
{
var wikiRoot = Global._instance.wiki_storage_path;
var wikiRoot = PathUtilities.NormalizeFileSystemPath(Global._instance.wiki_storage_path);
if (NavTree.SelectedItem is TreeViewItem treeItem && treeItem.Tag is WikiItem selectedItem)
{
if (selectedItem.IsFolder) return selectedItem.Path;
@@ -294,6 +294,9 @@ public partial class MainWindow : Window
private static bool PathsEqual(string left, string right)
{
left = PathUtilities.NormalizeFileSystemPath(left);
right = PathUtilities.NormalizeFileSystemPath(right);
var normalizedLeft = Path.GetFullPath(left)
.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
var normalizedRight = Path.GetFullPath(right)
@@ -337,7 +340,7 @@ public partial class MainWindow : Window
private void OpenFolderButton_Click(object? sender, RoutedEventArgs e)
{
var path = Global._instance.wiki_storage_path;
var path = PathUtilities.NormalizeFileSystemPath(Global._instance.wiki_storage_path);
if (!Directory.Exists(path)) return;
try
@@ -364,9 +367,9 @@ public partial class MainWindow : Window
});
if (folder == null || folder.Count == 0) return;
var chosen = folder[0].Path;
TbWikiPath.Text = chosen.ToString();
Global._instance.wiki_storage_path = chosen.ToString();
var chosen = PathUtilities.NormalizeFileSystemPath(folder[0].Path);
TbWikiPath.Text = chosen;
Global._instance.wiki_storage_path = chosen;
Global.Save();
// reinit wiki service and reload tree
@@ -384,9 +387,9 @@ public partial class MainWindow : Window
});
if (folder == null || folder.Count == 0) return;
var chosen = folder[0].Path;
TbFontPath.Text = chosen.ToString();
Global._instance.font_path = chosen.ToString();
var chosen = PathUtilities.NormalizeFileSystemPath(folder[0].Path);
TbFontPath.Text = chosen;
Global._instance.font_path = chosen;
Global.Save();
}
@@ -400,8 +403,8 @@ public partial class MainWindow : Window
});
if (folder == null || folder.Count == 0) return;
var chosen = folder[0].Path;
Global._instance.SetConfigPath(chosen.ToString());
var chosen = PathUtilities.NormalizeFileSystemPath(folder[0].Path);
Global._instance.SetConfigPath(chosen);
TbConfigPath.Text = Global._instance.config_path;
Global.Save();
@@ -829,10 +832,7 @@ public partial class MainWindow : Window
if (!string.IsNullOrWhiteSpace(filePath))
{
if (filePath.StartsWith("file://"))
{
filePath = new Uri(filePath).LocalPath;
}
filePath = PathUtilities.NormalizeFileSystemPath(filePath);
Console.WriteLine($"PATH: {filePath}");
@@ -1106,11 +1106,18 @@ public partial class MainWindow : Window
result = result.Trim();
if (!result.EndsWith(".md", StringComparison.OrdinalIgnoreCase)) result += ".md";
if (!Directory.Exists(Global._instance.wiki_storage_path))
Directory.CreateDirectory(Global._instance.wiki_storage_path);
var wikiRoot = PathUtilities.NormalizeFileSystemPath(Global._instance.wiki_storage_path);
if (!Directory.Exists(wikiRoot))
Directory.CreateDirectory(wikiRoot);
try
{
if (PathUtilities.HasInvalidFileNameChars(result))
{
MessageBox.Show(this, "Der Dateiname enthält ungültige Zeichen.", "Fehler");
return;
}
var targetDirectory = GetSelectedWikiTargetDirectory();
Directory.CreateDirectory(targetDirectory);
var newFilePath = Path.Combine(targetDirectory, result);
@@ -1131,11 +1138,18 @@ public partial class MainWindow : Window
result = result.Trim();
if (!Directory.Exists(Global._instance.wiki_storage_path))
Directory.CreateDirectory(Global._instance.wiki_storage_path);
var wikiRoot = PathUtilities.NormalizeFileSystemPath(Global._instance.wiki_storage_path);
if (!Directory.Exists(wikiRoot))
Directory.CreateDirectory(wikiRoot);
try
{
if (PathUtilities.HasInvalidFileNameChars(result))
{
MessageBox.Show(this, "Der Ordnername enthält ungültige Zeichen.", "Fehler");
return;
}
var targetDirectory = GetSelectedWikiTargetDirectory();
var newFolderPath = Path.Combine(targetDirectory, result);
Directory.CreateDirectory(newFolderPath);