www.delorie.com/gnu/docs/guile/guile_312.html   search  
Buy GNU books!

Guile Reference Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

27.5 Random Access

Scheme Procedure: seek fd_port offset whence
C Function: scm_seek (fd_port, offset, whence)
Sets the current position of fd/port to the integer offset, which is interpreted according to the value of whence.

One of the following variables should be supplied for whence:

Variable: SEEK_SET
Seek from the beginning of the file.
Variable: SEEK_CUR
Seek from the current position.
Variable: SEEK_END
Seek from the end of the file.
If fd/port is a file descriptor, the underlying system call is lseek. port may be a string port.

The value returned is the new position in the file. This means that the current position of a port can be obtained using:
(seek port 0 SEEK_CUR)

Scheme Procedure: ftell fd_port
C Function: scm_ftell (fd_port)
Return an integer representing the current position of fd/port, measured from the beginning. Equivalent to:

(seek port 0 SEEK_CUR)

Scheme Procedure: truncate-file object [length]
C Function: scm_truncate_file (object, length)
Truncates the object referred to by object to at most length bytes. object can be a string containing a file name or an integer file descriptor or a port. length may be omitted if object is not a file name, in which case the truncation occurs at the current port. position. The return value is unspecified.

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003