FilePathConvertible.swift 584 B

123456789101112131415161718192021222324252627282930313233343536
  1. //
  2. // FilePathConvertible.swift
  3. // PDFGenerator
  4. //
  5. // Created by Suguru Kishimoto on 7/23/16.
  6. //
  7. //
  8. import Foundation
  9. public protocol FilePathConvertible {
  10. var url: URL { get }
  11. var path: String { get }
  12. }
  13. extension FilePathConvertible {
  14. var isEmptyPath: Bool {
  15. return path.isEmpty
  16. }
  17. }
  18. extension String: FilePathConvertible {
  19. public var url: URL {
  20. return URL(fileURLWithPath: self)
  21. }
  22. public var path: String {
  23. return self
  24. }
  25. }
  26. extension URL: FilePathConvertible {
  27. public var url: URL {
  28. return self
  29. }
  30. }