Re: file reading/writing over 2 gig
Re: file reading/writing over 2 gig
- Subject: Re: file reading/writing over 2 gig
- From: Sherm Pendley <email@hidden>
- Date: Sun, 12 Aug 2007 03:35:55 -0400
On Aug 12, 2007, at 12:07 AM, Jaime Magiera wrote:
What is the preferred method for positional reading/writing of
files in Cocoa? For small files, NSFileHandle and NSData work
great. However, NSData caps at 2 gig. Is there another Cocoa solution?
NSFileHandle isn't "capped" at 2G - its -offsetInFile and -
seekToFileOffset: methods return and take unsigned long long ints,
respectively. So, one can read/write at any position within Files of
Unusual Size with no trouble.
NSFileHandle's -readDataOfLength: method, as well as NSData methods
that deal with offsets and sizes, do take and return unsigned longs,
because a 32-bit app can address "only" 4GB of memory at most. That's
what limits the amount of data you can read into memory at one time,
even though NSFileHandle will allow you to read that 4GB from any
position within a much larger file. That limitation applies to all 32-
bit apps, not just those that use Cocoa.
A 64-bit app can address much more memory, but deploying such a beast
has problems of its own. It requires a 64-bit processor, which limits
it to G5s and Mac Pros. Also, 64-bit support is currently limited to
BSD/POSIX functions only - neither Cocoa nor Carbon are currently 64-
bit. That means you'd need to factor your app into separate 32-bit
GUI and 64-bit "worker" processes, and implement some form of IPC to
communicate between them.
sherm--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
_______________________________________________
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