mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-29 19:30:36 +02:00
‘seek’ now accepts ‘SEEK_DATA’ and ‘SEEK_HOLE’ where supported.
* libguile/ports.c (scm_seek): Let SEEK_DATA and SEEK_HOLE through. (scm_init_ice_9_ports): Define ‘SEEK_DATA’ and ‘SEEK_HOLE’. * module/ice-9/ports.scm: Export ‘SEEK_DATA’ and ‘SEEK_HOLE’ when defined. * test-suite/tests/ports.test ("size of sparse file") ("SEEK_DATA while on data", "SEEK_DATA while in hole") ("SEEK_HOLE while in hole"): New tests. * NEWS: Update.
This commit is contained in:
parent
4a0c2433d9
commit
696acfc9e5
5 changed files with 119 additions and 10 deletions
|
@ -823,8 +823,26 @@ Seek from the current position.
|
|||
@defvar SEEK_END
|
||||
Seek from the end of the file.
|
||||
@end defvar
|
||||
If @var{fd_port} is a file descriptor, the underlying system
|
||||
call is @code{lseek}. @var{port} may be a string port.
|
||||
|
||||
On systems that support it, such as GNU/Linux, the following
|
||||
constants can be used for @var{whence} to navigate ``holes'' in
|
||||
sparse files:
|
||||
@defvar SEEK_DATA
|
||||
Seek to the next location in the file greater than or equal to
|
||||
@var{offset} containing data. If @var{offset} points to data,
|
||||
then the file offset is set to @var{offset}.
|
||||
@end defvar
|
||||
@defvar SEEK_HOLE
|
||||
Seek to the next hole in the file greater than or equal to the
|
||||
@var{offset}. If @var{offset} points into the middle of a hole,
|
||||
then the file offset is set to @var{offset}. If there is no hole
|
||||
past @var{offset}, then the file offset is adjusted to the end of
|
||||
the file---i.e., there is an implicit hole at the end of any file.
|
||||
@end defvar
|
||||
|
||||
If @var{fd_port} is a file descriptor, the underlying system call
|
||||
is @code{lseek} (@pxref{File Position Primitive,,, libc, The GNU C
|
||||
Library Reference Manual}). @var{port} may be a string port.
|
||||
|
||||
The value returned is the new position in @var{fd_port}. This means
|
||||
that the current position of a port can be obtained using:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue