Re: Calculating file size
Re: Calculating file size
- Subject: Re: Calculating file size
- From: Jean-Daniel Dupas <email@hidden>
- Date: Mon, 28 Apr 2008 12:08:48 +0200
Le 28 avr. 08 à 11:27, Gerriet M. Denkmann a écrit :
On 28 Apr 2008, at 07:44, email@hidden wrote:
Others have answered with good suggestions for other APIs, but I will
point out for the record that you can do it in Cocoa, too, because
the
file system has a path-based mechanism in which "..namedfork/rsrc" is
appended to the path. For example, in Terminal:
$ ls -li Documents//Example.doc
108 -rw-r--r--@ 1 aburgh aburgh 23552 Apr 27 2006 Documents/
Example.doc
$ ls -li Documents/Example.doc/..namedfork/rsrc
108 -rw-r--r-- 1 aburgh aburgh 286 Apr 27 2006 Documents/
Example.doc/..namedfork/rsrc
Notice that the "inode" is the same (the Catalog Node ID on HFS+),
but
size reflects the different forks. You can use this technique from
any program that lets you specify a path, such as command line
utilities, and you can even read and write the contents of the forks
this way. This is documented in the Mac OS X system documentation.
Where exactly?
I have found a mention of "namedfork" in man RezWack and some
#defines in /usr/include/sys/paths.h - but no other documentation.
Kind regards,
Gerriet.
Relying on the ..namedfork "hack" is not a good idea. The way it
handles other FS than HFS changed a lot between major version. It's
not documented and may disapear in the futur.
If you do not have any requirement (using BSD API for example) you
should use the CoreServices File Manager or other "high-level" API.
That the most reliable way to do what you want.
_______________________________________________
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