Erich Rast <erich ’at snafu.de>
The File Utilities library is a collection of helper functions
for dealing with paths and files.
Note: Most of this library has been developed for older versions
of Racket. You should check if there is a built-in Racket library
function with the same functionality before using one from this library.
2 Function Reference
Returns the name part from a file or folder path.
is a already string, it is
returned without change, otherwise the name part
of the path is returned as by get-file-or-folder-name
Returns the name part of a file or folder path without the suffix.
Returns the suffix part of a file or folder path. If there are multiple
suffixes, only the last one is returned. If no suffix is present,
an empty string is returned.
Composes a file name out of a main part name, a number,
and a suffix string. If the number part n is #f
then no number will be added to the name part.
Returns a name string that is guaranteed to be unique within folder.
Caution: This procedure creates neat file names such as "file-3.txt"
for a given name "file.txt" but does so at the cost of checking for
existing files with number suffixes 1, 2, ..., so for performance reasons you
ought not use this function to create many files with the same base and suffix
part within a folder.
Returns the parent directory of a folder or #f if there is none.
Returns a file or directory path that is unique within the parent directory of
. The same performance caveat as for make-unique-name
if the two paths given likely point to the same location
in the file system, #f
otherwise. This method normalizes the
paths, but might yield false negatives under rare circumstances.
for a slower, but more reliable method to compar
e whether two paths point to the same file.
Returns #t if the two file paths alias the same file in the file system,
#f otherwise. This method requires read permissions on the files
and temporarily opens the files for reading. It cannot be used to compare
| source-directory : path?|
| destination-directory : path?|
Moves the source directory into the destination directory. This method might fail
with a filesystem exception if the source and destination directories do not reside on the same volume.
| source-directory : path?|
| dest-directory : path?|
| pred? : (path? .->. boolean/c)|
Copy all files in the source directory for which pred? returns true into
the destination directory. If a file or directory with the same name already exists in
the destination directory, then the target file or folder is renamed by adding a
number to it before its suffix.
Returns #t if the file is visible according to Unix naming
conventions, #f otherwise. This function only checks whether the
file name starts with "." and might not correctly identify other types of
invisible files (e.g. on OS X).
Count the lines in the port. The port must support line counting or else an exception is raised.
Move the file at source to the directory target.
This function also works accross volume boundaries, in case of which the file is copied
and the original file is deleted.
Returns #t if the given files are byte-for-byte identical, #f otherwise.