macOS Icon Files Report Zero Bytes But Consume 60KB via Hidden Resource Forks
A developer building a disk storage analyser discovered that macOS creates a hidden file named 'Icon' followed by a carriage return (0x0D) in every folder with a custom icon. The file's data fork is genuinely empty, reporting zero bytes via standard size checks like st_size and os.path.getsize, yet it occupies around 60KB of real disk space stored in an Apple resource fork. This discrepancy exists because most programming languages and high-level APIs expose only st_size, which describes the data fork, while the actual disk usage is captured by st_blocks. The developer also warned that the carriage return in the filename can corrupt terminal progress lines, CI logs, and GUI labels by overwriting displayed text. The key takeaways are to sum st_blocks instead of st_size for accurate disk usage, and to strip control characters from file paths before rendering them.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in