C faster way to check if a directory exists

后端 未结 5 1828
感动是毒
感动是毒 2020-12-09 16:23

I\'m using opendir function to check if a directory exists. The problem is that I\'m using it on a massive loop and it\'s inflating the ram used by my app.

What is t

5条回答
  •  無奈伤痛
    2020-12-09 17:01

    You could call mkdir(). If the directory does not exist then it will be created and 0 will be returned. If the directory exists then -1 will be returned and errno will be set to EEXIST.

提交回复
热议问题