The Autopackage API

Table of Contents / Public library / Filesystem

Filesystem

Miscellaneous filesystem-related functions.

Functions in this category

resolveLinkSYMLINK
removeDir<DIRECTORY>
dirIsEmpty<DIRECTORY>
prune<DIRECTORY>
haveWriteAccess<DIRECTORY>


Details

resolveLink
Syntax: resolveLink SYMLINK
SYMLINK: A symbolic link file.
Outputs: The resolved filename.
Recursively resolve symbolic links.
Example:
touch foo
ln -s foo sym1
ln -s sym1 sym2
resolveLink sym2    # =>  foo


removeDir
Syntax: removeDir <DIRECTORY>
DIRECTORY: The directory to remove.
Returns: 0 if DIRECTORY is removed, 1 otherwise.
Recursively check if DIRECTORY is empty, and remove it if it is.
See also: dirIsEmpty()


dirIsEmpty
Syntax: dirIsEmpty <DIRECTORY>
DIRECTORY: A directory name.
Returns: 0 if DIRECTORY is empty, 1 if it's not.
Check whether DIRECTORY is empty. If DIRECTORY only contains empty subdirectories then DIRECTORY will be considered empty.


prune
Syntax: prune <DIRECTORY>
DIRECTORY: A directory.
If DIRECTORY is empty, change to the parent directory and delete DIRECTORY. Repeats until it reaches a directory that is no longer empty. See also: removeDir().
Example:
mkdir -p a/deep/directory
touch a/file
prune a/deep/directory
ls a/deep   # =>  "a/deep: no such file or directory"


haveWriteAccess
Syntax: haveWriteAccess <DIRECTORY>
DIRECTORY: The directory name.
Returns: 0 if we have write access, 1 if we don't.
Checks whether we have write access to DIRECTORY.


Last update: 10/6/2003