PREV UP NEXT SCM

5.6: I/O-Extensions

If 'i/o-extensions is provided (by linking in `ioext.o'), Line I/O, and the following functions are defined:

Function: isatty? port
Returns #t if port is input or output to a serial non-file device.
Function: stat <port-or-string>
Returns a vector of integers describing the argument. The argument can be either a string or an open input port. If the argument is an open port then the returned vector describes the file to which the port is opened; If the argument is a string then the returned vector describes the file named by that string. If there exists no file with the name string, or if the file cannot be accessed #f is returned. The elements of the returned vector are as follows:
0 st_dev
ID of device containing a directory entry for this file
1 st_ino
Inode number
2 st_mode
File type, attributes, and access control summary
3 st_nlink
Number of links
4 st_uid
User ID of file owner
5 st_gid
Group ID of file group
6 st_rdev
Device ID; this entry defined only for char or blk spec files
7 st_size
File size (bytes)
8 st_atime
Time of last access
9 st_mtime
Last modification time
10 st_ctime
Last file status change time
Function: getpid
Returns the process ID of the current process.
Function: file-position port
Returns the current position of the character in port which will next be read or written. If port is not open to a file the result is unspecified.
Function: file-set-position port integer
Sets the current position in port which will next be read or written. If port is not open to a file the action of file-set-position is unspecified. The result of file-set-position is unspecified.
Function: reopen-file filename modes port
Closes port port and reopens it with filename and modes. reopen-file returns #t if successful, #f if not.
Function: duplicate-port port modes
Creates and returns a duplicate port from port. Duplicate unbuffered ports share one file position. modes are as for open-file.
Function: redirect-port! from-port to-port
Closes to-port and makes to-port be a duplicate of from-port. redirect-port! returns to-port if successful, #f if not. If unsuccessful, to-port is not closed.
Function: opendir dirname
Returns a directory object corresponding to the file system directory named dirname. If unsuccessful, returns #f.
Function: readdir dir
Returns the string name of the next entry from the directory dir. If there are no more entries in the directory, readdir returns a #f.
Function: rewinddir dir
Reinitializes dir so that the next call to readdir with dir will return the first entry in the directory again.
Function: closedir dir
Closes dir and returns #t. If dir is already closed,, closedir returns a #f.
Function: mkdir path mode
The mkdir function creates a new, empty directory whose name is path. The integer argument mode specifies the file permissions for the new directory. See The Mode Bits for Access Permission, for more information about this.

mkdir returns if successful, #f if not.

Function: rmdir path
The rmdir function deletes the directory path. The directory must be empty before it can be removed. rmdir returns if successful, #f if not.
Function: chdir filename
Changes the current directory to filename. If filename does not exist or is not a directory, #f is returned. Otherwise, #t is returned.
Function: getcwd
The function getcwd returns a string containing the absolute file name representing the current working directory. If this string cannot be obtained, #f is returned.
Function: rename-file oldfilename newfilename
Renames the file specified by oldfilename to newfilename. If the renaming is successful, #t is returned. Otherwise, #f is returned.
Function: chmod file mode
The function chmod sets the access permission bits for the file named by file to mode. The file argument may be a string containing the filename or a port open to the file.

chmod returns if successful, #f if not.

Function: utime pathname acctime modtime
Sets the file times associated with the file named pathname to have access time acctime and modification time modtime. utime returns if successful, #f if not.
Function: umask mode
The function umask sets the file creation mask of the current process to mask, and returns the previous value of the file creation mask.
Function: fileno port
Returns the integer file descriptor associated with the port port. If an error is detected, #f is returned.
Function: access pathname how
Returns #t if the file named by pathname can be accessed in the way specified by the how argument. The how argument can be the logior of the flags:
  1. File-exists?
  2. File-is-executable?
  3. File-is-writable?

Or the how argument can be a string of 0 to 3 of the following characters in any order. The test performed is the and of the associated tests and file-exists?.

X
File-is-executable?
W
File-is-writable?
R
File-is-readable?
Function: execl command arg0 ...
Function: execlp command arg0 ...
Transfers control to program command called with arguments arg0 .... For execl, command must be an exact pathname of an executable file. execlp searches for command in the list of directories specified by the environment variable PATH. The convention is that arg0 is the same name as command.

If successful, this procedure does not return. Otherwise an error message is printed and the integer errno is returned.

Function: execv command arglist
Function: execvp command arglist

Like execl and execlp except that the set of arguments to command is arglist.

Function: putenv string
adds or removes definitions from the environment. If the string is of the form `NAME=VALUE', the definition is added to the environment. Otherwise, the string is interpreted as the name of an environment variable, and any definition for this variable in the environment is removed.

Names of environment variables are case-sensitive and must not contain the character =. System-defined environment variables are invariably uppercase.

Putenv is used to set up the environment before calls to execl, execlp, execv, execvp, system, or open-pipe (see open-pipe).

To access environment variables, use getenv (see getenv).