Internal Directory Structures
Every file on the system is stored in a directory. A directory is
nothing more than a file itself, except that it is specially structured and
marked on the disk so that it has special meaning. A directory is a table
that contains information about files (and subdirectories) that it contains,
and links to where the file (or subdirectory) data begins on the disk. The
paper analogy would be a table of contents to a book, except that directories
of course use a hierarchical tree
structure and books do not.
Each entry in a directory is 32 bytes in length, and stores the following
information:
-
File Name and Extension: This is the 11-character name of the file
using the conventional 8.3 DOS file naming standard, for example, COMMAND.COM.
Note that the "dot" in "COMMAND.COM" is implied and not actually stored on
the disk. See here for more on file naming and also on VFAT long file names,
which use a special structure. The
file name field is also used to indicate directory
entries that have been deleted.
-
File Attribute Byte: There are several different attributes which
the operating system uses to give special treatment to certain files; these
are stored in a single byte in each directory entry.
These attributes are discussed
in detail here. Note that it is one of these file attributes that indicates
whether an entry in the directory represents a "real" file, or a subdirectory.
-
Last Change Date/Time: There is a space for each file to indicate
the date and time that it was created or modified. You should know that these
fields can be arbitrarily modified by any program to be whatever they want,
so this date/time shouldn't be taken too religiously. I occasionally am asked
if the date/time on a file can be used to prove when someone did something
or not on their PC. It cannot, because it's too easy to change this information.
-
File Size: The size of the file in bytes.
-
Link to Start Cluster: The number of the cluster that starts the file
(or subdirectory) is stored in the directory. This is what allows the operating
system to find a file when it is needed, and how all the different files
and directories are linked together on the disk.
See here for more on cluster chaining.
Every regular directory on the disk has two special entries, that refer to
the directory itself and to the parent directory. These are named "." (single
dot) and ".." (double dot) respectively. These entries are used for navigation
purposes; if you type "chdir .." then DOS will change your current directory
to the parent of the one you were in.
Next:
Root Directory and Regular Directories