Directory recursion

前端 未结 3 645
旧巷少年郎
旧巷少年郎 2021-01-03 09:08

If you need to recursively traverse a directory tree, there are two ways to do it:

  1. Build up pathnames of increasing length as you go, .../.../... etc.

3条回答
  •  庸人自扰
    2021-01-03 09:48

    The method 2 seemlessly handles situations where a component in the path is renamed.

    It also denies anyone from unmounting the directory while it's being searched; the kernel will refuse to unmount the directory if it's in use, which includes being the cwd of some process.

提交回复
热议问题