K 개발자
디렉토리 관련 함수 본문
디렉토리 생성과 삭제
디렉토리 생성 : mkdir(2)
#include <sys/types.h>
#include <sys/stat.h>
int mkdir(const char *path, mode_t mode);
// path : 디렉토리가 포함된 경로, mode : 접근 권한
디렉토리 삭제 : rmdir(2)
#include <unistd.h>
int rmdir(const char *path);
// path : 삭제할 경로
디렉토리 관리
디렉토리명 변경 : rename(2)
#include <stdio.h>
int rename(const char *old, const char *new);
// old : 변경할 파일/디렉토리명, new : 새 파일/디렉토리명
현재 작업 디렉토리 위치 : getcwd(3)
#include <unistd.h>
char *getcwd(char *buf, size_t size);
// buf : 현재 디렉토리의 절대 경로를 저장할 버퍼 주소, size : 버퍼의 크기
디렉토리 이동 : chdir(2)
#include <unistd.h>
int chdir(const char *path);
// path : 이동하려는 디렉토리 경로
디렉토리 정보 검색
디렉토리 열기 : opendir(3)
#include <sys/types.h>
#include <dirent.h>
DIR *opendir(const char *dirname);
// dirname : 열려는 디렉토리명
디렉토리 닫기 : closedir(3)
#include <sys/types.h>
#include <dirent.h>
int closedir(DIR *dirp);
// dirp : 닫으려는 디렉토리를 가리키는 포인터
디렉토리 정보 읽기 : readdir(3)
#include <sys/types.h>
#include <dirent.h>
struct dirent *readdir(DIR *dirp);
// dirp : 정보를 읽어올 디렉토리를 가리키는 포인터
디렉토리 오프셋 : telldir(3), seekdir(3), rewinddir(3)
#include <dirent.h>
long telldir(DIR *dirp);
void seekdir(DIR *dirp, long loc);
void rewinddir(DIR *dirp);
// dirp : 대상 DIR 포인터, loc : 이동할 위치
'유닉스(Unix) > 시스템 프로그래밍' 카테고리의 다른 글
사용자 관련 정보 검색 (0) | 2021.08.16 |
---|---|
시스템 관련 정보 검색과 설정 (0) | 2021.08.16 |
링크 파일 생성 (0) | 2021.08.16 |
파일 접근 권한 제어 (0) | 2021.08.16 |
파일 정보 검색 (0) | 2021.08.16 |
Comments