Next: , Previous: , Up: posix   [Index]


4.12 File system directories

Function: mkdir pathname mode

Interface to the C function mkdir(), (libc)mkdir. Create a new directory file system entry with name pathname; mode must be a fixnum specifying access permissions. If successful return unspecified values, else raise an exception.

Function: mkdir/parents pathname mode

Create a new directory file system entry with name pathname and all its parents if they do not exist; mode must be a fixnum specifying access permissions for all the components. If successful return unspecified values, else raise an exception.

Function: rmdir pathname

Interface to the C function rmdir(), (libc)rmdir. Remove the directory file system entry selected by pathname. If successful return unspecified values, else raise an exception.

Function: getcwd
Function: getcwd/string

Interface to the C function getcwd(), (libc)getcwd. Acquire the pathname of the current working directory. If successful getcwd returns a bytevector holding the pathname, getcwd/string returns a string holding the pathname; else an exception is raised.

Function: chdir pathname

Interface to the C function chdir(), (libc)chdir. Change the current working directory to the file system entry selected by pathname. If successful return unspecified values, else raise an exception.

Function: fchdir fd

Interface to the C function fchdir(), (libc)fchdir. Change the current working directory to the file system entry associated to fd, which must be a fixnum representing a file descriptor. If successful return unspecified values, else raise an exception.

Structure Type: directory-stream

Opaque data structure type used in the inspection of file system directory entries. Instances of this type can be destroyed by closedir, but they are also automatically and correctly destroyed by the garbage collector. It has the following fields:

pathname

False or a string representing the pathname.

pointer

A pointer object referencing the directory.

fd

False or a fixnum representing the file descriptor associated to the directory.

closed?

A boolean, true if this stream has already been closed.

Function: make-directory-stream pathname pointer fd closed?

Constructor for directory-stream.

Function: directory-stream? obj

Return true if obj is an instance of directory-stream.

Function: directory-stream-pathname stream
Function: directory-stream-pointer stream
Function: directory-stream-fd stream
Function: directory-stream-closed? stream

Accessors for the fields of directory-stream.

Function: opendir pathname

Interface to the C function opendir(), (libc)opendir. Open a directory stream for the inspection of the file system entry pathname. If successful return an instance of directory-stream, else raise an exception.

Function: fdopendir fd

Interface to the C function fdopendir(), (libc)fdopendir. Open a directory stream for the inspection of the file system entry associated to fd, which must be a fixnum representing a file descriptor. If successful return an instance of directory-stream, else raise an exception.

Function: readdir stream
Function: readdir/string stream

Interface to the C function readdir(), (libc)readdir. Acquire the next entry from a directory stream referenced by stream, which must be an instance of directory-stream. If successful and an entry is available: readdir returns a pathname as a bytevector, readdir/string returns a pathname as a string; if successful and no more entries are available: return #f; else raise an exception.

When no more entries are available or an error occurs: the directory stream is closed.

Function: closedir stream

Interface to the C function closedir(), (libc)closedir. Close the directory stream referenced by stream, which must be an instance of directory-stream. If successful return unspecified values, else raise an exception.

This function has no effect if stream has been already closed.

Function: rewinddir stream

Interface to the C function rewinddir(), (libc)rewinddir. Rewind to the beginning the directory stream referenced by stream, which must be an instance of directory-stream. Return unspecified values.

Function: telldir stream

Interface to the C function telldir(), (libc)telldir. Return an exact integer representing the current position in the directory stream referenced by stream, which must be an instance of directory-stream.

Function: seekdir pointer pos

Interface to the C function seekdir(), (libc)seekdir. Set to pos the position of the directory stream referenced by stream, which must be an instance of directory-stream; pos must be the return value of a previous call to telldir. Return unspecified values.


Next: , Previous: , Up: posix   [Index]