delphi - 计算目录大小的API? [英] delphi - calculate directory size API?

查看:169
本文介绍了delphi - 计算目录大小的API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都知道其他方法来获取一个直播员的大小,而不是用文件计数文件来计算它的大小?我对一些win32 API函数感兴趣我已经google了这个,但我没有找到相关信息,所以我在这里问。



PS:我知道如何使用findfirst和findnext计算目录大小,并且总和所有文件的大小。

解决方案

获取一个目录的大小是一个很大的问题,主要是因为它是您无法定义的。问题的例子:




  • 一些文件系统,包括Linux上的NTFS和大多数文件系统都支持硬链接的概念。也就是说,同一个文件可能会显示在多个地方。软链接(重分解点)也产生同样的问题。

  • Windows允许文件系统挂载到目录中。示例:C:\DriveD可能与D:\相同。

  • 您想要磁盘上的文件大小还是文件的实际大小? / li>
  • 您是否关心实际的DIRECTORY条目?他们还占用空间!

  • 您对无法访问的文件执行什么操作?或者您没有浏览权限的目录?你算这些吗?



考虑到这一切,意味着唯一可能的实现是递归实现。你可以写自己的,或者希望你找到一个现成的,但最终的表现会是一样的。


Anyone knows other way to get a directoy's size, than calculate it's size by counting file with file? I'm interested on some win32 API function. I've google it about this, but i didn't found relevant information so i'm asking here.

PS: I know how to calculate a directory size by using findfirst and findnext and sum all file's size.

解决方案

Getting the size of one directory is a pretty big problem, mostly because it's something you can't define. Examples of problems:

  • Some filesystems, including NTFS and most filesystems on Linux support the notion of "hard links". That is, the very same file may show up in multiple places. Soft links (reparse points) pose the same problem.
  • Windows allows mounting of file systems to directories. Example: "C:\DriveD" might be the same thing as "D:\".
  • Do you want the file size on disk or the actual size of the file?
  • Do you care about actual DIRECTORY entries? They also take up space!
  • What do you do with files you don't have access to? Or directories you don't have permission to browse? Do you count those?

Taking all this into account means the only possible implementation is a recursive implementation. You can write your own or hope you find a ready-written one, but the end performance would be the same.

这篇关于delphi - 计算目录大小的API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