Re: Getting the "real" file size
Re: Getting the "real" file size
On Mon, Jun 30, 2003 at 04:17:55PM -0700, Bryan Lund wrote:
>
I am attempting to get the size of a file using something akin to the
>
following :
>
>
NSNumber *fsize;
>
NSFileManager *manager = [[NSFileManager alloc] init];
>
NSDictionary *fattrs = [manager fileAttributesAtPath:[@"path to file"]
>
traverseLink:NO];
>
fsize = [fattrs objectForKey:NSFileSize];
>
>
However NSFileSize returns the file size that you get when you do an
>
"ls -l" in the terminal...not the file size as reported by the Finder.
>
Oftentimes these sizes are quite different.
>
>
Is there any way to retrieve the file size for a file so that it
>
matches what is seen in the Finder?
Yes, use FSGetCatalogInfo - you'll see fields in the FSCatalogInfo structure
which correspond to
An example of using this information is in my 'launch' tool; you can
see the source here (look at the printMoreInfoFromURL function):
<
http://svn.sabi.net/repos/dev/trunk/launch/launch/main.c>
--
=Nicholas Riley <email@hidden> | <
http://www.uiuc.edu/ph/www/njriley>
Pablo Research Group, Department of Computer Science and
Medical Scholars Program, University of Illinois at Urbana-Champaign
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.