Jee*_*tel 4 c linux directory file
这样
为什么fopen("any_path_name","r")不返回NULL作为返回?
我知道在linux目录和文件被认为是文件.所以当我在fopen中使用read模式给出任何目录路径或文件路径时,它不会给出NULL文件描述符和?
那我怎么能检查它是否是dirctory路径或文件路径?如果我从命令参数获得一些路径?
man 2 stat:
NAME
fstat, fstat64, lstat, lstat64, stat, stat64 -- get file status
...
struct stat {
dev_t st_dev; /* ID of device containing file */
mode_t st_mode; /* Mode of file (see below) */
...
The status information word st_mode has the following bits:
...
#define S_IFDIR 0040000 /* directory */
Run Code Online (Sandbox Code Playgroud)