Cocoa + CopyItemAtPath: toPath: fails when copying a folder from a removable storage

Discussion in 'Mac Programming' started by helloking, Nov 16, 2009.

  1. helloking macrumors newbie

    Joined:
    Nov 16, 2009
    #1
    Hi Guys
    I am trying to copy a folder from removable storage device to the local machine and i am using the function from NSFileManager class "copyItemAtPath: toPath:". It fails and the error description i get is as follows:

    Error Domain=NSPOSIXErrorDomain Code=1 UserInfo=0x12f49d90 "Operation could not be completed. Operation not permitted"

    I am able to copy files from removable storage device to the local machine using this method and i am also able to copy files and folders from local machine to removable storage usng the same method.

    It would be great if any of you guys can decipher the error and let me know the details of how to get around the error in this particular case.

    Thanks
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    Have you only tried it on the same device or a second device? Maybe something's wrong with that device. Does Finder let you do what you want to do? (just trying to rule out any weird OS issues. Really doubt there's a bug in the API but you never know.)
     
  3. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #3
    What is the removable storage device, exactly?

    What format is it in (HFS, FAT, other)?

    Are there any device-nodes, fifos, etc. on the storage device?

    What is the ownership and permissions on the device's items?

    Have you considered applying a search to narrow down exactly which file or item isn't being copied? For example, a simple recursive descent should narrow it down quickly.

    1. Scan the contents of the folder.
    2. For each folder, try copyItemAtPath: toPath to a test location.
    3. If it works, go to next item.
    4. If it fails, recursively apply 1-4 to the failing folder.
    5. If all sub-folders copy correctly, the problem lies with one of the non-folders in the directory (i.e. one of the items that wasn't copied in 2.
     

Share This Page