File 'base/file.tcl' (part of 'Pool_Base')

Description (short)
file commands
Written by
Andreas Kupries
Description
Useful file commands like link resolution, directory traversal, ...
Depends on
Tcl
Keywords
script location, descend directories, directory hierarchy, directory scan, subdirectory list, file scan, softlink resolution, path stats


::pool::file::descendDirs (var path script)

Executes script for all directories found in the directory hierarchy beginning at path. The script has immediate access to the variable var, which will be set to the current directory before each execution. The working directory, as delivered by `pwd`, will be set to the current directory too. The command takes great care to avoid looping (which might be caused by circular links)
Argument: var Variable used to transfer the current path into the script.
Argument: path Start of the directory hierarchy to follow.
Argument: script Tcl code executed upon each iteration.

::pool::file::descendFiles (var path script)

Executes script for all files found in the directory hierarchy beginning at path. The script has immediate access to the variable var, which will be set to the current file before each execution. The working directory, as delivered by `pwd`, will be set to the current directory too. Implemented in terms of ::pool::file::descendDirs
Argument: var Variable used to transfer the current path into the script
Argument: path Start of the directory hierarchy to follow.
Argument: script Tcl code executed upon each iteration.

::pool::file::followLink (path)

Follows path to its destination. Recursion is used to step through all intermediate softlinks. path is returned unchanged if it is a regular file or directory.
Notes: Only the last component of path is followed, any softlinks higher in the path are not handled.
Argument: path The path to follow.
Returns: Final destination of path.

::pool::file::here ()

Determines the location of the script file currently active.
Returns: The path to the directory containing the active script

::pool::file::normalizePath (path)

A path containing '.' and/or '..' will be normalized, i.e. these components will be removed and the preceding path is modified accordingly. Empty path elements are handled like '.' To prevent mishandling of leading '..'s the current working directory will be prepended if path is relative.
Dangers: This code does *not* account for (soft)links. See ::pool::file::followLink and ::pool::file::resolveLinks for that.
Argument: path The path to normalize.
Returns: The normalized path.

::pool::file::normalizeUnixPath (path)

Same as ::pool::file::normalizePath, but unconditionally uses '/' as path separator.
Dangers: The code used here will mishandle leading ..'s
Notes: This is not platform independent, but quite nice for handling of internet urls. Because of this the working directory is NOT tacked on to the front of the path.
Argument: path The path to normalize.
Returns: The normalized path.

::pool::file::realname (path)

by Maurice Diamantini
Generates the canonical name of path via resolution of all softlinks and elimination of relative directions.
Notes: I rewrote Maurice code to use the procedures I already had in this file.
Argument: path The path to follow.
Returns: Canonical name of path.

::pool::file::resolveLinks (path)

by Maurice Diamantini
Follows path to its destination. Recursion is used to step through all intermediate softlinks. path is returned unchanged if it is a regular file or directory. In contrast to ::pool::file::followLink all softlinks in the path are resolved.
Notes: I rewrote Maurice code to use the procedures I already had in this file.
Argument: path The path to follow.
Returns: Nearly canonical name of path. Nearly, as it may contain '.' and '..'.

::pool::file::subdirs (dir)

Find all subdirectories of dir. Softlinks pointing to directories are part of the result too.
Argument: dir The directory to search in.
Returns: List containing all found subdirectories


Generated by AutoDoc 2.4 at 09/14/2000, invoked by Andreas Kupries