Protocol: NSFileManagerDelegate

Overview

The NSFileManagerDelegate protocol defines optional methods for managing operations involving the copying, moving, linking, or removal of files and directories. When you use an NSFileManager object to initiate a copy, move, link, or remove operation, the file manager asks its delegate whether the operation should begin at all and whether it should proceed when an error occurs.Asks the delegate if the file manager should copy the specified item to the new path.Asks the delegate if the file manager should copy the specified item to the new URL.Asks the delegate if a hard link should be created between the items at the two paths. Asks the delegate if a hard link should be created between the items at the two URLs.Asks the delegate if the file manager should move the specified item to the new path.Asks the delegate if the file manager should move the specified item to the new URL. Asks the delegate if the move operation should continue after an error occurs while copying the item at the specified path.Asks the delegate if the move operation should continue after an error occurs while copying the item at the specified URL.Asks the delegate if the operation should continue after an error occurs while linking to the item at the specified path.Asks the delegate if the operation should continue after an error occurs while linking to the item at the specified URL.Asks the delegate if the move operation should continue after an error occurs while moving the item at the specified path.Asks the delegate if the move operation should continue after an error occurs while moving the item at the specified URL. Asks the delegate if the operation should continue after an error occurs while removing the item at the specified path.Asks the delegate if the operation should continue after an error occurs while removing the item at the specified URL.Asks the delegate whether the item at the specified path should be deleted. Asks the delegate whether the item at the specified URL should be deleted.

Instance Method Summary (collapse)

Instance Method Details

- (Boolean) fileManager(fileManager, shouldCopyItemAtPath:srcPath, toPath:dstPath)

Asks the delegate if the file manager should copy the specified item to the new path. This method is called once for each item that needs to be copied. Thus, for a directory, this method is called once for the directory and once for each item in the directory.This method performs the same task as the fileManager:shouldCopyItemAtURL:toURL: method, which is preferred over this method in OS X v10.6 and later.

Parameters:

  • fileManager (NSFileManager)

    The file manager object that is attempting to copy the file or directory.

  • srcPath (String)

    The path to the file or directory that the file manager wants to copy.

  • dstPath (String)

    The new path for the copied file or directory.

Returns:

  • (Boolean)

    YES if the item should be copied or NO if the file manager should stop copying items associated with the current operation. If you do not implement this method, the file manager assumes a response of YES.

- (Boolean) fileManager(fileManager, shouldCopyItemAtURL:srcURL, toURL:dstURL)

Asks the delegate if the file manager should copy the specified item to the new URL. This method is called once for each item that needs to be copied. Thus, for a directory, this method is called once for the directory and once for each item in the directory.This method performs the same task as the fileManager:shouldCopyItemAtPath:toPath: method and is preferred over that method in OS X v10.6 and later.

Parameters:

  • fileManager (NSFileManager)

    The file manager object that is attempting to copy the file or directory.

  • srcURL (NSURL)

    The URL of the file or directory that the file manager wants to copy.

  • dstURL (NSURL)

    The URL specifying the location for the copied file or directory.

Returns:

  • (Boolean)

    YES if the item should be copied or NO if the file manager should stop copying items associated with the current operation. If you do not implement this method, the file manager assumes a response of YES.

- (Boolean) fileManager(fileManager, shouldLinkItemAtPath:srcPath, toPath:dstPath)

Asks the delegate if a hard link should be created between the items at the two paths. If the item specified by destURL is a directory, returning NO prevents links from being created to both the directory and its children.This method performs the same task as the fileManager:shouldLinkItemAtURL:toURL: method, which is preferred over this method in OS X v10.6 and later.

Parameters:

  • fileManager (NSFileManager)

    The file manager object that is attempting to create the link.

  • srcPath (String)

    The path or a file or directory that fileManager is about to attempt to link.

  • dstPath (String)

    The path or a file or directory to which fileManager is about to attempt to link.

Returns:

  • (Boolean)

    YES if the operation should proceed, otherwise NO.

- (Boolean) fileManager(fileManager, shouldLinkItemAtURL:srcURL, toURL:dstURL)

Asks the delegate if a hard link should be created between the items at the two URLs. If the item specified by destURL is a directory, returning NO prevents links from being created to both the directory and its children.This method performs the same task as the fileManager:shouldLinkItemAtPath:toPath: method and is preferred over that method in OS X v10.6 and later.

Parameters:

  • fileManager (NSFileManager)

    The file manager object that is attempting to create the link.

  • srcURL (NSURL)

    The URL identifying the new hard link to be created.

  • dstURL (NSURL)

    The URL identifying the destination of the link.

Returns:

  • (Boolean)

    YES if the link should be created or NO if it should not be created.

- (Boolean) fileManager(fileManager, shouldMoveItemAtPath:srcPath, toPath:dstPath)

Asks the delegate if the file manager should move the specified item to the new path. This method is called only once for the item being moved, regardless of whether the item is a file, directory, or symbolic link.This method performs the same task as the fileManager:shouldMoveItemAtURL:toURL: method, which is preferred over this method in OS X v10.6 and later.

