Get data fork size through C/C++ without using deprecated FSCatalogInfo's dataLogicalSize field

85 Views Asked by At

I am working on removing the use of deprecated Carbon based API's in my application. I am unable to find a method to calculate the data fork size in C++ without using the deprecated FSCatalogInfo struct's dataLogicalSize. I found out that the keys available in NS File Manager based methods, return size without taking data fork size in account.

1

There are 1 best solutions below

1
AudioBubble On BEST ANSWER

-[NSFileManager attributesOfItemAtPath:error:] will return a dictionary containing the key NSFileSize (among others) with a value equivalent to the dataLogicalSize you're looking for. The size of any resource fork present on the file is not included -- I've specifically verified this against several old files with resource forks I had lying around. :)

As a practical matter, files you will encounter in modern macOS systems will virtually never have resource forks.