diff --git a/.swift-version b/.swift-version new file mode 100644 index 0000000..f398a20 --- /dev/null +++ b/.swift-version @@ -0,0 +1 @@ +3.0 \ No newline at end of file diff --git a/FileProvider.podspec b/FileProvider.podspec index 5ea5a86..94f2388 100644 --- a/FileProvider.podspec +++ b/FileProvider.podspec @@ -16,7 +16,7 @@ Pod::Spec.new do |s| # s.name = "FileProvider" - s.version = "0.5.0" + s.version = "0.5.1" s.summary = "FileManager replacement for Local and Remote (WebDAV/Dropbox/SMB2) files on iOS and MacOS." # This description is used to generate tags and improve search results. diff --git a/Sources/DropboxFileProvider.swift b/Sources/DropboxFileProvider.swift index fa34b5e..a7bf67b 100644 --- a/Sources/DropboxFileProvider.swift +++ b/Sources/DropboxFileProvider.swift @@ -14,7 +14,7 @@ import CoreGraphics // in case of using this class with unencrypted HTTP connection. open class DropboxFileProvider: NSObject, FileProviderBasic { - open let type: String = "WebDAV" + open static let type: String = "WebDAV" open let isPathRelative: Bool = true open let baseURL: URL? open var currentPath: String = "" @@ -40,7 +40,7 @@ open class DropboxFileProvider: NSObject, FileProviderBasic { public init? (credential: URLCredential?) { self.baseURL = nil - dispatch_queue = DispatchQueue(label: "FileProvider.\(type)", attributes: DispatchQueue.Attributes.concurrent) + dispatch_queue = DispatchQueue(label: "FileProvider.\(DropboxFileProvider.type)", attributes: DispatchQueue.Attributes.concurrent) //let url = baseURL.uw_absoluteString self.credential = credential } diff --git a/Sources/FileProvider.swift b/Sources/FileProvider.swift index f67b2d2..a87692e 100644 --- a/Sources/FileProvider.swift +++ b/Sources/FileProvider.swift @@ -97,7 +97,7 @@ open class FileObject { public typealias SimpleCompletionHandler = ((_ error: Error?) -> Void)? public protocol FileProviderBasic: class { - var type: String { get } + static var type: String { get } var isPathRelative: Bool { get } var baseURL: URL? { get } var currentPath: String { get set } @@ -146,6 +146,10 @@ public protocol FileProvider: FileProviderBasic, FileProviderOperations, FilePro } extension FileProviderBasic { + public var type: String { + return type(of: self).type + } + public var bareCurrentPath: String { return currentPath.trimmingCharacters(in: CharacterSet(charactersIn: ". /")) } diff --git a/Sources/LocalFileProvider.swift b/Sources/LocalFileProvider.swift index 490117b..1ce5c2f 100644 --- a/Sources/LocalFileProvider.swift +++ b/Sources/LocalFileProvider.swift @@ -19,7 +19,7 @@ public final class LocalFileObject: FileObject { } open class LocalFileProvider: FileProvider, FileProviderMonitor { - open let type = "Local" + open static let type = "Local" open var isPathRelative: Bool = true open var baseURL: URL? = LocalFileProvider.defaultBaseURL() open var currentPath: String = "" @@ -33,16 +33,16 @@ open class LocalFileProvider: FileProvider, FileProviderMonitor { fileprivate var fileProviderManagerDelegate: LocalFileProviderManagerDelegate? = nil public init () { - dispatch_queue = DispatchQueue(label: "FileProvider.\(type)", attributes: DispatchQueue.Attributes.concurrent) - operation_queue = DispatchQueue(label: "FileProvider.\(type).Operation", attributes: []) + dispatch_queue = DispatchQueue(label: "FileProvider.\(LocalFileProvider.type)", attributes: DispatchQueue.Attributes.concurrent) + operation_queue = DispatchQueue(label: "FileProvider.\(LocalFileProvider.type).Operation", attributes: []) fileProviderManagerDelegate = LocalFileProviderManagerDelegate(provider: self) opFileManager.delegate = fileProviderManagerDelegate } public init (baseURL: URL) { self.baseURL = baseURL - dispatch_queue = DispatchQueue(label: "FileProvider.\(type)", attributes: DispatchQueue.Attributes.concurrent) - operation_queue = DispatchQueue(label: "FileProvider.\(type).Operation", attributes: []) + dispatch_queue = DispatchQueue(label: "FileProvider.\(LocalFileProvider.type)", attributes: DispatchQueue.Attributes.concurrent) + operation_queue = DispatchQueue(label: "FileProvider.\(LocalFileProvider.type).Operation", attributes: []) fileProviderManagerDelegate = LocalFileProviderManagerDelegate(provider: self) opFileManager.delegate = fileProviderManagerDelegate } diff --git a/Sources/SMBFileProvider.swift b/Sources/SMBFileProvider.swift index 5e1b182..202e26e 100644 --- a/Sources/SMBFileProvider.swift +++ b/Sources/SMBFileProvider.swift @@ -9,7 +9,7 @@ import Foundation open class SMBFileProvider: FileProvider, FileProviderMonitor { - open var type: String = "Samba" + open static var type: String = "Samba" open var isPathRelative: Bool = true open var baseURL: URL? open var currentPath: String = "" @@ -24,7 +24,7 @@ open class SMBFileProvider: FileProvider, FileProviderMonitor { return nil } self.baseURL = baseURL - dispatch_queue = DispatchQueue(label: "FileProvider.\(type)", attributes: DispatchQueue.Attributes.concurrent) + dispatch_queue = DispatchQueue(label: "FileProvider.\(SMBFileProvider.type)", attributes: DispatchQueue.Attributes.concurrent) //let url = baseURL.uw_absoluteString self.credential = credential } diff --git a/Sources/WebDAVFileProvider.swift b/Sources/WebDAVFileProvider.swift index 45fbeb2..779f2a2 100644 --- a/Sources/WebDAVFileProvider.swift +++ b/Sources/WebDAVFileProvider.swift @@ -45,7 +45,7 @@ public final class WebDavFileObject: FileObject { // in case of using this class with unencrypted HTTP connection. open class WebDAVFileProvider: NSObject, FileProviderBasic { - open let type: String = "WebDAV" + open static let type: String = "WebDAV" open let isPathRelative: Bool = true open let baseURL: URL? open var currentPath: String = "" @@ -74,7 +74,7 @@ open class WebDAVFileProvider: NSObject, FileProviderBasic { return nil } self.baseURL = baseURL - dispatch_queue = DispatchQueue(label: "FileProvider.\(type)", attributes: DispatchQueue.Attributes.concurrent) + dispatch_queue = DispatchQueue(label: "FileProvider.\(WebDAVFileProvider.type)", attributes: DispatchQueue.Attributes.concurrent) //let url = baseURL.uw_absoluteString self.credential = credential }