MoveCommand

This commit is contained in:
2023-07-04 22:07:11 +02:00
parent 718fd53026
commit 453834646b
17 changed files with 263 additions and 22 deletions

View File

@@ -0,0 +1,28 @@
using FileTime.Core.ContentAccess;
using FileTime.Core.Models;
namespace FileTime.Providers.Local;
public class LocalItemMover : IItemMover<ILocalContentProvider>
{
public Task RenameAsync(ILocalContentProvider contentProvider, FullName fullName, FullName newPath)
{
var source = contentProvider.GetNativePath(fullName);
var destination = contentProvider.GetNativePath(newPath);
if (File.Exists(source.Path))
{
File.Move(source.Path, destination.Path);
}
else if (Directory.Exists(source.Path))
{
Directory.Move(source.Path, destination.Path);
}
else
{
throw new FileNotFoundException(source.Path);
}
return Task.CompletedTask;
}
}