linux下用access()判断文件是否存在
2013-12-31 20:26
453 查看
代码:
示例:
#include <unistd.h> #include <stdio.h> /** * A example to check the file existence. * */ int isFileExist(const char* filename) { return access(filename, F_OK) == 0; } /** * Usage: a.out filename * */ int main(int argc, const char* argv[]) { if (argc != 2) { printf("Usage: a.out filename\n"); return 1; } if (isFileExist(argv[1])) { printf("%s exists.\n", argv[1]); } else { printf("%s does not exist.\n", argv[1]); } return 0; }
示例:
~/examples/cpp/access % ./a.out Usage: a.out filename ~/examples/cpp/access % ./a.out a.out a.out exists.
相关文章推荐
- linux下的access()函数判断文件是否存在、打印时间
- linux下的access()函数判断文件是否存在、打印时间
- linux 判断文件是否存在的access()方法与示例
- linux下的access()函数判断文件是否存在
- linux 判断文件是否存在的access()方法与示例
- linux下的access()函数判断文件是否存在、打印时间
- linux下的access()函数判断文件是否存在、打印时间
- linux 判断文件是否存在的access()方法与示例
- linux 判断文件是否存在
- [C]linux下C编程--判断文件是否存在
- linux+笔记:linux下判断一个文件或者目录是否存在
- 判断文件是否存在的另一种方法 _access 和 _waccess
- linux判断文件是否存在
- Linux - 判断文件/目录是否存在/具有权限
- Shell脚本执行hive语句 | hive以日期建立分区表 | linux schedule程序 | sed替换文件字符串 | shell判断hdfs文件目录是否存在
- VC++ 判断文件或文件夹是否存在的快捷方法 _access
- linux判断文件是否存在
- Linux下判断文件或文件夹是否存在的方法
- C语言函数access(szFilePath, 0)用于判断文件是否存在
- linux判断文件是否存在