0
我想使用函数S_ISLNK(file.st_mode)来检查某个文件是符号链接还是目录或常规文件。然而,当我用符号链接文件检查它时,它似乎不起作用。确定unix系统上的符号链接
这里是我的代码:
if(S_ISDIR(fileStat.st_mode))
{
// DIR - display files in the directory
printf(" DIR ");
fileType = 2;
}else if(S_ISLNK(fileStat.st_mode)){
// LNK - display the name of the file the link is pointing to
printf(" LNK ");
fileType = 3;
}else{
// Display general info only
printf(" REG ");
fileType = 1;
}
一个目录的检查工作正常,但是当我在一个符号链接运行我的程序文件,它显示为一个普通的文件。任何人都知道我可能做错了什么?