IFileOperations.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System.IO.Abstractions;
  2. namespace Terminal.Gui.FileServices;
  3. /// <summary>
  4. /// Interface for defining how to handle file/directory deletion, rename and newing attempts in
  5. /// <see cref="FileDialog"/>.
  6. /// </summary>
  7. public interface IFileOperations
  8. {
  9. /// <summary>Specifies how to handle file/directory deletion attempts in <see cref="FileDialog"/>.</summary>
  10. /// <param name="app"></param>
  11. /// <param name="toDelete"></param>
  12. /// <returns><see langword="true"/> if operation was completed or <see langword="false"/> if cancelled</returns>
  13. /// <remarks>
  14. /// Ensure you use a try/catch block with appropriate error handling (e.g. showing a <see cref="MessageBox"/>
  15. /// </remarks>
  16. bool Delete (IApplication? app, IEnumerable<IFileSystemInfo> toDelete);
  17. /// <summary>Specifies how to handle 'new directory' operation in <see cref="FileDialog"/>.</summary>
  18. /// <param name="app"></param>
  19. /// <param name="fileSystem"></param>
  20. /// <param name="inDirectory">The parent directory in which the new directory should be created</param>
  21. /// <returns>The newly created directory or null if cancelled.</returns>
  22. /// <remarks>
  23. /// Ensure you use a try/catch block with appropriate error handling (e.g. showing a <see cref="MessageBox"/>
  24. /// </remarks>
  25. IFileSystemInfo New (IApplication? app, IFileSystem fileSystem, IDirectoryInfo inDirectory);
  26. /// <summary>Specifies how to handle file/directory rename attempts in <see cref="FileDialog"/>.</summary>
  27. /// <param name="app"></param>
  28. /// <param name="fileSystem"></param>
  29. /// <param name="toRename"></param>
  30. /// <returns>The new name for the file or null if cancelled</returns>
  31. /// <remarks>
  32. /// Ensure you use a try/catch block with appropriate error handling (e.g. showing a <see cref="MessageBox"/>
  33. /// </remarks>
  34. IFileSystemInfo Rename (IApplication? app, IFileSystem fileSystem, IFileSystemInfo toRename);
  35. }