====== C++ Check if folder or file exists (linux) ====== Since everything is a file in linux, the procedure is the same both for folders and files #include #include #include int main() { if (std::ifstream("/folder")) { //folder std::string badge = "/folder/file"; if (std::ifstream(badge)) { std::cout << "File exists" << std::endl; } else { std::cout << "File doesn't exist" << std::endl; } } else { std::cout << "Folder doesn't exist" << std::endl; } return 0; }