dio_seek
(PHP 4 >= 4.2.0, PHP 5 < 5.1.0)
dio_seek — whence에서 fd의 위치를 찾습니다.
설명
dio_seek(resource $fd
, int $pos
, int $whence
= SEEK_SET): int
dio_seek() 함수는 주어진 파일 디스크립터의 파일 위치를 변경하는 데 사용됩니다.
매개변수
fd
- dio_open()에 의해 반환된 파일 설명자.
pos
- 새로운 위치.
whence
- 위치
pos
를 해석하는 방법을 지정합니다.-
SEEK_SET
(default) -pos
가 파일의 시작 부분에서 지정되도록 지정합니다. -
SEEK_CUR
-pos
가 현재 파일 위치의 문자 수임을 지정합니다. 이 개수는 양수 또는 음수일 수 있습니다. -
SEEK_END
-pos
가 파일 끝의 문자 수임을 지정합니다. 음수 개수는 파일의 현재 범위 내에서 위치를 지정합니다. 양수 카운트는 현재 끝을 지나는 위치를 지정합니다. 현재 끝을 지나 위치를 설정하고 실제로 데이터를 쓰는 경우 해당 위치까지 파일을 0으로 확장합니다.
-
반환 값
Examples
예제 #1 파일에서 위치 지정
<?php
$fd = dio_open('/dev/ttyS0', O_RDWR);
dio_seek($fd, 10, SEEK_SET);
// position is now at 10 characters from the start of the file
dio_seek($fd, -2, SEEK_CUR);
// position is now at 8 characters from the start of the file
dio_seek($fd, -5, SEEK_END);
// position is now at 5 characters from the end of the file
dio_seek($fd, 10, SEEK_END);
// position is now at 10 characters past the end of the file.
// The 10 characters between the end of the file and the current
// position are filled with zeros.
dio_close($fd);
?>