mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
NSFileManager: create NSFileManagerDelegate
Create NSFileManagerDelegate, a more modern manner to verify whether to proceed a file operation after an error or whether an operation should actually be performed by NSFileManager. No functionality using the delegate is yet implemented.
This commit is contained in:
parent
2ec3c7bc27
commit
3111003ca1
2 changed files with 93 additions and 1 deletions
|
@ -191,6 +191,8 @@ extern "C" {
|
|||
@class NSError;
|
||||
@class NSURL;
|
||||
|
||||
@protocol NSFileManagerDelegate;
|
||||
|
||||
/* MacOS-X defines OSType as a 32bit unsigned integer.
|
||||
*/
|
||||
#ifndef OSTYPE_DECLARED
|
||||
|
@ -210,6 +212,7 @@ typedef NSUInteger NSDirectoryEnumerationOptions;
|
|||
{
|
||||
#if GS_EXPOSE(NSFileManager)
|
||||
@private
|
||||
id<NSFileManagerDelegate> _delegate;
|
||||
NSString *_lastError;
|
||||
#endif
|
||||
#if GS_NONFRAGILE
|
||||
|
@ -229,6 +232,15 @@ typedef NSUInteger NSDirectoryEnumerationOptions;
|
|||
*/
|
||||
+ (NSFileManager*) defaultManager;
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
|
||||
#if GS_HAS_DECLARED_PROPERTIES
|
||||
@property (assign) id<NSFileManagerDelegate> delegate;
|
||||
#else
|
||||
- (id<NSFileManagerDelegate>) delegate;
|
||||
- (void) setDelegate: (id<NSFileManagerDelegate>)delegate;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
|
||||
- (NSDictionary *) attributesOfItemAtPath: (NSString*)path
|
||||
error: (NSError**)error;
|
||||
|
@ -444,6 +456,7 @@ typedef NSUInteger NSDirectoryEnumerationOptions;
|
|||
* if they wish to deal with copy and move operations performed
|
||||
* by NSFileManager.
|
||||
*/
|
||||
|
||||
@interface NSObject (NSFileManagerHandler)
|
||||
/**
|
||||
* <p>When an error occurs during a copy or move operation, the file manager
|
||||
|
@ -495,7 +508,6 @@ typedef NSUInteger NSDirectoryEnumerationOptions;
|
|||
willProcessPath: (NSString*)path;
|
||||
@end
|
||||
|
||||
|
||||
/**
|
||||
* <p>This is a subclass of <code>NSEnumerator</code> which provides a full
|
||||
* listing of all the files beneath a directory and its subdirectories.
|
||||
|
@ -659,6 +671,77 @@ GS_EXPORT NSString* const NSFileSystemFreeNodes;
|
|||
- (NSUInteger) fileSystemFileNumber;
|
||||
@end
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5,GS_API_LATEST)
|
||||
|
||||
@protocol NSFileManagerDelegate <NSObject>
|
||||
#if GS_PROTOCOLS_HAVE_OPTIONAL
|
||||
@optional
|
||||
#else
|
||||
@end
|
||||
@interface NSObject (NSFileManagerDelegate)
|
||||
#endif
|
||||
- (BOOL)fileManager: (NSFileManager *)fileManager
|
||||
shouldCopyItemAtPath: (NSString *)srcPath
|
||||
toPath: (NSString *)dstPath;
|
||||
- (BOOL)fileManager: (NSFileManager *)fileManager
|
||||
shouldCopyItemAtURL: (NSURL *)srcURL
|
||||
toURL: (NSURL *)dstURL;
|
||||
|
||||
- (BOOL)fileManager: (NSFileManager *)fileManager
|
||||
shouldProceedAfterError: (NSError *)error
|
||||
copyingItemAtPath: (NSString *)srcPath
|
||||
toPath: (NSString *)dstPath;
|
||||
- (BOOL)fileManager: (NSFileManager *)fileManager
|
||||
shouldProceedAfterError: (NSError *)error
|
||||
copyingItemAtURL: (NSURL *)srcURL
|
||||
toURL: (NSURL *)dstURL;
|
||||
|
||||
- (BOOL)fileManager: (NSFileManager *)fileManager
|
||||
shouldMoveItemAtPath: (NSString *)srcPath
|
||||
toPath: (NSString *)dstPath;
|
||||
- (BOOL)fileManager: (NSFileManager *)fileManager
|
||||
shouldMoveItemAtURL: (NSURL *)srcURL
|
||||
toURL: (NSURL *)dstURL;
|
||||
|
||||
- (BOOL)fileManager: (NSFileManager *)fileManager
|
||||
shouldProceedAfterError: (NSError *)error
|
||||
movingItemAtPath: (NSString *)srcPath
|
||||
toPath: (NSString *)dstPath;
|
||||
- (BOOL)fileManager: (NSFileManager *)fileManager
|
||||
shouldProceedAfterError: (NSError *)error
|
||||
movingItemAtURL: (NSURL *)srcURL
|
||||
toURL: (NSURL *)dstURL;
|
||||
|
||||
- (BOOL)fileManager: (NSFileManager *)fileManager
|
||||
shouldLinkItemAtPath: (NSString *)srcPath
|
||||
toPath: (NSString *)dstPath;
|
||||
- (BOOL)fileManager: (NSFileManager *)fileManager
|
||||
shouldLinkItemAtURL: (NSURL *)srcURL
|
||||
toURL: (NSURL *)dstURL;
|
||||
|
||||
- (BOOL)fileManager: (NSFileManager *)fileManager
|
||||
shouldProceedAfterError: (NSError *)error
|
||||
linkingItemAtPath: (NSString *)srcPath
|
||||
toPath: (NSString *)dstPath;
|
||||
- (BOOL)fileManager: (NSFileManager *)fileManager
|
||||
shouldProceedAfterError: (NSError *)error
|
||||
linkingItemAtURL: (NSURL *)srcURL
|
||||
toURL: (NSURL *)dstURL;
|
||||
|
||||
- (BOOL)fileManager: (NSFileManager *)fileManager
|
||||
shouldRemoveItemAtPath: (NSString *)path;
|
||||
- (BOOL)fileManager: (NSFileManager *)fileManager
|
||||
shouldRemoveItemAtURL: (NSURL *)URL;
|
||||
- (BOOL)fileManager: (NSFileManager *)fileManager
|
||||
shouldProceedAfterError: (NSError *)error
|
||||
removingItemAtPath: (NSString *)path;
|
||||
- (BOOL)fileManager: (NSFileManager *)fileManager
|
||||
shouldProceedAfterError: (NSError *)error
|
||||
removingItemAtURL: (NSURL *)URL;
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -356,6 +356,15 @@ static NSStringEncoding defaultEncoding;
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id<NSFileManagerDelegate>) delegate
|
||||
{
|
||||
return _delegate;
|
||||
}
|
||||
|
||||
- (void) setDelegate: (NSFileManager *)delegate {
|
||||
_delegate = delegate;
|
||||
}
|
||||
|
||||
- (BOOL) changeCurrentDirectoryPath: (NSString*)path
|
||||
{
|
||||
static Class bundleClass = 0;
|
||||
|
|
Loading…
Reference in a new issue