@@ -39,6 +39,15 @@ extern "C" {
3939@class NSURL ;
4040#endif
4141
42+ enum {
43+ NSDataReadingMappedIfSafe = 1UL << 0 , // Suggests using memory mapping for the file if it can be done securely
44+ NSDataReadingUncached = 1UL << 1 , // Suggests avoiding file system caching for the read operation
45+ #if OS_API_VERSION(MAC_OS_X_VERSION_10_7,GS_API_LATEST)
46+ NSDataReadingMappedAlways = 1UL << 3 , // Strongly requests memory mapping the file; overrides MappedIfSafe if both are set
47+ #endif
48+ };
49+ typedef NSUInteger NSDataReadingOptions ;
50+
4251#if OS_API_VERSION(MAC_OS_X_VERSION_10_6,GS_API_LATEST)
4352enum {
4453 NSDataSearchBackwards = (1UL << 0 ),
@@ -95,9 +104,15 @@ GS_EXPORT_CLASS
95104 length : (NSUInteger )bufferSize
96105 freeWhenDone : (BOOL )shouldFree ;
97106#endif
107+ + (instancetype )dataWithContentsOfFile : (NSString *)path
108+ options : (NSDataReadingOptions )readOptionsMask
109+ error : (NSError **)errorPtr ;
98110+ (instancetype ) dataWithContentsOfFile : (NSString *)path ;
99111+ (instancetype ) dataWithContentsOfMappedFile : (NSString *)path ;
100112#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
113+ + (instancetype ) dataWithContentsOfURL : (NSURL *)url
114+ options : (NSDataReadingOptions )readOptionsMask
115+ error : (NSError **)errorPtr ;
101116+ (instancetype ) dataWithContentsOfURL : (NSURL *)url ;
102117#endif
103118+ (instancetype ) dataWithData : (NSData *)data ;
@@ -127,9 +142,15 @@ GS_EXPORT_CLASS
127142 freeWhenDone : (BOOL )shouldFree ;
128143#endif
129144- (instancetype ) initWithContentsOfFile : (NSString *)path ;
145+ - (instancetype ) initWithContentsOfFile : (NSString *) path
146+ options : (NSDataReadingOptions ) readOptionsMask
147+ error : (NSError **) errorPtr ;
130148- (instancetype ) initWithContentsOfMappedFile : (NSString *)path ;
131149#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
132150- (instancetype ) initWithContentsOfURL : (NSURL *)url ;
151+ - (instancetype ) initWithContentsOfURL : (NSURL *)url
152+ options : (NSDataReadingOptions )readOptionsMask
153+ error : (NSError **)errorPtr ;
133154#endif
134155- (instancetype ) initWithData : (NSData *)data ;
135156
0 commit comments