Filesystem: file.ss

Next: Functions: functio.ss Up: MzLib Libraries Previous: Structures: defstru.ss

## Filesystem: `file.ss`

Files: `file.ss`, `fileu.ss`, `filer.ss`, `files.ss`
Requires: `string.ss`, `functio.ss`
Opened form requires: `stringu.ss`, `functiou.ss`
Signature: `mzlib:file^`
Unit: `mzlib:file@`, imports `mzlib:string^`, `mzlib:function^`

See also section 11.2.

`(build-absolute-path base path )` PROCEDURE

Like `build-path` (see section 11.2), but base is required to be an absolute pathname. If base is not an absolute pathname, `error` is called.

`(build-relative-path base path )` PROCEDURE

Like `build-path` (see section 11.2), but base is required to be a relative pathname. If base is not a relative pathname, `error` is called.

`(delete-directory/files path)` PROCEDURE

Deletes the file or directory specified by path, raising `exn:i/o:filesystem` if the file or directory cannot be deleted. If path is a directory, then `delete-directory/files` is first applied to each file and directory in path before the directory is deleted. The return value is void.

`(explode-path path)` PROCEDURE

Returns the list of directories that constitute path. The path argument must be normalized (except for letter case; see `normalize-path` below).

`(file-name-from-path path)` PROCEDURE

If path is a file pathname, returns just the file name part without the directory path.

`(filename-extension path)` PROCEDURE

Returns a string that is the extension part of the filename in path. If path is (syntactically) a directory, `#f` is returned.

`(find-library name collection)` PROCEDURE

Returns the path of the specified library (see Chapter 15), returning `#f` if the specified library or collection cannot be found. The collection argument is optional, defaulting to `"mzlib"`.

`(find-relative-path basepath path)` PROCEDURE

Finds a relative pathname with respect to basepath that names the same file or directory as path. Both basepath and path must be normalized (except for letter case; see `normalize-path` below). If path is not a proper subpath of basepath (i.e., a subpath that is strictly longer), path is returned.

`(make-directory* path)` PROCEDURE

Creates directory specified by path, creating intermediate directories as necessary.

`(make-temporary-file [format-string])` PROCEDURE

Creates a new temporary file and returns a pathname string for the file. Instead of merely generating a fresh file name, the file is actually created; this prevents other threads or processes from picking the same temporary name. However, the file is not opened for reading or writing when the pathname is returned. The client program calling `make-temporary-file` is expected to open the file with the desired access and flags (probably using the `'truncate` flag; see section 11.1.5) and to delete it when it is no longer needed.

If format-string is specified, it must be a format string suitable for use with `format` and one additional string argument (where the string contains only digits). The default format-string is `"mztmp~a"`.

`(normalize-path path wrt)` PROCEDURE

Returns a normalized, complete version of path, expanding the path and resolving all soft links. If path is relative, then the pathname wrt is used as the base path. The wrt argument is optional; if is omitted, then the current directory is used as the base path.

Letter case is not normalized by `normalize-path`, so combine `normalize-path` with `normal-case-path` to get strings for path comparison.

An error is signaled by `normalize-path` if the input path contains an embedded path for a non-existent directory, or if an infinite cycle of soft-links is detected.

`(path-only path)` PROCEDURE

If path is a filename, the file's path is returned. If path is syntactically a directory, `#f` is returned.

Next: Functions: functio.ss Up: MzLib Libraries Previous: Structures: defstru.ss