我正在编写一个文件观察器,并且由于某种原因无法获取文件信息,为什么?
struct stat info;
int fd = open(path, O_EVTONLY);
if (fd <= 0){
exit(-1);
}
int result = fstat(fd, &info);
if (!result){
exit(-1); //This happens! Errno says "No such file or directory" but that cant be because open would've failed
}
Run Code Online (Sandbox Code Playgroud)
int result = fstat(fd, &info);
if (!result){
exit(-1);
}
Run Code Online (Sandbox Code Playgroud)
检查fstat手册页,成功时返回 0。
| 归档时间: |
|
| 查看次数: |
1093 次 |
| 最近记录: |