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 standardansifacilities.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-pathnamesin both cases.)
Class precedence list:
system-error, error, serious-condition, condition, tBase class for errors signalled by Osicat.
environment-variablereturns the environment variable identified byname, ornilif one does not exist.namecan either be a symbol or a string.
setfenvironment-variablesets the environment variable identified bynametovalue. Bothnameandvaluecan be either a symbols or strings. Signals an error on failure.
environmentreturns the current environment as an assoc-list.setfenvironmentmodifies the environment its argument.Often it is preferable to use
setfenvironment-variableandmakunbound-environment-variableto modify the environment instead ofsetfenvironment.
Removes the environment variable identified by
namefrom the current environment.namecan be either a string or a symbol. Returns the string designated byname. Signals an error on failure.
current-directoryreturns the operating system's current directory, which may or may not correspond to*default-pathname-defaults*.
setfcurrent-directorychanges the operating system's current directory to thepathspec. An error is signalled if thepathspecis wild or does not designate a directory.
Recursively deletes all files and directories within the directory designated by the non-wild pathname designator
dirnameincludingdirnameitself.if-does-not-existmust be one of:erroror:ignorewhere:errormeans that an error will be signaled if the directorydirnamedoes not exist.
Deletes the directory designated by
pathspec. Returnst. The directory must be empty. Symbolic links are not followed.Signals an error if
pathspecis wild, doesn't designate a directory, or if the directory could not be deleted.
Checks whether the file named by the pathname designator
pathspecexists and is a directory. Returns its truename if this is the case,nilotherwise. 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-pathnamesis 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
pathspecin turn and returns a list of the results. Binds*default-pathname-defaults*to the directory designated by pathspec round to function call.If
pathspecdesignates a symbolic link, it is implicitly resolved.Signals an error if
pathspecis wild or doesn't designate a directory.
Recursively applies the function
fnto all files within the directory named by the non-wild pathname designatordirnameand all of its sub-directories. Returnston success.
fnwill only be applied to files for which the functiontestreturns a true value. Ifdirectoriesis notnil,fnandtestare applied to directories as well. Ifdirectoriesis:depth-first,fnwill be applied to the directory's contents first. Ifdirectoriesis:breadth-firstandtestreturnsnil, the directory's content will be skipped.if-does-not-existmust be one of:erroror:ignorewhere:errormeans that an error will be signaled if the directorydirnamedoes not exist.
pathspecmust 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,
iteratoris 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
pathspecis wild or does not designate a directory.
Checks whether the file named by the pathname designator
pathspecexists, if this is the case andfile-kindis specified it also checks the file kind. If the tests succeed, return two values: truename and file kind ofpathspec,nilotherwise. Follows symbolic links.
Checks whether the file named by the pathname designator
pathspecexists and is a regular file. Returns its truename if this is the case,nilotherwise. Follows symbolic links.
Returns a keyword indicating the kind of file designated by
pathspec, ornilif the file does not exist. Does not follow symbolic links by default.Possible file-kinds in addition to
nilare::regular-file,:symbolic-link,:directory,:pipe,:socket,:character-device, and:block-device. Iffollow-symlinksis non-NIL andpathspecdesignates a broken symlink returns:brokenas second value.Signals an error if
pathspecis wild.
file-permissionsreturns a list of keywords identifying the permissions ofpathspec.
setffile-permissionssets the permissions ofpathspecas identified by the symbols in list.If
pathspecdesignates 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
pathspecis 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.
pathspecserves as template for the file to be created: a certain number of random characters will be concatenated to the file component ofpathspec. Ifpathspechas no directory component, the file will be created inside*temporary-directory*. The file itself is unlinked once it has been opened.
element-typespecifies the unit of transaction of the stream. Consider usingwith-temporary-fileinstead of this function.On failure, a
file-errormay be signalled.
Within the lexical scope of the body,
streamis connected to a temporary file as created byopen-temporary-file. The file is closed automatically oncebodyexits.
Creates
linkthat points totarget. Defaults to a symbolic link, but giving a non-NIL value to the keyword argument:hardcreates 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
pathspecis wild, or does not designate a symbolic link.
user-inforeturns the password entry for the given name or numerical userid, as an assoc-list.
Returns
tif thepathspecdesignates an absolute pathname,nilotherwise.
Returns an absolute pathname corresponding to
pathspecby merging it withdefault, and (CURRENT-DIRECTORY) if necessary.
Returns
nilifpathspec(a pathname designator) does not designate a directory,pathspecotherwise. It is irrelevant whether file or directory designated bypathspecdoes actually exist.
Converts the non-wild pathname designator
pathspecto directory form.
Converts the non-wild pathname designator
pathspecto file form.
Returns
tif thepathspecdesignates a relative pathname,nilotherwise.
Removes those leading directory components from
pathspecthat 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