size of directory

조회 수: 9 (최근 30일)
Baba
Baba 2011년 11월 15일
is there a command that gives size of a given directory?

답변 (1개)

Walter Roberson
Walter Roberson 2011년 11월 15일
No. The "size" of a directory is not well defined.
  • Is it the amount of disk space required to store the file names and inode numbers in the most compact form supported by the filesystem?
  • Is it the amount of disk space required to store the file names and inode numbers as actually is on-disk (e.g., there might be unused entries in the directory that could in theory be compacted out but are left in place for performance reasons)
  • In the above two, is "amount of disk space" to be measured in terms of the number of bytes required to hold the information, or according to the full filesystem blocks that are allocated to exclusive use of that directory?
But I have the sneaking suspicion that you really are not concerned about the size of the directory and instead are concerned about the size of the contents of the files "stored" in the directory. And maybe in all subdirectories too, but maybe not. If so, there are still definitional difficulties, especially in the "full blocks" vs "used space" category. A file that stores only "Hello!" requires as much disk space as a file that stores 512 bytes, and some people would want the "6" answer and some people would want the "512" answer.
  댓글 수: 1
Jan
Jan 2011년 11월 15일
In addition the directory can contain hard- and soft-links. Under Windows you cann attach an alternate data stream to each each file and directory also, and therefore you have to decide if this belongs to the size of a folder also.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Search Path에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by