FileManager.swift 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import Foundation
  2. protocol FileManager {
  3. var temporaryDirectory: URL { get }
  4. func url(
  5. for: Foundation.FileManager.SearchPathDirectory,
  6. in: Foundation.FileManager.SearchPathDomainMask,
  7. appropriateFor: URL?,
  8. create: Bool
  9. ) throws -> URL
  10. func urls(
  11. for: Foundation.FileManager.SearchPathDirectory,
  12. in: Foundation.FileManager.SearchPathDomainMask
  13. ) -> [URL]
  14. func enumerator(
  15. at: URL,
  16. includingPropertiesForKeys: [URLResourceKey]?,
  17. options: Foundation.FileManager.DirectoryEnumerationOptions,
  18. errorHandler: ((URL, Error) -> Bool)?
  19. ) -> Foundation.FileManager.DirectoryEnumerator?
  20. func createDirectory(
  21. at: URL,
  22. withIntermediateDirectories: Bool,
  23. attributes: [FileAttributeKey: Any]?
  24. ) throws
  25. func createFile(
  26. atPath: String,
  27. contents: Data?,
  28. attributes: [FileAttributeKey: Any]?
  29. ) -> Bool
  30. func removeItem(at: URL) throws
  31. func moveItem(at: URL, to: URL) throws
  32. func fileExists(atPath: String) -> Bool
  33. func attributesOfItem(atPath: String) throws -> [FileAttributeKey: Any]
  34. func contents(atPath: String) -> Data?
  35. }
  36. extension Foundation.FileManager: FileManager {}