i have function opens file read theses files, standard open() et read() functions. use errno variables possible errors such permission denied or no such file or directory, when use open on directory don't return error open , try read it. how can error message when give open directory ?
directory file (in terms of unix/linux). won't error. can use stat or fstat function tracking of ordinary or special files.
when use either stat or fstat, need declare struct stat variable struct stat var
. stat
structure has member called st_mode
has information of kind of file is.
struct stat { dev_t st_dev; /* id of device containing file */ ino_t st_ino; /* inode number */ mode_t st_mode; /* protection */ nlink_t st_nlink; /* number of hard links */ uid_t st_uid; /* user id of owner */ gid_t st_gid; /* group id of owner */ dev_t st_rdev; /* device id (if special file) */ off_t st_size; /* total size, in bytes */ blksize_t st_blksize; /* blocksize file system i/o */ blkcnt_t st_blocks; /* number of 512b blocks allocated */ time_t st_atime; /* time of last access */ time_t st_mtime; /* time of last modification */ time_t st_ctime; /* time of last status change */ };
Comments
Post a Comment