목록directory (1)
YOGYUI
C++::디렉터리 존재 여부 확인하기 (g++)
C++: Check Directory Existence (g++) #include bool check_dir_exist(const char *path) { bool exist = false; struct stat st; if(stat(path, &st) == 0) { if( ((st.st_mode) & S_IFMT) == S_IFDIR ) { exist = true; } } return exist; } 헤더파일 를 include한 뒤 stat 함수 호출 int stat(const char *path, struct stat *buf); path: 경로명 문자열 포인터 (입력) buf: 경로에 대한 정보가 담긴 stat 구조체 (출력) 리턴값: 0 = 성공, -1 = 실패 (실패 이유는 다양하며, errno..
Software/C, C++
2022. 7. 25. 19:32