IFileOperations.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using System.IO.Abstractions;
  2. namespace Terminal.Gui;
  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="toDelete"></param>
  11. /// <returns><see langword="true"/> if operation was completed or <see langword="false"/> if cancelled</returns>
  12. /// <remarks>
  13. /// Ensure you use a try/catch block with appropriate error handling (e.g. showing a <see cref="MessageBox"/>
  14. /// </remarks>
  15. bool Delete (IEnumerable<IFileSystemInfo> toDelete);
  16. /// <summary>Specifies how to handle 'new directory' operation in <see cref="FileDialog"/>.</summary>
  17. /// <param name="fileSystem"></param>
  18. /// <param name="inDirectory">The parent directory in which the new directory should be created</param>
  19. /// <returns>The newly created directory or null if cancelled.</returns>
  20. /// <remarks>
  21. /// Ensure you use a try/catch block with appropriate error handling (e.g. showing a <see cref="MessageBox"/>
  22. /// </remarks>
  23. IFileSystemInfo New (IFileSystem fileSystem, IDirectoryInfo inDirectory);
  24. /// <summary>Specifies how to handle file/directory rename attempts in <see cref="FileDialog"/>.</summary>
  25. /// <param name="fileSystem"></param>
  26. /// <param name="toRename"></param>
  27. /// <returns>The new name for the file or null if cancelled</returns>
  28. /// <remarks>
  29. /// Ensure you use a try/catch block with appropriate error handling (e.g. showing a <see cref="MessageBox"/>
  30. /// </remarks>
  31. IFileSystemInfo Rename (IFileSystem fileSystem, IFileSystemInfo toRename);
  32. }