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


4.9 File system inspection

Data Structure: struct-stat

Data structure type representing at the Scheme level the C structure struct stat, (libc)stat.

Function: make-struct-stat mode ino dev nlink uid gid size atime atime_nsec mtime mtime_nsec ctime ctime_nsec blocks blksize

Build and return a new struct-stat instance.

Function: struct-stat? obj

Return true if obj is an instance of struct-stat.

Function: struct-stat-st_mode stat
Function: struct-stat-st_ino stat
Function: struct-stat-st_dev stat
Function: struct-stat-st_nlink stat
Function: struct-stat-st_uid stat
Function: struct-stat-st_gid stat
Function: struct-stat-st_size stat
Function: struct-stat-st_atime stat
Function: struct-stat-st_atime_nsec stat
Function: struct-stat-st_mtime stat
Function: struct-stat-st_mtime_nsec stat
Function: struct-stat-st_ctime stat
Function: struct-stat-st_ctime_nsec stat
Function: struct-stat-st_blocks stat
Function: struct-stat-st_blksize stat

Accessors for the field of struct-stat instances.

Function: stat pathname
Function: lstat pathname

Interfaces to the C functions stat() and lstat(), (libc)stat. Inspect the file system entry selected by pathname and return an instance of struct-stat. If an error occurs: an exception is raised.

Function: fstat fd

Interface to the C function fstat(), (libc)fstat. Inspect the file system entry associated to the file descriptor fd, which must be a fixnum, and return an instance of struct-stat. If an error occurs: an exception is raised.

Function: file-is-directory? pathname
Function: file-is-char-device? pathname
Function: file-is-block-device? pathname
Function: file-is-regular-file? pathname
Function: file-is-symbolic-link? pathname
Function: file-is-socket? pathname
Function: file-is-fifo? pathname
Function: file-is-message-queue? pathname
Function: file-is-semaphore? pathname
Function: file-is-shared-memory? pathname
Function: file-is-directory? pathname follow-symlinks?
Function: file-is-char-device? pathname follow-symlinks?
Function: file-is-block-device? pathname follow-symlinks?
Function: file-is-regular-file? pathname follow-symlinks?
Function: file-is-symbolic-link? pathname follow-symlinks?
Function: file-is-socket? pathname follow-symlinks?
Function: file-is-fifo? pathname follow-symlinks?
Function: file-is-message-queue? pathname follow-symlinks?
Function: file-is-semaphore? pathname follow-symlinks?
Function: file-is-shared-memory? pathname follow-symlinks?

Return #t or #f if the file system entry selected by pathname is of the specified type; if an error occurs: an exception is raised. When follow-symlinks? is true: stat() is used to inspect the entry, else lstat() is used. follow-symlinks? defaults to #f.

Function: S_ISDIR st_mode
Function: S_ISCHR st_mode
Function: S_ISBLK st_mode
Function: S_ISREG st_mode
Function: S_ISLNK st_mode
Function: S_ISSOCK st_mode
Function: S_ISFIFO st_mode

Return #t or #f if the argument is associated to a file system entry of the specified type. st_mode must be the value of the st_mode field of a struct-stat instance.

Function: access pathname how

Interface to the C function access(), (libc)access. Test the access mode selected by how, which must be a fixnum, for the file system entry selected by pathname. Return #t or #f if the access is possible or not; if an error occurs: an exception is raised.

Function: file-readable? pathname
Function: file-writable? pathname
Function: file-executable? pathname

Return #t or #f if the file system entry selected by pathname is accessible in the specified mode. These functions are equivalent but slower, respectively, to the following calls:

(access pathname R_OK)
(access pathname W_OK)
(access pathname X_OK)
Function: file-size filename

Determine the size of the file selected by filename relying on a call to stat(). If successful: return an exact integer representing the size, else raise an exception.

Function: file-atime pathname
Function: file-mtime pathname
Function: file-ctime pathname

Return an exact integer representing the access, modification and creation times for pathname. If an error occurs: raise an exception.


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