On Nov 10, 2008, at 1:45 PM, David wrote:

I have NSFIleManager copying files in a secondary thread. The user can
select to cancel the copy.
Is there a way to force NSFileManager to stop copying a file? The
files could be of arbitrary size. A large file could take quite a
while to end. I currently check if the thread has been cancelled
between files, but I can't figure out how to stop it if its in the
middle of copying one file.

Is there a way to make NSFileManager stop a copy operation?
Is there a way to forcibly kill a thread and thereby stop NSFileManager?

Killing the thread is generally not a good solution, even if you can work it out with pthread functions. In your case, I'd switch to the Carbon File Manager [1] and its asynchronous copying functions. Specifically, look at FSCopyObjectAsync or FSPathCopyObjectAsync, which can evidently be cancelled with FSFileOperationCancel (I'm not sure if you also have to use FSFileOperationUnscheduleFromRunLoop).

--
Adam

[1] 
http://developer.apple.com/documentation/Carbon/Reference/File_Manager/Reference/reference.html

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to