ali-rantakari / trash

Small command-line program for OS X that moves files or folders to the trash.
570 stars 16 forks source link

updated string from bytes to use NSByteCountFormatter #26

Closed vsanthanam closed 6 years ago

vsanthanam commented 6 years ago

bytes, in the form of long long, are current converted to an NSString using a custom util function that assumes kilo = 1000. (As was the standard since macOS 10.6)

However, in macOS 10.8, Apple added the NSByteCountFormatter API to Foundation, which not only adds this functionality built in, but can also use the appropriate kilo value based on the OS it's currently running on. NSByteCountFormatter also supports storage increments greater than TB, incase anyone is every thing to trash a files more than 1000 TB in size 😂

I've updated the util file to check for the presence of NSByteCountFormatter and use it if possible, and if not to default to the legacy method.