Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
The software is provided “as is”, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.
Osicat is a lightweight operating system interface for Common Lisp on Unix-platforms. It is not a POSIX-style
api
, but rather a simple lispy accompaniment to the standardansi
facilities.Osicat homepage:
http://www.common-lisp.net/project/osicat/
Concepts:
Designated directory
When a relative pathname designator is used as a directory designator it is first resolved against
*default-pathname-default*
, and then against the current directory. (Withmerge-pathnames
in both cases.)
Class precedence list:
system-error, error, serious-condition, condition, t
Base class for errors signalled by Osicat.
environment-variable
returns the environment variable identified byname
, ornil
if one does not exist.name
can either be a symbol or a string.
setf
environment-variable
sets the environment variable identified byname
tovalue
. Bothname
andvalue
can be either a symbols or strings. Signals an error on failure.
environment
returns the current environment as an assoc-list.setf
environment
modifies the environment its argument.Often it is preferable to use
setf
environment-variable
andmakunbound-environment-variable
to modify the environment instead ofsetf
environment
.
Removes the environment variable identified by
name
from the current environment.name
can be either a string or a symbol. Returns the string designated byname
. Signals an error on failure.
current-directory
returns the operating system's current directory, which may or may not correspond to*default-pathname-defaults*
.
setf
current-directory
changes the operating system's current directory to thepathspec
. An error is signalled if thepathspec
is wild or does not designate a directory.
Recursively deletes all files and directories within the directory designated by the non-wild pathname designator
dirname
includingdirname
itself.if-does-not-exist
must be one of:error
or:ignore
where:error
means that an error will be signaled if the directorydirname
does not exist.
Deletes the directory designated by
pathspec
. Returnst
. The directory must be empty. Symbolic links are not followed.Signals an error if
pathspec
is wild, doesn't designate a directory, or if the directory could not be deleted.
Checks whether the file named by the pathname designator
pathspec
exists and is a directory. Returns its truename if this is the case,nil
otherwise. Follows symbolic links.
Returns a fresh list of pathnames corresponding to all files within the directory named by the non-wild pathname designator
pathspec
. Ifbare-pathnames
is non-NIL only the files's bare pathnames are returned (with an empty directory component), otherwise the files' pathnames are merged withpathspec
.
Applies function to each entry in directory designated by
pathspec
in turn and returns a list of the results. Binds*default-pathname-defaults*
to the directory designated by pathspec round to function call.If
pathspec
designates a symbolic link, it is implicitly resolved.Signals an error if
pathspec
is wild or doesn't designate a directory.
Recursively applies the function
fn
to all files within the directory named by the non-wild pathname designatordirname
and all of its sub-directories. Returnst
on success.
fn
will only be applied to files for which the functiontest
returns a true value. Ifdirectories
is notnil
,fn
andtest
are applied to directories as well. Ifdirectories
is:depth-first
,fn
will be applied to the directory's contents first. Ifdirectories
is:breadth-first
andtest
returnsnil
, the directory's content will be skipped.if-does-not-exist
must be one of:error
or:ignore
where:error
means that an error will be signaled if the directorydirname
does not exist.
pathspec
must be a valid directory designator:*default-pathname-defaults*
is bound, and (CURRENT-DIRECTORY) is set to the designated directory for the dynamic scope of the body.Within the lexical scope of the body,
iterator
is defined via macrolet such that successive invocations of (ITERATOR) return the directory entries, one by one. Both files and directories are returned, except '.' and '..'. The order of entries is not guaranteed. The entries are returned as relative pathnames against the designated directory. Entries that are symbolic links are not resolved, but links that point to directories are interpreted as directory designators. Once all entries have been returned, further invocations of (ITERATOR) will all returnnil
.The value returned is the value of the last form evaluated in body. Signals an error if
pathspec
is wild or does not designate a directory.
Checks whether the file named by the pathname designator
pathspec
exists, if this is the case andfile-kind
is specified it also checks the file kind. If the tests succeed, return two values: truename and file kind ofpathspec
,nil
otherwise. Follows symbolic links.
Checks whether the file named by the pathname designator
pathspec
exists and is a regular file. Returns its truename if this is the case,nil
otherwise. Follows symbolic links.
Returns a keyword indicating the kind of file designated by
pathspec
, ornil
if the file does not exist. Does not follow symbolic links by default.Possible file-kinds in addition to
nil
are::regular-file
,:symbolic-link
,:directory
,:pipe
,:socket
,:character-device
, and:block-device
. Iffollow-symlinks
is non-NIL andpathspec
designates a broken symlink returns:broken
as second value.Signals an error if
pathspec
is wild.
file-permissions
returns a list of keywords identifying the permissions ofpathspec
.
setf
file-permissions
sets the permissions ofpathspec
as identified by the symbols in list.If
pathspec
designates a symbolic link, that link is implicitly resolved.Permission symbols consist of
:user-read
,:user-write
,:user-exec
,:group-read
,:group-write
,:group-exec
,:other-read
,:other-write
,:other-exec
,:set-user-id
,:set-group-id
, and:sticky
.Both signal an error if
pathspec
is wild, or doesn't designate an existing file.
Creates a temporary file setup for input and output, and returns a stream connected to that file.
pathspec
serves as template for the file to be created: a certain number of random characters will be concatenated to the file component ofpathspec
. Ifpathspec
has no directory component, the file will be created inside*temporary-directory*
. The file itself is unlinked once it has been opened.
element-type
specifies the unit of transaction of the stream. Consider usingwith-temporary-file
instead of this function.On failure, a
file-error
may be signalled.
Within the lexical scope of the body,
stream
is connected to a temporary file as created byopen-temporary-file
. The file is closed automatically oncebody
exits.
Creates
link
that points totarget
. Defaults to a symbolic link, but giving a non-NIL value to the keyword argument:hard
creates a hard link. Returns the pathname of the link.Relative targets are resolved against the link. Relative links are resolved against
*default-pathname-defaults*
.Signals an error if either target or link is wild, target does not exist, or link exists already.
Returns the pathname pointed to by the symbolic link designated by
pathspec
. If the link is relative, then the returned pathname is relative to the link, not*default-pathname-defaults*
.Signals an error if
pathspec
is wild, or does not designate a symbolic link.
user-info
returns the password entry for the given name or numerical userid
, as an assoc-list.
Returns
t
if thepathspec
designates an absolute pathname,nil
otherwise.
Returns an absolute pathname corresponding to
pathspec
by merging it withdefault
, and (CURRENT-DIRECTORY) if necessary.
Returns
nil
ifpathspec
(a pathname designator) does not designate a directory,pathspec
otherwise. It is irrelevant whether file or directory designated bypathspec
does actually exist.
Converts the non-wild pathname designator
pathspec
to directory form.
Converts the non-wild pathname designator
pathspec
to file form.
Returns
t
if thepathspec
designates a relative pathname,nil
otherwise.
Removes those leading directory components from
pathspec
that are shared withdefault
.
absolute-pathname
: Pathname Utilitiesabsolute-pathname-p
: Pathname Utilitiescurrent-directory
: Directoriesdelete-directory
: Directoriesdelete-directory-and-files
: Directoriesdirectory-exists-p
: Directoriesdirectory-pathname-p
: Pathname Utilitiesenvironment
: Environmentenvironment-variable
: Environmentfile-exists-p
: Files and Symbolic Linksfile-kind
: Files and Symbolic Linksfile-permissions
: Files and Symbolic Linksget-monotonic-time
: Timelist-directory
: Directoriesmake-link
: Files and Symbolic Linksmakunbound-environment-variable
: Environmentmapdir
: Directoriesopen-temporary-file
: Files and Symbolic Linkspathname-as-directory
: Pathname Utilitiespathname-as-file
: Pathname Utilitiespathname-directory-pathname
: Pathname Utilitiesread-link
: Files and Symbolic Linksregular-file-exists-p
: Files and Symbolic Linksrelative-pathname-p
: Pathname Utilitiessystem-error
: Conditionsunmerge-pathnames
: Pathname Utilitiesuser-info
: Userswalk-directory
: Directorieswith-directory-iterator
: Directorieswith-temporary-file
: Files and Symbolic Links