forked from ReactiveCocoa/ReactiveCocoa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NSFileManager+RACSupport.h
46 lines (39 loc) · 1.71 KB
/
NSFileManager+RACSupport.h
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
// NSFileManager+RACSupport.h
// ReactiveCocoa
//
// Created by Josh Abernathy on 9/18/12.
// Copyright (c) 2012 GitHub, Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <ReactiveCocoa/ReactiveCocoa.h>
extern NSString * const RACNSFileManagerErrorDomain;
// An error occurred while trying to open the file at the URL.
extern const NSInteger RACNSFileManagerErrorCouldNotOpenFile;
// An error occurred while trying to create an event source for the file at the
// URL.
extern const NSInteger RACNSFileManagerErrorCouldNotCreateEventSource;
@interface NSFileManager (RACSupport)
// Creates a new signal that sends `URL` when the file changes. It sends an
// error if a problem occurred trying to watch the file, and sends completed if
// the file was deleted.
//
// If the file at the URL is overwritten, it will re-register for events for the
// new file and continue watching.
//
// Note that the distinction between deleted and overwritten is pretty weak and
// prone to race conditions. Depending on how the file is written, there could
// be a time between when a file is deleted and when the new file is written.
// In that case, the signal could complete as it thinks the file was deleted.
//
// Depending on how the signal's being used, callers could mitigate this by
// calling -repeat: and -retry: on the returned signal.
//
// Take care when watching bundles. Events can be delivered before the bundle is
// done being written. The FSEvents API might be a better alternative for that
// case.
//
// scheduler - the scheduler that should be used to send values on the returned
// signal. Should not be nil.
+ (RACSignal *)rac_watchForEventsForFileAtURL:(NSURL *)URL scheduler:(RACScheduler *)scheduler;
@end