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 the best (fastest) way to check if a directory exists in C? What is the best (fastest) way to create it if doesn’t exists?
You could call
mkdir(). If the directory does not exist then it will be created and0will be returned. If the directory exists then-1will be returned anderrnowill be set toEEXIST.