2
0

IFileOperations.cs 1.8 KB

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