diff --git a/src/GuiApp/FileTime.Avalonia/IconProviders/MaterialIconProvider.cs b/src/GuiApp/FileTime.Avalonia/IconProviders/MaterialIconProvider.cs index 8ab83cb..a950f55 100644 --- a/src/GuiApp/FileTime.Avalonia/IconProviders/MaterialIconProvider.cs +++ b/src/GuiApp/FileTime.Avalonia/IconProviders/MaterialIconProvider.cs @@ -4,6 +4,7 @@ using FileTime.Providers.Local; using Syroot.Windows.IO; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; namespace FileTime.Avalonia.IconProviders { @@ -23,13 +24,16 @@ namespace FileTime.Avalonia.IconProviders public MaterialIconProvider() { - _specialPaths.Add(new SpecialPathWithIcon(KnownFolders.Desktop.Path, GetAssetPath("desktop.svg"))); - _specialPaths.Add(new SpecialPathWithIcon(KnownFolders.Documents.Path, GetAssetPath("folder-resource.svg"))); - _specialPaths.Add(new SpecialPathWithIcon(KnownFolders.DownloadsLocalized.Path, GetAssetPath("folder-download.svg"))); - _specialPaths.Add(new SpecialPathWithIcon(KnownFolders.MusicLocalized.Path, GetAssetPath("folder-music.svg"))); - _specialPaths.Add(new SpecialPathWithIcon(KnownFolders.Pictures.Path, GetAssetPath("folder-images.svg"))); - _specialPaths.Add(new SpecialPathWithIcon(KnownFolders.Profile.Path, GetAssetPath("folder-home.svg"))); - _specialPaths.Add(new SpecialPathWithIcon(KnownFolders.Videos.Path, GetAssetPath("folder-video.svg"))); + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + _specialPaths.Add(new SpecialPathWithIcon(KnownFolders.Desktop.Path, GetAssetPath("desktop.svg"))); + _specialPaths.Add(new SpecialPathWithIcon(KnownFolders.Documents.Path, GetAssetPath("folder-resource.svg"))); + _specialPaths.Add(new SpecialPathWithIcon(KnownFolders.DownloadsLocalized.Path, GetAssetPath("folder-download.svg"))); + _specialPaths.Add(new SpecialPathWithIcon(KnownFolders.MusicLocalized.Path, GetAssetPath("folder-music.svg"))); + _specialPaths.Add(new SpecialPathWithIcon(KnownFolders.Pictures.Path, GetAssetPath("folder-images.svg"))); + _specialPaths.Add(new SpecialPathWithIcon(KnownFolders.Profile.Path, GetAssetPath("folder-home.svg"))); + _specialPaths.Add(new SpecialPathWithIcon(KnownFolders.Videos.Path, GetAssetPath("folder-video.svg"))); + } } public ImagePath GetImage(IItem item) @@ -63,7 +67,7 @@ namespace FileTime.Avalonia.IconProviders if (_iconsByFileName.TryGetValue(fileName, out var value)) possibleIcon = value; else if (_iconsByExtension.FirstOrDefault(k => fileName.EndsWith("." + k.Key)) is KeyValuePair matchingExtension && matchingExtension.Key != null) possibleIcon = matchingExtension.Value; - if(possibleIcon != null) + if (possibleIcon != null) { icon = possibleIcon + ".svg"; } diff --git a/src/GuiApp/FileTime.Avalonia/Models/RootDriveInfo.cs b/src/GuiApp/FileTime.Avalonia/Models/RootDriveInfo.cs index 088b016..268fb2d 100644 --- a/src/GuiApp/FileTime.Avalonia/Models/RootDriveInfo.cs +++ b/src/GuiApp/FileTime.Avalonia/Models/RootDriveInfo.cs @@ -1,9 +1,8 @@ using FileTime.Core.Models; +using FileTime.Providers.Local; using MvvmGen; -using System; -using System.Collections.Generic; using System.IO; -using System.Text; +using System.Runtime.InteropServices; namespace FileTime.Avalonia.Models { @@ -33,7 +32,7 @@ namespace FileTime.Avalonia.Models [PropertyInvalidate(nameof(Used))] [PropertyInvalidate(nameof(Size))] - public long UsedPercentage => Used * 100 / Size; + public long UsedPercentage => Size == 0 ? 0 : Used * 100 / Size; public RootDriveInfo(DriveInfo driveInfo, IContainer container) { @@ -46,8 +45,8 @@ namespace FileTime.Avalonia.Models private void Refresh() { Name = _container.Name; - FullName = _container.FullName; - Label = _driveInfo.VolumeLabel; + FullName = _container is LocalContentProvider ? "/" : _container.FullName; + Label = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? _driveInfo.VolumeLabel : null; Size = _driveInfo.TotalSize; Free = _driveInfo.AvailableFreeSpace; Used = _driveInfo.TotalSize - _driveInfo.AvailableFreeSpace; diff --git a/src/GuiApp/FileTime.Avalonia/ViewModels/MainPageViewModel.cs b/src/GuiApp/FileTime.Avalonia/ViewModels/MainPageViewModel.cs index 2e9b1b8..c61f519 100644 --- a/src/GuiApp/FileTime.Avalonia/ViewModels/MainPageViewModel.cs +++ b/src/GuiApp/FileTime.Avalonia/ViewModels/MainPageViewModel.cs @@ -1,4 +1,4 @@ -using FileTime.Core.Components; +using FileTime.Core.Components; using FileTime.Core.Extensions; using FileTime.Core.Interactions; using FileTime.Core.Models; @@ -122,7 +122,15 @@ namespace FileTime.Avalonia.ViewModels } var driveInfos = new List(); - foreach (var drive in DriveInfo.GetDrives().Where(d => d.DriveType == DriveType.Fixed)) + var drives = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) + ? DriveInfo.GetDrives().Where(d => d.DriveType == DriveType.Fixed) + : DriveInfo.GetDrives().Where(d => + d.DriveType == DriveType.Fixed + && d.DriveFormat != "pstorefs" + && d.DriveFormat != "bpf_fs" + && d.DriveFormat != "tracefs" + && !d.RootDirectory.FullName.StartsWith("/snap/")); + foreach (var drive in drives) { var container = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? await GetContainerForWindowsDrive(drive)