On Aug 26, 2016, at 10:19 PM, Graham Cox <graham....@bigpond.com> wrote: > > Apparently a simple task, but no obvious API for it: getting the length > (size) of a file I have a NSFileHandle for. This class has no -length > property, so how can I get it?
The reason it has no length property is because not all NSFileHandles have the concept of a length. For example, a file handle associated with a pipe or socket. For an on-disk file, you can seekToEndOfFile and get offsetInFile to determine the file length. If you need to not perturb the file position, you can record the original offsetInFile and then seekToFileOffset:origOffset to restore it after measuring the length. Matthew Emerson's suggestion of using fstat() with the fileDescriptor is also reasonable. Regards, Ken _______________________________________________ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com