Re: Size of a file on disk
Re: Size of a file on disk
- Subject: Re: Size of a file on disk
- From: Martin Wierschin <email@hidden>
- Date: Wed, 31 Aug 2011 16:57:26 -0700
>>> NSFileHandle *hndl = [NSFileHandle fileHandleForReadingAtPath:path];
>>> long long lngth = [hndl seekToEndOfFile];
>>>
>>> This gets you the length in bytes.
>>
>> And loads the entire file into memory!!
>
> Does it? I didn't think seek loaded anything, and it was just for random access.
Either way, I think avoiding NSFileHandle is the right thing to do. NSFileHandle implies a desire to read/write data. Who knows what the reading initializer does. Maybe it assigns a file descriptor (limited resource) right away, or does something silly like prefetch data into a buffer.
~Martin
_______________________________________________
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