gpt4 book ai didi

objective-c - Cocoa api 报告的可用空间值不正确,我应该使用什么?

转载 作者:太空狗 更新时间:2023-10-30 03:54:50 24 4
gpt4 key购买 nike

有谁知道 Apple 的获取信息面板使用什么 API 来确定 Lion 中的可用空间?我试图获得 Apple 报告的相同可用空间的所有代码都失败了,甚至 Quick Look 也没有显示 Get Info 显示的相同空间。如果我删除一堆文件并尝试读取可用空间,这似乎会发生。

Incorrect free space on Lion

当我使用 NSFileManager -> NSFileSystemFreeSize 时,我得到 42918273024 字节

当我使用 NSURL -> NSURLVolumeAvailableCapacityKey 我得到 42918273024 字节

当我使用 statfs -> buffer.f_bsize * buffer.f_bfree 我得到 43180417024 字节

statfs 得到与 Quick Look 相似的结果,但我如何匹配 Get Info?

最佳答案

您可能会看到本地 Time Machine 快照备份的结果。以下引述来自以下 Apple 支持文章 - OS X Lion: About Time Machine's "local snapshots" on portable Macs :

Time Machine in OS X Lion includes a new feature called "local snapshots" that keeps copies of files you create, modify or delete on your internal disk. Local snapshots compliment regular Time Machine backups (that are stored on your external disk or Time Capsule) giving you a "safety net" for times when you might be away from your external backup disk or Time Capsule and accidentally delete a file.

文章最后说:

Note: You may notice a difference in available space statistics between Disk Utility, Finder, and Get Info inspectors. This is expected and can be safely ignored. The Finder displays the available space on the disk without accounting for the local snapshots, because local snapshots will surrender their disk space if needed.

看起来您尝试过的所有测量可用磁盘空间的编程方法都给出了磁盘上的真实可用空间值,而不是通过删除本地 Time Machine 备份可以提供的空间。我怀疑像 df 这样的命令行工具是否已经意识到本地 Time Machine 备份。

关于objective-c - Cocoa api 报告的可用空间值不正确,我应该使用什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11597397/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com