Skip to content
An easier way to watch for file system events.
Objective-C
Branch: master
Clone or download
Latest commit b1e989d Nov 23, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
CBHFileSystemEventKit.xcodeproj
CBHFileSystemEventKit
CBHFileSystemEventKitTests
.gitattributes
.gitignore
CBHFileSystemEventKit.podspec
LICENSE
README.md

README.md

CBHFileSystemEventKit

release pod licence coverage

An easier way to watch for file system events.

Use

The starting point of any use is CBHFileSystemWatcher. It is used to describe what kind of file system events you want to get and how/where you want to receive them. When an event matching the description occurs the callback is invoked and passed a CBHFileSystemEvent which describes where and what happened.

Examples:

Watch the contents of a directory with a block:

// [...]

NSString *path = @"/path/to/directory/to/watch";
CBHFileSystemWatcherType type = CBHFileSystemWatcherType_default;
id someContext = nil;

CBHFileSystemWatcher *watcher = [CBHFileSystemWatcher watcherOfPath:path withType:type andBlock:^(CBHFileSystemEvent *event) {
	// Do something with the event and someContext.
}];

// [...]

Watch the contents of a directory with an observer:

// [...]

- (void)watchPath
{
	NSString *path = @"/path/to/directory/to/watch";
	CBHFileSystemWatcherType type = CBHFileSystemWatcherType_default;
	SEL selector = @selector(_fileSystemEventOccurred:);
	id someContext = nil;

	_watcher = [CBHFileSystemWatcher watcherWithObserver:self andSelector:selector ofPath:path withType:type andObject:someContext];
}

- (void)_fileSystemEventOccurred:(CBHFileSystemEvent *)event
{
	id context = [event object];
	// Do something with the event.
}

// [...]

Licence

CBHFileSystemEventKit is available under the ISC license.

You can’t perform that action at this time.