In article
<42c24225$0$845$61c65585@uq-127creek-reader-03.brisbane.pipenetworks.com
..au>,
"pf" <P.Fredlein.RemoveThis@NOSPAMuq.net.au> wrote:
> Hi,
>
> I'm considering using Cocoa rather than Carbon...
>
> How do I init an NSData object with data from a file *but* only from x bytes
> in with a length of y bytes into the file? I don't want to read the whole
> file into one data object then copy x bytes into another NSData object.
+ (id)dataWithContentsOfMappedFile:(NSString *)path can create an NSData
that simply references the file. So you could...
NSData* theChunk = [[NSData dataWithContentsOfMappedFile:@"foo"]
subdataWithRange:NSMakeRange(theStart, theLength)];
> NSFile doesn't seem to be what I thought - similar to MFC's CFile...
I don't know what NSFile is. NSFileHandle might be what you're looking
for.
NSFileHandle* theFile = [NSFileHandle fileHandleForReadingAtPath:@"foo"];
[theFile seekToFileOffset:theStart];
NSData* theChunk = [theFile readDataOfLength:theLength];
G
--
Goal 2005: Convincing James Hetfield to cover the Strawberry Shortcake
"Are You Berry Berry Happy?" song.