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.
You want the hidden member of a
statresult calledst_blocks.The file in question has about 10 MB in the resource fork, which shows up in the result from
statbut in a "hidden" attribute. (Bonus points for anyone who knows exactly which file this is.) Note that it is documented inman 2 statthat thest_blocksattribute always measures increments of 512 bytes.Note:
st_sizemeasures the number of bytes of data, butst_blocksmeasures size on disk including the overhead from partially used blocks. So,Now if you do a "Get Info" in the Finder, you'll see that the file has: