Linux improvements

This commit is contained in:
2022-02-04 00:49:25 +01:00
parent 96cba48f04
commit 2e43cca9fd
3 changed files with 27 additions and 16 deletions

View File

@@ -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
{
@@ -22,6 +23,8 @@ namespace FileTime.Avalonia.IconProviders
}
public MaterialIconProvider()
{
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")));
@@ -31,6 +34,7 @@ namespace FileTime.Avalonia.IconProviders
_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<string, string> matchingExtension && matchingExtension.Key != null) possibleIcon = matchingExtension.Value;
if(possibleIcon != null)
if (possibleIcon != null)
{
icon = possibleIcon + ".svg";
}

View File

@@ -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;

View File

@@ -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<RootDriveInfo>();
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)