> On Aug 26, 2016, at 8: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?
> 
> I need to know because I have a requirement to create a backup copy of a file 
> once it exceeds a certain size. This backup is created when I first open the 
> file as a NSFileHandle. I can read the content of the file and find out the 
> size that way, but I’d rather not first read it into memory if I’m just going 
> to create my backup copy and then start over with an empty file - reading it 
> all in just to find the length seems a bit wrong, is all.

Seems reasonable enough.

You may need to use the Unix C api,  fstat() defined in <sys/stat.h>.
See the man page for that.



_______________________________________________

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

Reply via email to