Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chris-huxtable/cbhfilesystemeventkit
An easier way to watch for file system events.
https://github.com/chris-huxtable/cbhfilesystemeventkit
fsevent fsevents objective-c objective-c-library
Last synced: 5 days ago
JSON representation
An easier way to watch for file system events.
- Host: GitHub
- URL: https://github.com/chris-huxtable/cbhfilesystemeventkit
- Owner: chris-huxtable
- License: isc
- Created: 2019-11-21T20:46:23.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-11-23T15:12:31.000Z (about 5 years ago)
- Last Synced: 2024-12-17T14:23:52.406Z (5 days ago)
- Topics: fsevent, fsevents, objective-c, objective-c-library
- Language: Objective-C
- Size: 24.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CBHFileSystemEventKit
[![release](https://img.shields.io/github/release/chris-huxtable/CBHFileSystemEventKit.svg)](https://github.com/chris-huxtable/CBHFileSystemEventKit/releases)
[![pod](https://img.shields.io/cocoapods/v/CBHFileSystemEventKit.svg)](https://cocoapods.org/pods/CBHFileSystemEventKit)
[![licence](https://img.shields.io/badge/licence-ISC-lightgrey.svg?cacheSeconds=2592000)](https://github.com/chris-huxtable/CBHFileSystemEventKit/blob/master/LICENSE)
[![coverage](https://img.shields.io/badge/coverage-98%25-brightgreen.svg?cacheSeconds=2592000)](https://github.com/chris-huxtable/CBHFileSystemEventKit)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:
```objective-c
// [...]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:
```objective-c
// [...]- (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](https://github.com/chris-huxtable/CBHFileSystemEventKit/blob/master/LICENSE).