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;
}
一個目錄的檢查工作正常,但是當我在一個符號鏈接運行我的程序文件,它顯示爲一個普通的文件。任何人都知道我可能做錯了什麼?