Efficiently Traverse Directory Tree with opendir(), readdir() and closedir()

后端 未结 5 1077
[愿得一人]
[愿得一人] 2020-12-30 02:35

The C routines opendir(), readdir() and closedir() provide a way for me to traverse a directory structure. However, each dirent structure returned by readdir() does not seem

5条回答
  •  死守一世寂寞
    2020-12-30 02:56

    The way to use opendir/readdir/closedir is to make the function recursive! Have a look at the snippet here on Dreamincode.net.

    Hope this helps.

    EDIT Thanks R.Sahu, the linky has expired, however, found it via wayback archive and took the liberty to add it to gist. Please remember, to check the license accordingly and attribute the original author for the source! :)

提交回复
热议问题