Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<Platforms>x86;x64;ARM64</Platforms>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsAotCompatible>true</IsAotCompatible>
</PropertyGroup>

<PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions src/Files.App.CsWin32/Files.App.CsWin32.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<Configurations>Debug;Release</Configurations>
<Platforms>x86;x64;arm64</Platforms>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
<IsAotCompatible>true</IsAotCompatible>
</PropertyGroup>

<ItemGroup>
Expand Down
3 changes: 0 additions & 3 deletions src/Files.App.CsWin32/NativeMethods.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ RemoveDirectoryFromApp
GetKeyState
CreateDirectoryFromApp
WNetCancelConnection2
NET_USE_CONNECT_FLAGS
NETRESOURCEW
WNetAddConnection3
CREDENTIALW
Expand Down Expand Up @@ -78,7 +77,6 @@ GetAce
SetEntriesInAcl
ACL_SIZE_INFORMATION
DeleteAce
EXPLICIT_ACCESS
ACCESS_ALLOWED_ACE
LookupAccountSid
GetComputerName
Expand Down Expand Up @@ -133,7 +131,6 @@ ShellExecuteEx
CoTaskMemFree
QueryDosDevice
DeviceIoControl
GetLastError
CreateFile
GetVolumeInformation
COMPRESSION_FORMAT
Expand Down
1 change: 1 addition & 0 deletions src/Files.App.Storage/Files.App.Storage.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<Platforms>x86;x64;arm64</Platforms>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsAotCompatible>true</IsAotCompatible>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public unsafe static HRESULT TryGetThumbnail(this IWindowsStorable storable, int
{
thumbnailData = null;

using ComPtr<IShellItemImageFactory> pShellItemImageFactory = storable.ThisPtr.As<IShellItemImageFactory>();
using ComPtr<IShellItemImageFactory> pShellItemImageFactory = default;
storable.ThisPtr.As(pShellItemImageFactory.GetAddressOf());
if (pShellItemImageFactory.IsNull)
return HRESULT.E_NOINTERFACE;

Expand Down
1 change: 1 addition & 0 deletions src/Files.App.Storage/Watchers/RecycleBinWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace Files.App.Storage.Watchers
{
[Obsolete]
public class RecycleBinWatcher : ITrashWatcher
{
private readonly List<SystemIO.FileSystemWatcher> _watchers = [];
Expand Down
1 change: 1 addition & 0 deletions src/Files.Core.Storage/Files.Core.Storage.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<Configurations>Debug;Release</Configurations>
<Platforms>x86;x64;arm64</Platforms>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
<IsAotCompatible>true</IsAotCompatible>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions src/Files.Shared/Files.Shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<Configurations>Debug;Release</Configurations>
<Platforms>x86;x64;arm64</Platforms>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
<IsAotCompatible>true</IsAotCompatible>
</PropertyGroup>

<ItemGroup>
Expand Down
74 changes: 13 additions & 61 deletions src/Files.Shared/Helpers/PathHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,77 +17,28 @@ public static string Combine(string folder, string name)
return folder.Contains('/') ? Path.Combine(folder, name).Replace('\\', '/') : Path.Combine(folder, name);
}

public static string FormatName(string path)
{
string fileName;
string rootPath = Path.GetPathRoot(path) ?? string.Empty;

if (rootPath == path &&
( path.StartsWith(@"\\") ||
(new DriveInfo(path).DriveType == System.IO.DriveType.Network)
)
)
{
// Network Share path
fileName = path.Substring(path.LastIndexOf(@"\", StringComparison.Ordinal) + 1);
}
else if (rootPath == path)
{
// Drive path
fileName = path;
}
else
{
// Standard file name
fileName = Path.GetFileName(path);
}

// Check for link file name
if (FileExtensionHelpers.IsShortcutOrUrlFile(fileName))
fileName = fileName.Remove(fileName.Length - 4);

return fileName;
}

/// <summary>
/// Determines whether the <paramref name="path"/> points to any special system folders.
/// </summary>
/// <remarks>
/// The term "Special folder" refers to any folders that may be natively supported by a certain platform (e.g. Libraries).
/// </remarks>
/// <param name="path">The path to a folder to check.</param>
/// <returns>If the path points to a special folder, returns true; otherwise false.</returns>
public static bool IsSpecialFolder(string path)
{
foreach (Environment.SpecialFolder specialFolder in Enum.GetValues(typeof(Environment.SpecialFolder)))
{
var specialFolderPath = Environment.GetFolderPath(specialFolder);
if (string.Equals(specialFolderPath, path, StringComparison.OrdinalIgnoreCase))
return true;
}

return false;
}

public static bool TryGetFullPath(string commandName, out string fullPath)
{
fullPath = string.Empty;
try
{
var p = new Process();
p.StartInfo = new ProcessStartInfo
var p = new Process
{
UseShellExecute = false,
CreateNoWindow = true,
FileName = "where.exe",
Arguments = commandName,
RedirectStandardOutput = true
StartInfo = new ProcessStartInfo
{
UseShellExecute = false,
CreateNoWindow = true,
FileName = "where.exe",
Arguments = commandName,
RedirectStandardOutput = true
}
};

p.Start();

var output = p.StandardOutput.ReadToEnd();
p.WaitForExit(1000);


if (p.ExitCode != 0)
return false;

Expand All @@ -97,16 +48,17 @@ public static bool TryGetFullPath(string commandName, out string fullPath)
if (FileExtensionHelpers.IsExecutableFile(line))
{
fullPath = line;

return true;
}
}

return false;
}
catch (Exception)
{
return false;
}

}
}
}
24 changes: 12 additions & 12 deletions src/Files.Shared/Utils/IAsyncInitialize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@

namespace Files.Shared.Utils
{
/// <summary>
/// Allows an object to be initialized asynchronously.
/// </summary>
public interface IAsyncInitialize
{
/// <summary>
/// Initializes resources and prepares them for use.
/// </summary>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> that cancels this action.</param>
/// <returns>A <see cref="Task"/> that represents the asynchronous operation.</returns>
Task InitAsync(CancellationToken cancellationToken = default);
}
/// <summary>
/// Allows an object to be initialized asynchronously.
/// </summary>
public interface IAsyncInitialize
{
/// <summary>
/// Initializes resources and prepares them for use.
/// </summary>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> that cancels this action.</param>
/// <returns>A <see cref="Task"/> that represents the asynchronous operation.</returns>
Task InitAsync(CancellationToken cancellationToken = default);
}
}
Loading