The presence of the dot and double dot in MS-DOS and Windows

28 viewsOtherTechnology

In my quest to understand inodes and why they are, I am got that it was a Unix thing and that the . and .. links are some artifacts of it. In using an old 386 PC with MS-DOS 6.22, I also find these (hard?) links where the file system is FAT16, so why are these present? Of course they are useful but I am asking about why they were brought to FAT16 from whatever file system Unix was using?

In: Technology

3 Answers

Anonymous 0 Comments

As someone who grew up through the various DOS/UNIX versions I may have a useful insight to this. An often used allegory for a file system is an old-fashioned filing cabinet, where files are stored in folders, these are arranged in drawers and so on. The filesystem provides a way to find a particular piece of information from the mass of data stored by putting a structure between the user and the raw data on the disk. This structure allows the user to refine their search for a piece of information using folder and file names.

What has been abstracted from the user through the advent of Windows and other graphical user interfaces, is that each user session maintains a current position in the filesystem. In MSDOS, you would use the CD (change directory) command to move to the folder an executable was in, and then type the name of the executable to run it. The OS would use your current position in the filesystem to determine where to look for the executable. I have spent countless hours troubleshooting .BAT and Shell files for failing to start in the proper folder or similar.

The “.” and “..” files allows the OS to orientate itself. Wherever it currently is in the filesystem, those two files will allow it to find any files in the current directory and connect back up the filesystem tree. Every time a command is typed, it can respond in the same way – open current “.” file, look for executable file, or open current “‘..” file and look at the parent folder. They become shorthand for “in the current folder” and “in the parent folder”.

In summary they are there because they serve a useful purpose, and one that most OS design still needs – a neutral reference point to use when looking for information.

Anonymous 0 Comments

`.` refers to the current directory, and `..` refers to the parent directory.

They’re used as “shorthand” to refer to files in the current directory (eg: `.somefile.ext`) or files in the parent directory (eg: `..somefile.ext`).

This is so you don’t have to use the entire file’s path to refer to it. For example, if your current directory was `C:SomeFolderAnotherFolderYetAnotherFolder`, and you wanted to refer to `somefile.ext` in `C:SomeFolderAnotherFolder`, you can just use `..somefile.ext`.

Anonymous 0 Comments

Early MS-DOS / QDOS copied a load of stuff from CP/M. And CP/M was somewhat inspired by Unix. I think that’s about as complex as it gets.

Implementation is different though. In Unix . and .. are part of the filesystem and in some early / buggy versions can even be deleted. In MS-DOS they’re part of the shell.