CS/UNIX
[UNIX Input and Output] - lseek 함수
sliver__
2022. 10. 11. 21:38
728x90
[lseek]
- open된 file의 offset을 찾는다.
- 또는 현재의 offset 값을 찾는다.
#include <sys/types.h>
#include <unistd.h>
off_t lseek(int fildes, off_t offset, int whence);
- 파일 디스크립터와 offset, whence의 조합으로 검색이 수행된다.
- 함수가 성공할 경우 새 offset을 return 하고 실패했을 경우 errno와 함께 -1을 return 한다.
- ESPIPE errno : non-seekable device일 경우
- whence의 값은 아래의 표와 같고 <unistd.h> 에 macro로 정의되어 있다.
728x90