Parameters:

  • fileManager (NSFileManager)

    The file manager object that is attempting to move the file or directory.

  • srcPath (String)

    The path to the file or directory that the file manager wants to move.

  • dstPath (String)

    The new path for the file or directory.

Returns:

  • (Boolean)

    YES if the operation should proceed, otherwise NO. If you do not implement this method, the file manager assumes a response of YES.

- (Boolean) fileManager(fileManager, shouldMoveItemAtURL:srcURL, toURL:dstURL)

Asks the delegate if the file manager should move the specified item to the new URL. This method is called only once for the item being moved, regardless of whether the item is a file, directory, or symbolic link.This method performs the same task as the fileManager:shouldMoveItemAtPath:toPath: method and is preferred over that method in OS X v10.6 and later.

Parameters:

  • fileManager (NSFileManager)

    The file manager object that is attempting to move the file or directory.

  • srcURL (NSURL)

    The URL of the file or directory that the file manager wants to move.

  • dstURL (NSURL)

    The URL specifying the new location for the file or directory.

Returns:

  • (Boolean)

    YES if the item should be moved or NO if it should not be moved. If you do not implement this method, the file manager assumes a response of YES.

- (Boolean) fileManager(fileManager, shouldProceedAfterError:error, copyingItemAtPath:srcPath, toPath:dstPath)

Asks the delegate if the move operation should continue after an error occurs while copying the item at the specified path. The file manager calls this method when there is a problem copying the item to the specified location. If you return YES, the file manager continues copying any other items and ignores the error.This method performs the same task as the fileManager:shouldProceedAfterError:copyingItemAtURL:toURL: method, which is preferred over this method in OS X v10.6 and later.

Parameters:

  • fileManager (NSFileManager)

    The NSFileManager object that sent this message.

  • error (NSError)

    The error that occurred during the attempt to copy.

  • srcPath (String)

    The path or a file or directory that fileManager is attempting to copy.

  • dstPath (String)

    The path or a file or directory to which fileManager is attempting to copy.

Returns:

  • (Boolean)

    YES if the operation should proceed or NO if it should be aborted. If you do not implement this method, the file manager assumes a response of NO.

- (Boolean) fileManager(fileManager, shouldProceedAfterError:error, copyingItemAtURL:srcURL, toURL:dstURL)

Asks the delegate if the move operation should continue after an error occurs while copying the item at the specified URL. The file manager calls this method when there is a problem copying the item to the specified location. If you return YES, the file manager continues copying any other items and ignores the error.This method performs the same task as the fileManager:shouldProceedAfterError:copyingItemAtPath:toPath: method and is preferred over that method in OS X v10.6 and later.

Parameters:

  • fileManager (NSFileManager)

    The file manager object that attempted to copy the item.

  • error (NSError)

    The error that occurred during the attempt to copy.

  • srcURL (NSURL)

    The URL or a file or directory that fileManager is attempting to copy.

  • dstURL (NSURL)

    The URL or a file or directory to which fileManager is attempting to copy.

Returns:

  • (Boolean)

    YES if the operation should proceed or NO if it should be aborted. If you do not implement this method, the file manager assumes a response of NO.

- (Boolean) fileManager(fileManager, shouldProceedAfterError:error, linkingItemAtPath:srcPath, toPath:dstPath)

Asks the delegate if the operation should continue after an error occurs while linking to the item at the specified path. The file manager calls this method when there is a problem creating a hard link to the item at the specified location. If you return YES, the file manager continues creating any other links associated with the current operation and ignores the error.This method performs the same task as the fileManager:shouldProceedAfterError:linkingItemAtURL:toURL: method, which is preferred over this method in OS X v10.6 and later.

Parameters:

  • fileManager (NSFileManager)

    The file manager object that attempted to create the link.

  • error (NSError)

    The error that occurred during the link attempt.

  • srcPath (String)

    The path to the attempted link location.

  • dstPath (String)

    The path to the file or directory that was the destination of the hard link.

Returns:

  • (Boolean)

    YES if the operation should proceed or NO if it should be aborted. If you do not implement this method, the file manager assumes a response of NO.

- (Boolean) fileManager(fileManager, shouldProceedAfterError:error, linkingItemAtURL:srcURL, toURL:dstURL)

Asks the delegate if the operation should continue after an error occurs while linking to the item at the specified URL. The file manager calls this method when there is a problem creating a hard link to the item at the specified location. If you return YES, the file manager continues creating any other links associated with the current operation and ignores the error.This method performs the same task as the fileManager:shouldProceedAfterError:linkingItemAtPath:toPath: method and is preferred over that method in OS X v10.6 and later.

Parameters:

  • fileManager (NSFileManager)

    The file manager object that attempted to create the link.

  • error (NSError)

    The error that occurred during the link attempt.

  • srcURL (NSURL)

    The URL of the attempted link location.

  • dstURL (NSURL)

    The URL of the file or directory that was the destination of the hard link.

Returns:

  • (Boolean)

    YES if the operation should proceed or NO if it should be aborted. If you do not implement this method, the file manager assumes a response of NO.

