시스템 프로그래밍_01
System programming2018. 3. 9. 21:34
파일의 종류 검색 : 127슬라이드
S_IFMT :
S_IFDIR : 디렉토리 파일 : 0x4000
S_IFREG : 일반 파일 : 0x8000
S_IFLNK : 심볼릭 링크 파일 : 0xA000
---------------------------------------------------------------------
# include <stdio.h>
# include <sys/stat.h>
int main(void) {
struct stat buf;
int kind;
stat("s_dir", &buf);
printf("mode => (16진수 => %x)\n", (unsigned int)buf.st_mode);
kind = buf.st_mode & S_IFMT;
printf("Kind => %x\n", kind);
switch(kind) {
case S_IFDIR:
printf("s_dir : Directory\n");
break;
case S_IFREG:
printf("s_dir : Regular file\n");
break;
case S_IFLNK:
printf("s_dir : symbolic link file \n");
break;
}
return 0;
}
'System programming' 카테고리의 다른 글
시스템 프로그래밍 파일종류 검색 (0) | 2018.03.09 |
---|---|
시스템 프로그래밍 (0) | 2018.03.07 |
strcpy (0) | 2017.11.08 |
시스템 프로그래밍_1 (0) | 2017.10.09 |