Checking if a directory exists in Unix (system call)
问题 I am not able to find a solution to my problem online. I would like to call a function in Unix, pass in the path of a directory, and know if it exists. opendir() returns an error if a directory does not exist, but my goal is not to actually open, check the error, close it if no error, but rather just check if a file is a directory or not. Is there any convenient way to do that please? 回答1: There are two relevant functions on POSIX systems: stat() and lstat(). These are used to find out