• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Write with NSFileWrapper vs. copy with NSFileManager
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Write with NSFileWrapper vs. copy with NSFileManager


  • Subject: Re: Write with NSFileWrapper vs. copy with NSFileManager
  • From: Mike Abdullah <email@hidden>
  • Date: Tue, 25 Mar 2014 17:20:04 +0000

On 25 Mar 2014, at 12:52, Colas B <email@hidden> wrote:

> Hi, I am having troubles using NSFileWrapper. In order to have a better understanding of it, I would like to ask you the following question.
>
> Is there a difference between
>
>     NSURL *referenceURL, *destinationURL ;
>
>     [[[NSFileManager alloc] init] copyItemAtURL:referenceURL
>                                           toURL:destinationURL
>                                           error:NULL] ;
>
> and
>
>     NSURL *referenceURL, *destinationURL ;
>     NSFileWrapperWritingOptions options ;
>
>     NSFileWrapper * fileWrapper = [[NSFileWrapper alloc] initWithURL:referenceURL
>                                                              options:0
>                                                                error:NULL] ;
>     [fileWrapper writeToURL:destinationURL
>                     options:options
>         originalContentsURL:nil
>                       error:NULL] ;
>
>  (especially, depending on the values of options; what would be the best choice for options here?)?
>
> Again, I ask this question in order to understand better NSFileWrapper. I see that I have the choice in my code to use one or the other. I guess the answer might involve considerations about "hard links".

Yes, there's a difference.

NSFileManager will copy the file/folder in whatever manner it sees fit. Internally this is likely to be by copying chunks of the file(s) into memory and then writing that back out.

NSFileWrapper, with the arguments you've specified will instead read the entire file/folder into memory, and then write that back out to disk. That data will be kept in memory until the file wrapper is deallocated, or you explicitly ask it to read from disk again.


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Write with NSFileWrapper vs. copy with NSFileManager
      • From: Jens Alfke <email@hidden>
References: 
 >Write with NSFileWrapper vs. copy with NSFileManager (From: Colas B <email@hidden>)

  • Prev by Date: Re: Simulating sublayers in CATiledLayer
  • Next by Date: Re: Write with NSFileWrapper vs. copy with NSFileManager
  • Previous by thread: Write with NSFileWrapper vs. copy with NSFileManager
  • Next by thread: Re: Write with NSFileWrapper vs. copy with NSFileManager
  • Index(es):
    • Date
    • Thread