Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to check if directory exists in C++

📅 2015-Apr-02 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ directory, dirent.h ⬩ 📚 Archive

The dirent.h header file provides the opendir. Its purpose is to open a directory path to read with other calls. However, this is also a good way to check if the directory exists. If the input directory path does not exist or is a file, then this function return NULL.

Tried with: Ubuntu 14.04