You are looking at historical revision 19541 of this page. It may differ significantly from its current revision.

directory-utils

Documentation

pathname?

[procedure] (pathname? OBJ)

Does not verify existence of the file, just whether it has dir+fil.

[procedure] (check-pathname LOCATION OBJECT [ARGNAM]) => *
[procedure] (error-pathname LOCATION OBJECT [ARGNAM])

filename?

[procedure] (filename? OBJ)

Does not verify existence of the file, just whether it doesn't have dir.

[procedure] (check-filename LOCATION OBJECT [ARGNAM]) => *
[procedure] (error-filename LOCATION OBJECT [ARGNAM])

dot-filename?

[procedure] (dot-filename? PATHNAME) => boolean

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

Does not verify existence of the file!

dot-pathname?

[procedure] (dot-pathname? PATHNAME) => boolean

Is any dir in the PATHNAME a dot-filename?

Does not verify existence of the file!

check-directory

[procedure] (check-directory LOCATION OBJECT [ARGNAM]) => *

Does the OBJECT name an existing directory>

[procedure] (error-directory LOCATION OBJECT [ARGNAM])

directory-fold

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

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

Note that only the filename is passed and not the complete pathname.

FUNCTION is a (procedure (filename *) *).

IDENTITY default is '().

DIRECTORY default is "./".

DOTFILES is a boolean indicating whether files with a "." prefix are included in the fold.

create-directory/parents

[procedure] (create-directory/parents DIRECTORY)

Ensures the directory pathname DIRECTORY exists.

Like the *NIX `"mkdir -p DIRECTORY" command.

create-pathname-directory

[procedure] (create-pathname-directory PATHNAME)

Ensures the directory component of PATHNAME exist.

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

make-program-filename

[procedure] (make-program-filename COMMAND)

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 on other platforms.

make-shell-filename

[procedure] (make-shell-filename COMMAND)

Returns the platform specific form of a shell command filename.

On Windows the bat extension is added unless an extension is already present. On *NIX platforms adds .sh.

file-exists/directory?

[procedure] (file-exists/directory? FILENAME [DIRECTORY | DIRECTORY-LIST])

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

DIRECTORY-LIST is as for make-pathname.

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

find-file-pathnames

[procedure] (find-file-pathnames FILENAME [DIRECTORY | DIRECTORY-LIST] ...)

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

[procedure] (find-program-pathnames COMMAND-NAME [DIRECTORY | DIRECTORY-LIST] ...)

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

[procedure] (which-command-pathnames COMMAND-NAME [ENVIRONMENT-VARIABLE])

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 ';' for Windows, & a ':' otherwise.

which-command-pathname

[procedure] (which-command-pathname COMMAND-NAME [ENVIRONMENT-VARIABLE])

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

Like the *NIX "which COMMAND-NAME" command.

remove-dotfiles

[procedure] (remove-dotfiles FILES)

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

Directory Stack

push-directory
[procedure] (push-directory DIRECTORY)

Push the current directory and change to the DIRECTORY.

pop-directory
[procedure] (pop-directory)

Pop the last directory and change to it.

pop-toplevel-directory
[procedure] (pop-toplevel-directory)

Pop the earliest directory and change to it.

Usage

(require-extension directory-utils)

Author

kon lovett

Version history

1.0.0
Hello

License

Copyright (C) 2010 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.