Skip to content

Commit 047a1a8

Browse files
add URL and file name to FolderContentChangeEvent
1 parent ee7e2e3 commit 047a1a8

4 files changed

Lines changed: 35 additions & 12 deletions

File tree

Example/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
3535
Monitoring.folderMonitor(url: url)
3636
.subscribeOn(MainScheduler.asyncInstance)
3737
.subscribe(onNext: { event in
38-
self.report("change in \(event) (\(event.change))")
38+
self.report("\(event.filename) changed (\(event.change))")
3939
})
4040
.addDisposableTo(disposeBag)
4141
}

RxFileMonitor.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
5096B2B91DD2217900076058 /* RxSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5096B2B61DD2216B00076058 /* RxSwift.framework */; };
1414
5096B2BA1DD2217900076058 /* RxSwift.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 5096B2B61DD2216B00076058 /* RxSwift.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
1515
5096B2BC1DD221D700076058 /* Monitoring.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5096B2BB1DD221D700076058 /* Monitoring.swift */; };
16+
5096B2C11DD22D6000076058 /* FolderContentChangeEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5096B2C01DD22D6000076058 /* FolderContentChangeEvent.swift */; };
1617
50E8354D1DD1B26900783B62 /* RxFileMonitor.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50E835431DD1B26900783B62 /* RxFileMonitor.framework */; };
1718
50E835521DD1B26900783B62 /* RxFileMonitorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50E835511DD1B26900783B62 /* RxFileMonitorTests.swift */; };
1819
50E835541DD1B26900783B62 /* RxFileMonitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 50E835461DD1B26900783B62 /* RxFileMonitor.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -61,6 +62,7 @@
6162
5096B2B41DD21D0B00076058 /* Change.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Change.swift; sourceTree = "<group>"; };
6263
5096B2B61DD2216B00076058 /* RxSwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RxSwift.framework; path = Carthage/Build/Mac/RxSwift.framework; sourceTree = "<group>"; };
6364
5096B2BB1DD221D700076058 /* Monitoring.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Monitoring.swift; sourceTree = "<group>"; };
65+
5096B2C01DD22D6000076058 /* FolderContentChangeEvent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FolderContentChangeEvent.swift; sourceTree = "<group>"; };
6466
50E835431DD1B26900783B62 /* RxFileMonitor.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = RxFileMonitor.framework; sourceTree = BUILT_PRODUCTS_DIR; };
6567
50E835461DD1B26900783B62 /* RxFileMonitor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RxFileMonitor.h; sourceTree = "<group>"; };
6668
50E835471DD1B26900783B62 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@@ -112,6 +114,7 @@
112114
50E8356E1DD1BAEE00783B62 /* FileMonitor.swift */,
113115
50E835751DD1D1C200783B62 /* FolderContentMonitor.swift */,
114116
5096B2B41DD21D0B00076058 /* Change.swift */,
117+
5096B2C01DD22D6000076058 /* FolderContentChangeEvent.swift */,
115118
);
116119
name = Monitors;
117120
sourceTree = "<group>";
@@ -317,6 +320,7 @@
317320
buildActionMask = 2147483647;
318321
files = (
319322
50E835761DD1D1C200783B62 /* FolderContentMonitor.swift in Sources */,
323+
5096B2C11DD22D6000076058 /* FolderContentChangeEvent.swift in Sources */,
320324
5096B2BC1DD221D700076058 /* Monitoring.swift in Sources */,
321325
50E8356F1DD1BAEE00783B62 /* FileMonitor.swift in Sources */,
322326
5096B2B51DD21D0B00076058 /* Change.swift in Sources */,
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//
2+
// FolderContentChangeEvent.swift
3+
// RxFileMonitor
4+
//
5+
// Created by Christian Tietze on 08/11/16.
6+
// Copyright © 2016 CleanCocoa. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
public struct FolderContentChangeEvent: CustomStringConvertible {
12+
13+
public let eventId: FSEventStreamEventId
14+
public let eventPath: String
15+
public let change: Change
16+
17+
public var url: URL {
18+
return URL(fileURLWithPath: eventPath)
19+
}
20+
21+
public var filename: String {
22+
23+
return url.lastPathComponent
24+
}
25+
26+
public var description: String {
27+
28+
return "\(eventPath) (\(eventId)) changed: \(change)"
29+
}
30+
}

RxFileMonitor/FolderContentMonitor.swift

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,6 @@
88

99
import Foundation
1010

11-
public struct FolderContentChangeEvent: CustomStringConvertible {
12-
13-
public let eventId: FSEventStreamEventId
14-
public let eventPath: String
15-
public let change: Change
16-
17-
public var description: String {
18-
return "\(eventPath) (\(eventId)) changed: \(change)"
19-
}
20-
}
21-
2211
public class FolderContentMonitor {
2312

2413
let callback: (FolderContentChangeEvent) -> Void

0 commit comments

Comments
 (0)