AP.
AP.

Reputation: 5323

OSX : get size on disk for a file/directory

I am looking for a way (the fastest, working for both files and directory and accurate) to get the size of disk (not the file size) of a file or directory, using either: - BSD functions - Carbon functions - Cocoa functions

Thanks !

Upvotes: 1

Views: 520

Answers (1)

Mark F
Mark F

Reputation: 457

If you have a file URL, you can use -[NSURL resourceValuesForKeys:error:] to get these values:

  • NSURLFileSizeKey; <-- file size in bytes
  • NSURLFileAllocatedSizeKey; <-- file size on disk

Upvotes: 2

Related Questions