• 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: Copying large files with progress indicator
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Copying large files with progress indicator


  • Subject: Re: Copying large files with progress indicator
  • From: Mike Abdullah <email@hidden>
  • Date: Tue, 1 Aug 2006 16:38:19 +0100


On 1 Aug 2006, at 02:33, Adam R. Maxwell wrote:


On Jul 31, 2006, at 17:06, Mike Abdullah wrote:

OK, that rather surprises me - why haven't Apple done a decent file copying system in Cocoa yet! Maybe I should file a request.

So, I downloaded MoreFilesX. It's readme says quite a bit about the HFD+ APIs. Am I right in thinking that the code will use the HFS+ if suitable, but that it will still work for non-HFS+ operations?

You might want to look at FSCopyObject; I think it's more modern (and easier to use) than MoreFilesX <http://developer.apple.com/ samplecode/FSCopyObject/index.html>. It loses xattrs on 10.4, though, unfortunately.


If you can require 10.4, take a look at FSCopyObjectAsync, which has a callback for periodic updates. These functions are only documented in the Files.h header, though.

-- Adam


10.4 only is fine for me. I've had a look at FSCopyObjectAsync, and after a search around, found Apple's nice FSFileOperation sample code:


http://developer.apple.com/samplecode/FSFileOperation/

I've got a quick simple project up and running using this, however, I wonder if someone could help clarify something for me. My code is:

- (IBAction)doCopy:(id)sender
{
OSStatus err;
FSRef sourceFileRef, destinationDirectoryRef;

// Build the parameters
FSFileOperationRef fileOp = FSFileOperationCreate(kCFAllocatorDefault);

FSPathMakeRef((UInt8 *)[@"/Users/dev/Desktop/test.dmg" fileSystemRepresentation], &sourceFileRef, NULL);

FSPathMakeRef((UInt8 *)[@"/Users/dev/Desktop/Copy/" fileSystemRepresentation], &destinationDirectoryRef, NULL);

OptionBits options = kFSFileOperationDefaultOptions;


// Do the copy
err = FSCopyObjectAsync(fileOp, &sourceFileRef, &destinationDirectoryRef, NULL, options, NULL, 0.01, NULL);

while (YES)
{
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 5.0, true);

CFDictionaryRef infoDict2;
(void) FSFileOperationCopyStatus(fileOp, NULL, NULL, &err, &infoDict2, NULL);

NSLog(@"%@", (NSDictionary *)infoDict2);
}
}


Now obviously, I need to do this in a separate thread which isn't a problem. However, what I don't really understand is what exactly goes on with the CFRunLoopRunInMode call. It seems that during the duration of this method, that's when a chunk of file copying is actually done, but once I stick the code in a thread, should I really use this, or is there something better?

Mike.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Copying large files with progress indicator
      • From: Shawn Erickson <email@hidden>
  • Prev by Date: Re: NSTabView and edit fields
  • Next by Date: NSScroller setFloatValue
  • Previous by thread: Re: Frameworks + sharedFrameworksPath
  • Next by thread: Re: Copying large files with progress indicator
  • Index(es):
    • Date
    • Thread