Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6643911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:06:20+00:00 2026-05-26T00:06:20+00:00

I had written a small utility for creating xml for any folder structure and

  • 0

I had written a small utility for creating xml for any folder structure and comparison of folders via generated xml that supports both win and Mac as platforms. However on Mac, recursively calculating folder size don’t adds up to total size. On investigation, it came that it is due to extended attributes and resource forks that were present on certain files.

Can anybody know how can I determine these extended attributes and resource forks and their size preferably in python. Currently, I am using os.path.getsize to determine the size of file and adding files size to determine folder size eventually.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:06:21+00:00Added an answer on May 26, 2026 at 12:06 am

    You want the hidden member of a stat result called st_blocks.

    >>> s = os.stat('some_file')
    >>> s
    posix.stat_result(st_mode=33261, st_ino=12583347, st_dev=234881026,
                      st_nlink=1, st_uid=1000, st_gid=20, st_size=9889973,
                      st_atime=1301371810, st_mtime=847731600, st_ctime=1301371422)
    >>> s.st_size / 1e6 # size of data fork only, in MB
    9.889973
    >>> x.st_blocks * 512e-6 # total size on disk, in MB
    20.758528
    

    The file in question has about 10 MB in the resource fork, which shows up in the result from stat but in a “hidden” attribute. (Bonus points for anyone who knows exactly which file this is.) Note that it is documented in man 2 stat that the st_blocks attribute always measures increments of 512 bytes.

    Note: st_size measures the number of bytes of data, but st_blocks measures size on disk including the overhead from partially used blocks. So,

    >>> open('file.txt', 'w').write('Hello, world!')
    13
    >>> s = os.stat('file.txt')
    >>> s.st_size
    13
    >>> s.st_blocks * 512
    4096
    

    Now if you do a “Get Info” in the Finder, you’ll see that the file has:

    Size: 4 KB on disk (13 bytes)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A small utility of mine that I made for personal use (written in C++)
I am a trying to learn C# .Net. I had written small (hobby) Analog
In Ruby I have often written a number of small classes, and had a
I've written a small Scheme interpreter in C#, and realised that the way I
I've written a small application that deals with the private stock market. I store
I recently inherited some code that someone else had written. I discovered that everywhere
I have had a small game (Written in C#) which I've built up over
I had written a small thread program when i compiled cc filename.c, i got
I had written a small client-server code where in I was sending integers and
I was glancing through some code I had written in my Perl class and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.