Attempt to fix File Path handling

- Now uses unix standard frontslashes for directories internally
- Converts the backslashes windows returns to frontslashes
- Changed default paths
This commit is contained in:
adroslice 2019-12-01 17:05:00 +01:00
parent 3545afad51
commit 10153a9bd2
2 changed files with 7 additions and 8 deletions

View File

@ -7,14 +7,13 @@ using System.Text.RegularExpressions;
using Avalonia; using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.VisualTree;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using Avalonia.LogicalTree;
using BFR.Helpers; using BFR.Helpers;
using BFR.DataModels; using BFR.DataModels;
using Avalonia.Interactivity;
using Avalonia.Input; using Avalonia.Input;
using Avalonia.LogicalTree;
using Avalonia.VisualTree;
namespace BFR namespace BFR
{ {
@ -26,8 +25,8 @@ namespace BFR
public async Task OpenDirectoryButtonClick() => OpenDirectory(await new OpenFolderDialog() { Directory = WorkingDirectory }.ShowAsync(this)); public async Task OpenDirectoryButtonClick() => OpenDirectory(await new OpenFolderDialog() { Directory = WorkingDirectory }.ShowAsync(this));
public void OpenDirectory(string directory) public void OpenDirectory(string directory)
{ {
WorkingDirectory = directory; WorkingDirectory = directory.Replace('\\', '/');
AllFiles.ReplaceAll(Directory.GetFiles(WorkingDirectory).Select(x => new FileModel(x))); AllFiles.ReplaceAll(Directory.GetFiles(WorkingDirectory).Select(x => new FileModel(x.Replace('\\', '/'))));
Filter(); Filter();
} }
@ -137,7 +136,7 @@ namespace BFR
{ {
AvaloniaXamlLoader.Load(this); AvaloniaXamlLoader.Load(this);
DataContext = this; DataContext = this;
OpenDirectory(Environment.OSVersion.Platform == PlatformID.Win32NT ? @"C:\Users" : @"\home"); OpenDirectory(Environment.OSVersion.Platform == PlatformID.Win32NT ? @"C:/Users/" : @"/home/");
HandleEvents = true; HandleEvents = true;
OperationsListBox = this.Find<ListBox>("OperationsListBox"); OperationsListBox = this.Find<ListBox>("OperationsListBox");
} }

View File

@ -27,8 +27,8 @@
get => $"{Directory}{FullName}"; get => $"{Directory}{FullName}";
set set
{ {
FullName = value.Substring(value.LastIndexOf('\\') + 1); FullName = value.Substring(value.LastIndexOf('/') + 1);
Directory = value.Substring(0, value.LastIndexOf('\\') + 1); Directory = value.Substring(0, value.LastIndexOf('/') + 1);
} }
} }