What is the best way to copy files
What is the best way to copy files
- Subject: What is the best way to copy files
- From: David <email@hidden>
- Date: Sat, 10 Jan 2009 16:23:04 -0500
This is sort of a conceptual question.
The broader question is what is the purpose of Cocoa and how does it
relate to Core Foundation and Unix.
The specific question is, what is the best way to copy files. Several
different ways to copy files come to mind including:
Use Cocoa
- NSFileManager copyPath:toPath:handler:
- NSWorkspace performFileOperation:source:destination:files:tag: using
NSWorkspaceCopyOperation
- Manually copy blocks of data using NSFileHandle readDataOfLength:
and writeData:
Using core foundation
- Carbon's file manager. PSFSCopyFileAsync (or sync)
Using unix functions
- read, write
Unix standard C functions
- fread, fwrite
I'm looking for what I think are some fairly common requirements from
a file copy mechanism.
- simple. Why write something if you can reuse.
- support multi-threading so that you can stay responsive to the UI
while copying large files.
- good error handling. To be able to clearly handle and report errors.
- provides ways to control, ie cancel a large file copy in progress.
I didn't think this should be a difficult question, but I haven't
found an answer so far.
I've currently used NSFileManager in my application but have been
disappointed for several reasons:
1. I can't find a reasonable way to cancel a large file copy in progress.
2. The error reporting is very poor. Very little information is
provided on errors which may occur.
So I need to pick something else and would like suggestions on which
approach will provide the needed flexibility.
This also addresses a broader question I have about how Cocoa relates
to Core Foundation, to Unix APIs and even to standard C functions.
I had thought Cocoa was a wrapper for Core Foundation, but
NSFileManager is not a wrapper. There is no equivalent in Core
Foundation, while the Carbon file manager has no equivalent in Cocoa.
Are Unix APIs the best way to go?
Thanks
_______________________________________________
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