-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathDefaultFileWatcherFactory.swift
More file actions
30 lines (27 loc) · 1.21 KB
/
DefaultFileWatcherFactory.swift
File metadata and controls
30 lines (27 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import Foundation
public class DefaultFileWatcherFactory: FileWatcherFactory {
public init() {}
public func createFileWatcher(fileURL: URL, dispatchQueue: DispatchQueue?,
onFileModified: (() -> Void)? = nil, onFileDeleted: (() -> Void)? = nil, onFileRenamed: (() -> Void)? = nil) -> FileWatcherProtocol {
return SingleFileWatcher(fileURL: fileURL,
dispatchQueue: dispatchQueue,
onFileModified: onFileModified,
onFileDeleted: onFileDeleted,
onFileRenamed: onFileRenamed
)
}
public func createDirectoryWatcher(
watchedPaths: [URL],
changePublisher: @escaping PublisherType,
publishInterval: TimeInterval,
directoryChangePublisher: PublisherType? = nil
) -> DirectoryWatcherProtocol {
return BatchingFileChangeWatcher(
watchedPaths: watchedPaths,
changePublisher: changePublisher,
publishInterval: publishInterval,
fsEventProvider: FileChangeWatcherFSEventProvider(),
directoryChangePublisher: directoryChangePublisher
)
}
}