

However, if you have a 1,000,000 byte hard-drive and want to know how big of a file can fit on that hard-drive, this will be a very important meaning to you! This is not a commonly used meaning because it is terribly hard to determine without knowing the tremendously deep inner workings of your file system (such as accounting for the space needed to store all the permissions on the file). For instance, in Linux, the concept of the file name is stored in the inode for the directory containing the file. This includes information that is usually stored separately from the file. This sounds inefficient, but it can make bookkeeping quite a bit simpler, and often simpler means faster.Ī third meaning, which you are tugging at, would be the actual number of bits required on the hard-drive to describe the presence of a file.

For example, the file system may store data in 64 kB blocks, meaning it will never allocate anything which is not an even multiple of 64 kB. We need to know how many bytes of data will be in the file so we can plan ahead.Īnother meaning arises from the way most file systems store data. This number is important to programmers because we often need to open a file, read all the data, and close it. If the file is an empty text file, it may indeed contain zero bytes. The most common one, and the one you are seeing here, is the number of bytes in the file. There are many file sizes which are meaningful. The semantic meaning of file size is different from the one you are using. But the file size logic comes from the model where a directory entry attaches a file to a directory, then the file names and related meta data are stored in the directory. Unfortunately, the term file is not always used to mean precisely the same thing. For example, the same file can have more than one name in more than one directory. The directory entry is logically distinct from the file. There is just a directory entry with a name and owner. It is possible because there really is no file. SuperUser contributors David Schwartz and Cort Ammon have the answer for us. How is it possible for a file to have a size of zero? The Answer How is that possible? I mean even if the file itself is empty, it must still have some size (even it if is just to store its own name). If I create an empty *.txt file on my computer and then look at its size, it shows a size of zero. This is something that I ran into and could not think of a proper explanation. SuperUser reader Eugene S wants to know how a file’s size can be zero:
