20.1. The Files Dictionary
Prev | Chapter 20. Files | Next

## 20.1. The Files Dictionary [sec_the_files_dictionary]

### Directory is not a file

CLISP has traditionally taken the view that a directory is a separate object and not a special kind of file, so whenever the standard says that a function operates on files without specifically mentioning that it also works on directories, CLISP `SIGNAL`s an `ERROR` when passed a directory.

CLISP provides separate directory functions, such as `EXT:DELETE-DIRECTORY`, `EXT:RENAME-DIRECTORY` et al.

### Function `PROBE-FILE`

`PROBE-FILE` cannot be used to check whether a directory exists. Use functions `EXT:PROBE-DIRECTORY` or `DIRECTORY` for this.

### Function `FILE-AUTHOR`

`FILE-AUTHOR` always returns `NIL`, because the operating systems CLISP is ported to do not store a file's author in the file system. Some operating systems, such as UNIX, have the notion of a file's owner, and some other Common Lisp implementations return the user name of the file owner. CLISP does not do this, because owner and author are not the same; in particular, authorship is preserved by copying, while ownership is not.

Use `OS:FILE-OWNER` to find the owner of the file. See also `OS:FILE-PROPERTIES` (Platform Dependent: Win32 platform only.).

### Function `EXT:PROBE-DIRECTORY`

`(`EXT:PROBE-DIRECTORY` `pathname`)` tests whether `pathname` exists and is a directory. It will, unlike `PROBE-FILE` or `TRUENAME`, not `SIGNAL` an `ERROR` if the parent directory of `pathname` does not exist.

### Function `DELETE-FILE`

`(`DELETE-FILE` `pathname`)` deletes the pathname `pathname`, not its `TRUENAME`, and returns the absolute pathname it actually removed or `NIL` if `pathname` did not exist. When `pathname` points to a file which is currently open in CLISP, an `ERROR` is `SIGNAL`ed. To remove a directory, use `EXT:DELETE-DIRECTORY` instead.

### Function `RENAME-FILE`

This function cannot operate on directories, use `EXT:RENAME-DIRECTORY` to rename a directory.

### Function `DIRECTORY`

`(`DIRECTORY` `&OPTIONAL` `pathname` `&KEY` :FULL :CIRCLE `:IF-DOES-NOT-EXIST`)` can run in two modes:

- If `pathname` contains no name or type component, a list of all matching directories is produced. E.g., `(`DIRECTORY` "/etc/*/")` lists all subdirectories in the directory `#P"/etc/"`.
- Otherwise a list of all matching files is returned. E.g., `(`DIRECTORY` "/etc/*")` lists all regular files in the directory `#P"/etc/"`. If the `:FULL` argument is non-`NIL`, additional information is returned: for each matching file you get a `LIST` of at least four elements (`file-pathname` `file-truename` `file-write-date-as-decoded-time` `file-length`).

If you want all the files and subdirectories in the current directory, you should use `(`NCONC` (`DIRECTORY` "*/") (`DIRECTORY` "*"))`. If you want all the files and subdirectories in all the subdirectories under the current directory (similar to the ls `-R` UNIX command), use `(`NCONC` (`DIRECTORY` "**/") (`DIRECTORY` "**/*"))`.

Platform Dependent: UNIX platform only.
  If the `:CIRCLE` argument is non-`NIL`, the function avoids endless loops that may result from symbolic links.

The argument `:IF-DOES-NOT-EXIST` controls the treatment of links pointing to non-existent files and can take the following values:

`:DISCARD` (default)
  discard the bad directory entries
`:ERROR`
  an `ERROR` is `SIGNAL`ed on bad directory entries (this corresponds to the default behavior of `DIRECTORY` in CMU CL)
`:KEEP`
  keep bad directory entries in the returned list (this roughly corresponds to the `(`DIRECTORY` ... `:TRUNAMEP` `NIL`)` call in CMU CL)
`:IGNORE`
  Similar to `:DISCARD`, but also do not signal an error when a directory is unaccessible (contrary to the [ANSI CL standard] specification).

### Function `EXT:DIR`

`(`EXT:DIR` `&OPTIONAL` `pathname`)` is like `DIRECTORY`, but displays the pathnames instead of returning them. `(EXT:DIR)` shows the contents of the current directory.

### Function `EXT:CD`

`(`EXT:CD` `pathname`)` sets the current working directory, `(`EXT:CD`)` returns it.

Platform Dependent: UNIX platform only.
  `(`EXT:CD` [`pathname`])` manages the current directory.
Platform Dependent: Win32 platform only.
  `(`EXT:CD` [`pathname`])` manages the current device and the current directory.

### Function `EXT:DEFAULT-DIRECTORY`

`(`EXT:DEFAULT-DIRECTORY`)` is equivalent to `(`EXT:CD`)`. `(`SETF` (`EXT:DEFAULT-DIRECTORY`) `pathname`)` is equivalent to `(`EXT:CD` `pathname`)`, except for the return value.

### Function `EXT:MAKE-DIRECTORY`

`(`EXT:MAKE-DIRECTORY` `directory-pathname`)` creates a new subdirectory.

### Function `EXT:DELETE-DIRECTORY`

`(`EXT:DELETE-DIRECTORY` `directory-pathname`)` removes an (empty) subdirectory.

### Function `EXT:RENAME-DIRECTORY`

`(`EXT:RENAME-DIRECTORY` `old-directory-pathname` `new-directory-pathname`)` renames a subdirectory to a new name.

| These notes document CLISP version 2.45 | Last modified: 2008-04-15

Enter your search termsSubmit search form
Webclisp.cons.orgclisp.podval.orgwww.lisp.org

Prev | Up | Next
Chapter 20. Files | Home | Chapter 21. Streams