Whenever I list the contents of a directory with a function like readdir, the returned file names also include \".\" and \"..\". I have the suspicion that these are just nor
.
and ..
are actually hard links in filesystems. They are needed so that you can specify relative paths, based on some reference path (consider "../sibling/file.txt"
). Since these hard links are actually existing in the filesystem, it makes sense for readdir
to tell you about them. (actually the term hard link
just means some name that is indistinguishable from the actual directory referred to: they both point to the same inode
in the filesystem).
Best way is to just strcmp
and ignore them, if you don't want to list them.