2019-09-20 09:07:41 +00:00
|
|
|
/* Definition of class NSFileCoordinator
|
|
|
|
Copyright (C) 2019 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Implemented by: Gregory Casamento <greg.casamento@gmail.com>
|
|
|
|
Date: Sep 2019
|
|
|
|
Original File by: Daniel Ferreira
|
|
|
|
|
|
|
|
This file is part of the GNUstep Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library; if not, write to the Free
|
|
|
|
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02111 USA.
|
|
|
|
*/
|
|
|
|
|
2017-06-21 00:03:43 +00:00
|
|
|
#ifndef __NSFileCoordinator_h_GNUSTEP_BASE_INCLUDE
|
|
|
|
#define __NSFileCoordinator_h_GNUSTEP_BASE_INCLUDE
|
|
|
|
|
|
|
|
#import <Foundation/NSObject.h>
|
2019-09-20 09:07:41 +00:00
|
|
|
#import <Foundation/NSURL.h>
|
2017-06-21 00:03:43 +00:00
|
|
|
|
|
|
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_7,GS_API_LATEST)
|
|
|
|
|
2019-09-20 09:07:41 +00:00
|
|
|
@class NSArray, NSError, NSMutableDictionary, NSOperationQueue, NSSet;
|
|
|
|
|
|
|
|
@protocol NSFilePresenter;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
NSFileCoordinatorReadingWithoutChanges = 1 << 0,
|
|
|
|
NSFileCoordinatorReadingResolvesSymbolicLink = 1 << 1,
|
|
|
|
NSFileCoordinatorReadingImmediatelyAvailableMetadataOnly = 1 << 2,
|
|
|
|
NSFileCoordinatorReadingForUploading = 1 << 3,
|
|
|
|
};
|
|
|
|
typedef NSUInteger NSFileCoordinatorReadingOptions;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
NSFileCoordinatorWritingForDeleting = 1 << 0,
|
|
|
|
NSFileCoordinatorWritingForMoving = 1 << 1,
|
|
|
|
NSFileCoordinatorWritingForMerging = 1 << 2,
|
|
|
|
NSFileCoordinatorWritingForReplacing = 1 << 3,
|
|
|
|
NSFileCoordinatorWritingContentIndependentMetadataOnly = 1 << 4,
|
|
|
|
};
|
|
|
|
typedef NSUInteger NSFileCoordinatorWritingOptions;
|
|
|
|
|
2017-06-21 00:03:43 +00:00
|
|
|
@interface NSFileAccessIntent : NSObject
|
2019-09-20 09:07:41 +00:00
|
|
|
{
|
2019-09-21 00:00:45 +00:00
|
|
|
NSURL *_url;
|
|
|
|
BOOL _isRead;
|
|
|
|
NSInteger _options;
|
2019-09-20 09:07:41 +00:00
|
|
|
}
|
|
|
|
+ (instancetype) readingIntentWithURL: (NSURL *)url
|
|
|
|
options: (NSFileCoordinatorReadingOptions)options;
|
|
|
|
+ (instancetype) writingIntentWithURL: (NSURL *)url
|
|
|
|
options: (NSFileCoordinatorWritingOptions)options;
|
|
|
|
- (NSURL *) URL;
|
2017-06-21 00:03:43 +00:00
|
|
|
@end
|
|
|
|
|
2019-09-20 09:07:41 +00:00
|
|
|
DEFINE_BLOCK_TYPE(GSNoEscapeReadWriteHandler, void, NSURL*, NSURL*);
|
|
|
|
DEFINE_BLOCK_TYPE(GSNoEscapeNewURLHandler, void, NSURL*);
|
|
|
|
DEFINE_BLOCK_TYPE(GSAccessorCallbackHandler, void, NSError*);
|
|
|
|
DEFINE_BLOCK_TYPE(GSDualWriteURLCallbackHandler, void, NSURL*, NSURL*);
|
|
|
|
DEFINE_BLOCK_TYPE_NO_ARGS(GSBatchAccessorHandler, void);
|
|
|
|
DEFINE_BLOCK_TYPE(GSAccessorHandlerBlock, void, GSBatchAccessorHandler);
|
|
|
|
|
2017-06-21 00:03:43 +00:00
|
|
|
@interface NSFileCoordinator : NSObject
|
2019-09-20 09:07:41 +00:00
|
|
|
{
|
2019-09-21 00:00:45 +00:00
|
|
|
id _accessArbiter;
|
|
|
|
id _fileReactor;
|
2019-09-23 03:26:30 +00:00
|
|
|
id _purposeIdentifier;
|
2019-09-21 00:00:45 +00:00
|
|
|
NSURL *_recentFilePresenterURL;
|
|
|
|
id _accessClaimIDOrIDs;
|
|
|
|
BOOL _isCancelled;
|
|
|
|
NSMutableDictionary *_movedItems;
|
2019-09-20 09:07:41 +00:00
|
|
|
}
|
2017-06-21 00:03:43 +00:00
|
|
|
|
2019-09-20 09:07:41 +00:00
|
|
|
+ (NSArray *) filePresenters;
|
|
|
|
|
|
|
|
- (NSString *) purposeIdentifier;
|
|
|
|
|
|
|
|
- (void) setPurposeIdentifier: (NSString *)ident; // copy
|
|
|
|
|
|
|
|
- (void)cancel;
|
|
|
|
|
|
|
|
- (void)coordinateAccessWithIntents: (NSArray *)intents
|
|
|
|
queue: (NSOperationQueue *)queue
|
|
|
|
byAccessor: (GSAccessorCallbackHandler)accessor;
|
|
|
|
|
|
|
|
- (void)coordinateReadingItemAtURL: (NSURL *)readingURL
|
|
|
|
options: (NSFileCoordinatorReadingOptions)readingOptions
|
|
|
|
writingItemAtURL: (NSURL *)writingURL
|
|
|
|
options: (NSFileCoordinatorWritingOptions)writingOptions
|
|
|
|
error: (NSError **)outError
|
|
|
|
byAccessor: (GSNoEscapeReadWriteHandler)readerWriter;
|
|
|
|
|
|
|
|
- (void)coordinateReadingItemAtURL: (NSURL *)url
|
|
|
|
options: (NSFileCoordinatorReadingOptions)options
|
|
|
|
error: (NSError **)outError
|
|
|
|
byAccessor: (GSNoEscapeNewURLHandler)reader;
|
|
|
|
|
|
|
|
- (void)coordinateWritingItemAtURL: (NSURL *)url
|
|
|
|
options: (NSFileCoordinatorWritingOptions)options error:(NSError **)outError
|
|
|
|
byAccessor: (GSNoEscapeNewURLHandler)writer;
|
|
|
|
|
|
|
|
- (void)coordinateWritingItemAtURL: (NSURL *)url1
|
|
|
|
options: (NSFileCoordinatorWritingOptions)options1
|
|
|
|
writingItemAtURL: (NSURL *)url2
|
|
|
|
options: (NSFileCoordinatorWritingOptions)options2
|
|
|
|
error: (NSError **)outError
|
|
|
|
byAccessor: (GSDualWriteURLCallbackHandler)writer;
|
|
|
|
|
|
|
|
- (void)itemAtURL:(NSURL *)oldURL didMoveToURL: (NSURL *)newURL;
|
|
|
|
|
|
|
|
- (void)itemAtURL:(NSURL *)oldURL willMoveToURL: (NSURL *)newURL;
|
|
|
|
|
|
|
|
- (void)itemAtURL:(NSURL *)url didChangeUbiquityAttributes: (NSSet *)attributes;
|
|
|
|
|
|
|
|
- (void)prepareForReadingItemsAtURLs: (NSArray *)readingURLs
|
|
|
|
options: (NSFileCoordinatorReadingOptions)readingOptions
|
|
|
|
writingItemsAtURLs: (NSArray *)writingURLs
|
|
|
|
options: (NSFileCoordinatorWritingOptions)writingOptions
|
|
|
|
error: (NSError **)outError
|
|
|
|
byAccessor: (GSAccessorHandlerBlock)batchAccessor;
|
|
|
|
@end
|
|
|
|
|
2017-06-21 00:03:43 +00:00
|
|
|
#endif
|
|
|
|
#endif
|