You can use is_regular_file
to check any path (either a C++17 path object or just a string). Similarly you can use is_directory
to check if the given path belongs to a directory.
Note that these just return false if the file or directory does not exist!
// Check if something is a file bool isTestTxtAFile = is_regular_file("test.txt"); // true bool isMyDirectoryAFile = is_regular_file("my-directory"); // false bool isDoesNotExistAFile = is_regular_file("does-not-exist"); // false // Check if something is a directory bool isTestTxtADirectory = is_directory("test.txt"); // false bool isMyDirectoryADirectory = is_directory("my-directory"); // true bool isDoesNotExistADirectory = is_directory("does-not-exist"); // false