linux获取文件类型
来源:互联网 发布:龙神契约升阶数据 编辑:程序博客网 时间:2024/05/22 03:48
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int i;
struct stat buf;
char *ptr;
for(i = 1; i < argc; i++)
{
printf("%s: ", argv[i]);
if(lstat(argv[i], &buf) < 0)
{
perror("lstat error");
continue;
}
if(S_ISREG(buf.st_mode))
ptr = "regular";
else if(S_ISDIR(buf.st_mode))
ptr = "directory";
else if (S_ISCHR(buf.st_mode))
ptr = "character special";
else if (S_ISBLK(buf.st_mode))
ptr = "block special";
else if (S_ISFIFO(buf.st_mode))
ptr = "fifo";
#ifdef S_ISLNK
else if (S_ISLNK(buf.st_mode))
ptr = "symbolic link";
#endif
#ifdef S_ISSOCK
else if (S_ISSOCK(buf.st_mode))
ptr = "socket";
#endif
else
ptr = "***unknown mode ***";
printf("%s\n", ptr);
}
}
- linux下文件类型获取
- linux获取文件类型
- linux下文件类型获取
- linux下文件类型的获取
- LINUX C 获取文件类型 以及访问权限
- 获取文件类型
- 获取文件类型
- 获取文件类型
- 获取文件类型
- linux文件类型
- linux文件类型
- Linux文件类型
- Linux文件类型
- LInux文件类型
- linux:文件类型
- Linux文件类型
- Linux文件类型
- linux 文件类型
- 28
- Verilog HDL in one day Part-IV
- Python file read and wirte
- 算法复杂度分析
- QTP之回放模式(ReplayType)
- linux获取文件类型
- windows 下安装 python lxml
- oracle X表汇总
- 29
- wince6.0 don't know how to make**错误
- 本科应届生月薪5000元以上的职业
- 数据结构与算法 试题与答案
- 一种不会导致资源泄露的“终止”线程的方法
- loadView和viewDidLoad及initWithNibName/awakeFromNib/initWithCoder