chickadee » directory-utils

Outdated egg!

This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for the CHICKEN 5 version of this egg, if it exists.

If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.

directory-utils

Documentation

pathname?

pathname? OBJprocedure

Does not verify existence of the file, just whether the pathname has a directory and/or file component.

check-pathname LOCATION OBJECT #!optional ARGNAMprocedure
error-pathname LOCATION OBJECT #!optional ARGNAMprocedure

filename?

filename? OBJprocedure

Does not verify existence of the file, just whether it has a directory component.

check-filename

error-filename

check-filename LOCATION OBJECT #!optional ARGNAMprocedure
error-filename LOCATION OBJECT #!optional ARGNAMprocedure

dot-filename?

dot-filename? PATHNAMEprocedure

Does the OBJECT name a file with a dot-name?

Does not verify existence of the file!

dot-pathname?

dot-pathname? PATHNAMEprocedure

Is any directory in the PATHNAME a dot-filename?

Does not verify existence of the file!

check-directory

check-directory LOCATION OBJECT #!optional ARGNAMprocedure

Does the OBJECT name an existing directory>

error-directory LOCATION OBJECT #!optional ARGNAMprocedure

directory-fold

(directory-fold FUNCTION IDENTITY DIRECTORY [#:dotfiles? DOTFILES?]) -> *procedure

Invokes FUNCTION on each filename in the DIRECTORY and the recursive value from IDENTITY. Returns the final value.

FUNCTION
(filename * -> *).
DOTFILES
boolean ; include files with a "." prefix ; Default #f.

Note that only the filename is passed and not the complete pathname. The "." and ".." filenames are not supplied no matter the DOTFILES? setting.

On a Windows platform hidden files have a hidden attribute so this routine is rather *nix centric.

create-pathname-directory

create-pathname-directory PATHNAMEprocedure

Ensures the directory component of PATHNAME exist.

Like the *nix `"mkdir -p `dirname PATHNAME`" command.

make-program-filename

make-program-filename COMMANDprocedure

Returns the platform specific form of an executable command filename.

On Windows the "exe" extension is added unless an extension is already present. Does nothing otherwise.

make-shell-filename

make-shell-filename COMMANDprocedure

Returns the platform specific form of a shell command filename.

On Windows the "bat" extension is added unless an extension is already present. Otherwise conditionally adds the "sh" extension.

file-exists-in-directory?

(file-exists-in-directory? FILENAME [DIRECTORY ...]) -> (or #f pathname)procedure

Returns the pathname when FILENAME exists in the DIRECTORY ..., otherwise #f.

DIRECTORY ... as make-pathname.

When only the FILENAME argument supplied then the same as file-exists?.

find-file-pathnames

(find-file-pathnames FILENAME [DIRECTORY | DIRECTORY-LIST] ...) -> (or #f (list-of pathname))procedure

Returns a list of all pathnames found for FILENAME in the supplied directory/directories, or #f when not found.

The list of pathnames is in the same relative order as that of the directory parameter(s).

find-program-pathnames

(find-program-pathnames COMMAND-NAME [DIRECTORY | DIRECTORY-LIST] ...) -> (or #f (list-of pathname))procedure

Returns a list of all pathnames found for COMMAND-NAME in the supplied directory/directories, or #f when not found.

Uses make-program-filename to make a filename.

On Windows also uses make-shell-filename to make a filename.

Does not ensure that the file is executable!

which-command-pathnames

which-command-pathnames COMMAND-NAME #!optional ENVIRONMENT-VARIABLEprocedure

Returns the pathnames of COMMAND-NAME in the ENVIRONMENT-VARIABLE where the file exists, or #f when nothing found.

The default ENVIRONMENT-VARIABLE is "PATH".

Uses the platform specific "PATH" environment variable element separator - a Windows #\;, and a *nix #\:.

which-command-pathname

which-command-pathname COMMAND-NAME #!optional ENVIRONMENT-VARIABLEprocedure

Same as which-command-pathnames but returns the first pathname only.

Like the *nix `which COMMAND-NAME` command.

remove-dotfiles

remove-dotfiles FILESprocedure

Remove dot files from a directory list. Useful with glob.

Directory Stack

directory-utility-stack
directory-utility-stack #!optional STACKparameter

Which stack to use for directory stack operations.

stack is from stack.

push-directory
push-directory DIRECTORYprocedure

Push the current directory and change to the string DIRECTORY.

pop-directory
pop-directoryprocedure

Pop the last directory and change to it.

pop-toplevel-directory
pop-toplevel-directoryprocedure

Pop the earliest directory and change to it.

Usage

(require-extension directory-utils)

Author

Kon Lovett

Version history

1.1.1
Fix dependency.
1.1.0
Add types.
1.0.6
fix test.
1.0.3
More tests.
1.0.2
Deprecated create-directory/parents.
1.0.1
1.0.0
Hello

License

Copyright (C) 2010-2018 Kon Lovett. All rights reserved.

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 ASIS, 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.

Contents »