- (Boolean) fileManager(fileManager, shouldProceedAfterError:error, movingItemAtPath:srcPath, toPath:dstPath)

Asks the delegate if the move operation should continue after an error occurs while moving the item at the specified path. The file manager calls this method when there is a problem moving the item to the specified location. If you return YES, the file manager proceeds to remove the item from its current location as if the move operation had completed successfully. This method performs the same task as the fileManager:shouldProceedAfterError:movingItemAtURL:toURL: method, which is preferred over this method in OS X v10.6 and later.

Parameters:

  • fileManager (NSFileManager)

    The file manager object that attempted to move the item.

  • error (NSError)

    The error that occurred while trying to move the item in srcPath.

  • srcPath (String)

    The path of the file or directory that the file manager tried to move.

  • dstPath (String)

    The path of the intended destination for the item in srcPath.

Returns:

  • (Boolean)

    YES if the operation should proceed or NO if it should be aborted. If you do not implement this method, the file manager assumes a response of NO.

- (Boolean) fileManager(fileManager, shouldProceedAfterError:error, movingItemAtURL:srcURL, toURL:dstURL)

Asks the delegate if the move operation should continue after an error occurs while moving the item at the specified URL. The file manager calls this method when there is a problem moving the item to the specified location. If you return YES, the file manager proceeds to remove the item from its current location as if the move operation had completed successfully. This method performs the same task as the fileManager:shouldProceedAfterError:movingItemAtPath:toPath: method and is preferred over that method in OS X v10.6 and later.

Parameters:

  • fileManager (NSFileManager)

    The file manager object that attempted to move the item.

  • error (NSError)

    The error that occurred while trying to move the item in srcURL.

  • srcURL (NSURL)

    The URL of the file or directory that the file manager tried to move.

  • dstURL (NSURL)

    The URL of the intended destination for the item in srcURL.

Returns:

  • (Boolean)

    YES if the operation should proceed or NO if it should be aborted. If you do not implement this method, the file manager assumes a response of NO.

- (Boolean) fileManager(fileManager, shouldProceedAfterError:error, removingItemAtPath:path)

Asks the delegate if the operation should continue after an error occurs while removing the item at the specified path. The file manager calls this method when there is a problem deleting the item to the specified location. If you return YES, the file manager continues deleting any remaining items and ignores the error.This method performs the same task as the fileManager:shouldProceedAfterError:removingItemAtURL: method, which is preferred over this method in OS X v10.6 and later.

Parameters:

  • fileManager (NSFileManager)

    The file manager object that attempted to remove the item.

  • error (NSError)

    The error that occurred during the attempt to copy.

  • path (String)

    The path for the file or directory that the file manager tried to delete.

Returns:

  • (Boolean)

    YES if the operation should proceed or NO if it should be aborted. If you do not implement this method, the file manager assumes a response of NO.

- (Boolean) fileManager(fileManager, shouldProceedAfterError:error, removingItemAtURL:URL)

Asks the delegate if the operation should continue after an error occurs while removing the item at the specified URL. The file manager calls this method when there is a problem deleting the item to the specified location. If you return YES, the file manager continues deleting any remaining items and ignores the error.This method performs the same task as the fileManager:shouldProceedAfterError:removingItemAtPath: method and is preferred over that method in OS X v10.6 and later.

Parameters:

  • fileManager (NSFileManager)

    The file manager object that attempted to remove the item.

  • error (NSError)

    The error that occurred while attempting to remove the item at URL.

  • URL (NSURL)

    The URL for the file or directory that the file manager tried to delete.

Returns:

  • (Boolean)

    YES if the operation should proceed or NO if it should be aborted. If you do not implement this method, the file manager assumes a response of NO.

- (Boolean) fileManager(fileManager, shouldRemoveItemAtPath:path)

Asks the delegate whether the item at the specified path should be deleted. Removed items are deleted immediately and not placed in the Trash. If the specified item is a directory, returning NO prevents both the directory and its children from being deleted. This method performs the same task as the fileManager:shouldRemoveItemAtURL: method, which is preferred over this method in OS X v10.6 and later.

Parameters:

  • fileManager (NSFileManager)

    The file manager object that is attempting to remove the file or directory.

  • path (String)

    The path to the file or directory that the file manager is attempting to delete.

Returns:

  • (Boolean)

    YES if the specified item should be deleted or NO if it should not be deleted.

- (Boolean) fileManager(fileManager, shouldRemoveItemAtURL:URL)

Asks the delegate whether the item at the specified URL should be deleted. Removed items are deleted immediately and not placed in the Trash. If the specified item is a directory, returning NO prevents both the directory and its children from being deleted.This method performs the same task as the fileManager:shouldRemoveItemAtPath: method and is preferred over that method in OS X v10.6 and later.

Parameters:

  • fileManager (NSFileManager)

    The file manager object that is attempting to remove the file or directory.

  • URL (NSURL)

    The URL indicating the file or directory that the file manager is attempting to delete.

Returns:

  • (Boolean)

    YES if the specified item should be removed or NO if it should not be removed.