Miscellaneous File Utilities

Assorted file-handling utility functions.

Procedures

directory-read pathname

Fixes an annoying feature of MIT Scheme's default directory-read, where it would not list a directory unless the path ends with a "/"

list-files pathname

A recursive verison of directory-read. Returns, as a flat list of pathnames, all files in the given directory and its subdirectories.

md5 pathname

Computes the MD5 hash of a file, returning it as a number. The user must have the md5sum utility installed. Example:

 (md5 "/home/maciej/.emacs")
 ;Value: 267481038891216476457224829949509594393
 

make-path pathname

Creates a directory together with all parent directories that do not exist. Equivalent to mkdir -p in *nix

touch pathname

Equivalent to the *nix touch

file-in-directory dir file

Creates a pathname representing a file in a directory. For example:

 (file-in-directory "/usr" "bin")
 ;Value 22: #[pathname 22 "/usr/bin"]
 

files-differ? pathnameA pathnameB

Checks whether two (possibly binary) files differ by calling the diff utility. Both files have to exist.

copy-file from to

Copies a file from one path to another

path-move source dest

Path-equivalent of moving a file. The destination is interpreted to be a directory. For example:

(path-move "/tmp/a/b/pic.png" "/backup")
;Value 14: #[pathname 23 "/backup/pic.png"]

read-file-as-string pathname

Reads contents of a file and returns it as a string


Scheme Power Tools Documentation
(c) Maciej Pacula 2010-2011
http://mpacula.com