delete directory from disk

This commit is contained in:
Matt Parker
2025-10-20 19:00:11 +10:00
parent 76bc0afc52
commit 5eef6424f8
3 changed files with 22 additions and 1 deletions

View File

@@ -17,6 +17,17 @@ public class IdeFileExternalChangeHandler
GlobalEvents.Instance.FileSystemWatcherInternal.FileChanged.Subscribe(OnFileChanged);
GlobalEvents.Instance.FileSystemWatcherInternal.FileCreated.Subscribe(OnFileCreated);
GlobalEvents.Instance.FileSystemWatcherInternal.DirectoryCreated.Subscribe(OnFolderCreated);
GlobalEvents.Instance.FileSystemWatcherInternal.DirectoryDeleted.Subscribe(OnFolderDeleted);
}
private async Task OnFolderDeleted(string folderPath)
{
var sharpIdeFolder = SolutionModel.AllFolders.SingleOrDefault(f => f.Path == folderPath);
if (sharpIdeFolder is null)
{
return;
}
await _sharpIdeSolutionModificationService.RemoveDirectory(sharpIdeFolder);
}
private async Task OnFolderCreated(string folderPath)

View File

@@ -68,7 +68,16 @@ public sealed class IdeFileWatcher : IDisposable
private void HandleDeleted(string fullPath)
{
Console.WriteLine($"FileSystemWatcher: Deleted - {fullPath}");
var isDirectory = Path.HasExtension(fullPath) is false;
if (isDirectory)
{
GlobalEvents.Instance.FileSystemWatcherInternal.DirectoryDeleted.InvokeParallelFireAndForget(fullPath);
}
else
{
GlobalEvents.Instance.FileSystemWatcherInternal.FileDeleted.InvokeParallelFireAndForget(fullPath);
}
//Console.WriteLine($"FileSystemWatcher: Deleted - {fullPath}");
}
private void HandleCreated(string fullPath)

View File

@@ -3,6 +3,7 @@ using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
namespace SharpIDE.Application.Features.FileWatching;
/// Does not do any file system operations, only modifies the in-memory solution model
public class SharpIdeSolutionModificationService
{
public SharpIdeSolutionModel SolutionModel { get; set; } = null!;