Why do directory listings contain the current (.) and parent (..) directory?

后端 未结 8 1170
面向向阳花
面向向阳花 2020-12-11 03:11

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

8条回答
  •  独厮守ぢ
    2020-12-11 03:20

    Because on Unix-like operating systems, the directory-listing commands include those, and you use them to move up and down in the filesystem hierarchy.

    Something like grep { not /^.{1,2}\z/ } readdir HANDLE should work for you.

提交回复
热议问题