• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Getting the "real" file size
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting the "real" file size


  • Subject: Re: Getting the "real" file size
  • From: Nicholas Riley <email@hidden>
  • Date: Mon, 30 Jun 2003 18:46:35 -0500
  • Mail-followup-to: Bryan Lund <email@hidden>, email@hidden

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.

  • Follow-Ups:
    • Re: Getting the "real" file size
      • From: Nicholas Riley <email@hidden>
References: 
 >Getting the "real" file size (From: Bryan Lund <email@hidden>)

  • Prev by Date: Getting the "real" file size
  • Next by Date: Re: Getting the "real" file size
  • Previous by thread: Getting the "real" file size
  • Next by thread: Re: Getting the "real" file size
  • Index(es):
    • Date
    • Thread