How can I check whether this is directory-path or any filename-path?

后端 未结 3 825
暗喜
暗喜 2021-01-06 12:22

by this

Why does fopen("any_path_name",'r') not give NULL as return?

i get to know that in linux directories and files are considered to b

3条回答
  •  再見小時候
    2021-01-06 12:30

    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 */
    

提交回复
热议问题