When would the "." and ".." entries in a dir listing differ? (I understand they represent two different directories, but they always list identically with the same date and time in a default dir command. Do they ever differ?)
As to the actual listing:
27/08/2011 11:23 <DIR> . 27/08/2011 11:23 <DIR> ..
They're using the date of the current directory for both. If you start in
C:\Users\Chris (say) you might get the above. But when you go up to
C:\Users you get:
26/07/2011 21:20 <DIR> . 26/07/2011 21:20 <DIR> ..
So the date of
.. in the first case is not the same as the date of
. in the second. Which is apparently wrong as they are (or should be) the same directory. However,
.. are references to the current and parent directory and are both created at the same time - when the directory was created - so it's actually correct (thanks to Synetech inc for pointing this out)
The only time the timestamps would be different is if one or other of
.. were recreated.
The original answer:
. means the current directory.
.. means the parent directory.
So under normal circumstances they are always different.
The only time they yield the same result is when you are at the root of the disk. So at
dir . and
dir .. produce the same output.
No, they will always be the same. Because these are directories, not files, they are handled slightly differently (in fact, they are not even normal directories, they are pointers as eL01 said, so they are handled even more differently than normal directories).
When you create a directory, two entries are automatically created:
.points to the newly created directory
..points to the the new directory’s parent
. will have the current date and time that the directory is created, and while it may seem logical for the timestamp of the parent directory to be copied to
.., that is not how it works. When you create a new directory, both of the pointers receive the current date and time. This is the case from DOS through Windows 7 on both FAT* and NTFS.
I actually can't give you proof, but I think:
Every directory has a list of directories and files it contains. To make it possible to use relative paths every directory needs those two pointers - one to itself
. and the other directory one level above
.. - those two pointers are just created on the time the directory itself is created.
So the timestamp of
.. is actually not the timestamp of the directory above but the timestamp of the pointer to the directory above.