Skip to content

Commit

Permalink
Code Quality: Clean up App.Shell (#12399)
Browse files Browse the repository at this point in the history
  • Loading branch information
0x5bfa authored May 21, 2023
1 parent 173fd80 commit 1f78ff4
Show file tree
Hide file tree
Showing 16 changed files with 517 additions and 411 deletions.
10 changes: 5 additions & 5 deletions src/Files.App/Filesystem/LibraryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ public static async Task<List<LibraryLocationItem>> ListUserLibraries()
var libFiles = Directory.EnumerateFiles(ShellLibraryItem.LibrariesPath, "*" + ShellLibraryItem.EXTENSION);
foreach (var libFile in libFiles)
{
using var shellItem = new ShellLibrary2(Shell32.ShellUtil.GetShellItemForPath(libFile), true);
if (shellItem is ShellLibrary2 library)
using var shellItem = new ShellLibraryEx(Shell32.ShellUtil.GetShellItemForPath(libFile), true);
if (shellItem is ShellLibraryEx library)
{
libraryItems.Add(ShellFolderExtensions.GetShellLibraryItem(library, libFile));
}
Expand Down Expand Up @@ -167,7 +167,7 @@ public async Task<bool> CreateNewLibrary(string name)
{
try
{
using var library = new ShellLibrary2(name, Shell32.KNOWNFOLDERID.FOLDERID_Libraries, false);
using var library = new ShellLibraryEx(name, Shell32.KNOWNFOLDERID.FOLDERID_Libraries, false);
library.Folders.Add(ShellItem.Open(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments))); // Add default folder so it's not empty
library.Commit();
library.Reload();
Expand Down Expand Up @@ -212,7 +212,7 @@ public async Task<LibraryLocationItem> UpdateLibrary(string libraryPath, string
try
{
bool updated = false;
using var library = new ShellLibrary2(Shell32.ShellUtil.GetShellItemForPath(libraryPath), false);
using var library = new ShellLibraryEx(Shell32.ShellUtil.GetShellItemForPath(libraryPath), false);
if (folders is not null)
{
if (folders.Length > 0)
Expand Down Expand Up @@ -404,7 +404,7 @@ private void OnLibraryChanged(WatcherChangeTypes changeType, string oldPath, str

if (!changeType.HasFlag(WatcherChangeTypes.Deleted))
{
var library = SafetyExtensions.IgnoreExceptions(() => new ShellLibrary2(Shell32.ShellUtil.GetShellItemForPath(newPath), true));
var library = SafetyExtensions.IgnoreExceptions(() => new ShellLibraryEx(Shell32.ShellUtil.GetShellItemForPath(newPath), true));
if (library is null)
{
App.Logger.LogWarning($"Failed to open library after {changeType}: {newPath}");
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Filesystem/StorageItems/ShellStorageFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public static IAsyncOperation<BaseStorageFile> FromPathAsync(string path)
{
try
{
using var shellItem = ShellFolderExtensions.GetShellItemFromPathOrPidl(path);
using var shellItem = ShellFolderExtensions.GetShellItemFromPathOrPIDL(path);
return ShellFolderExtensions.GetShellFileItem(shellItem);
}
catch
Expand Down
Loading

0 comments on commit 1f78ff4

Please sign in to comment.