Procedures associated with Path(s)


The procs below are not associated with a particular class. These procs were defined in Path.tcl, but no class was defined.
::tycho::autoName {stem}
Return a name constructed by augmenting the provided stem with a number to guarantee that the name is unique. A global (within the tycho namespace) array autoNames is used to keep track of the numbers used for each stem. This procedure should be used for window classes instead of the #auto facility in itcl to assign to the class valid names for windows. Window names must begin with a period. By convention, for a class named "Class", we would use the stem ".class". Thus, the single argument should be ".class". Note that if you invoke this outside the namespace "tycho", you must call it "::tycho::autoName".
::tycho::evalIfNewer {sourceFile targetFile args}
If targetFile does not exist, or if sourceFile has a modification time later than the file targetFile, then evaluate the rest of the args. This is similar to what the make command does.
::tycho::expandPath { path }
Expand a filename, returning an absolute filename with the complete path. The argument might begin with an environment variable, a global Tcl variable, or a reference to a user's home directory. If the argument begins with a dollar sign ($), then everything up to the first slash is taken to be a variable name. If an environment variable exists with that name, then the dollar sign and the variable name are replaced with the value of the environment variable. For example, if the value of of the environment variable TYCHO is /usr/tools/tycho, then
    ::tycho::expandPath \$TYCHO/tmp
returns /usr/tools/tycho/tmp. If there is no such environment variable, but a global Tcl variable with the given name exists, then the value of that variable is substituted. If no such variable is defined as well, then an error is reported. Similarly, "~user/foo" will be expanded (on Unix systems) to "/users/user/foo", assuming that "user" has his or her home directory at "/users/user". If there is no user named "user", or we are not on a Unix system, then an error is reported. In all cases, any extra spaces at the beginning or the end of the given path are removed. Moreover, filenames are normalized before being returned. Symbolic links are followed, as are fields in the path like "/../". Thus, any two references to the same path should return the same string.

Formerly, this procedure was in File.itcl, but it was moved so that it could be used in scripts that use itclsh, which does not have windows.#.

::ptkExpandEnvVar { path }
COMPATIBILITY procedure. Use ::tycho::expandPath.
::tycho::invoke { args }
Invoke an external program, passing it the specified arguments. The format of the command is exactly that of the Tcl "exec" command. The main purpose of this procedure is to generate an informative error message if the "exec" fails.
::tycho::isRelative {pathname}
Return true if the the pathname is not an absolute pathname, and it does not start with tilde or a dollar sign.
::tycho::mkdir { args }
Create a directory.
::tycho::pathEnvSearch {filename}
Search the user's PATH environment variable for filename.
::tycho::pathSearch {filename path}
Search the path list for filename, if it is found then return the directory where it was found. If it is not found, return the empty string.
::tycho::relativePath {srcFile dstFile}
Given two pathnames srcFile and dstFile, return a relative pathname that goes from the srcFile to the dstFile. This is useful for creating HTML links that are relative, thus avoiding the non-portable use of $TYCHO.
::tycho::rootDir {pathname}
Return the name of the root directory. Under Unix this is "/". Under Mac the volume name is returned. Under Windows.
::tycho::rm { args }
Remove a file FIXME: In tcl7.6, this should go away.
::tycho::rmIfNotWritable { file }
Remove a file if we can't open it for writing. Lots of times a user will have symbolic links to a master tree that they don't have write permission to. If one of these links is a derived file, such as a documentation file, then the user will not be able to update the documentation file if it is not writable by the user. The solution is to break the link.
::tycho::simplifyPath {pathName {envVarList {}}}
Given a path and a list of environment variables, try to simplify the path by checking to see if we can use an environment variable instead of a long string.

For example, if the TYCHO environment variable is set to /users/ptolemy/tycho, and this directory is actually automounted at /export/watson/watson2/ptolemy/tycho, and we pass simplifyPath the pathname /export/watson/watson2/ptolemy/tycho/README, then we should get back $TYCHO/README.

If we cannot simplify the pathname, then we return the original pathname.

If we specify a list of environment variables, then the first environment variable that matches a non-zero number of characters is the environment variable that is used

If we don't specify a list of environment variables (the default), then we return the shortest string that results from subsituting environment variables.

The following example expands and then simplifies $TYCHO/README.files:

::tycho::simplifyPath [::tycho::expandPath \
   [file join \$TYCHO README.files]] \
   [list TYCHO]]
.
::tycho::tmpFileName { {stem {tytmp}} {extension {}}}
Return a temporary filename that does not exist yet. The TMPDIR environment variable is as a base used if it is present, if TMPDIR is not present, then /tmp is used. If the optional arg `stem' is present, then a unique string is appended on to it. The stem arg defaults to tytmp. If the optional arg `extension' is present, then the extension is appended after the unique string is appended. If extension is the empty string then nothing is appended. The default is the empty string.

For example, the following command under Unix:

::tycho::tmpFileName myfile .itcl
might return something like /tmp/myfile1.itcl.
::tycho::uniqueFileName { {stem {tyuniq}} {extension {}}}
Return a filename that is unique, and does not yet exist If the optional arg `stem' is present, then a unique string is appended on to it. The stem arg defaults to tyuniq. If the optional arg `extension' is present, then the extension is appended after the unique string is appended.

For example

::tycho::uniqueFileName myfile .itcl
might return something like myfile1.itcl.

Index of classes



Author: Edward A. Lee
Contributor: Joel King, Farhana Sheikh, Christopher Hylands
Version: @(#)Path.tcl 1.29 12/15/96
Copyright: (c) 1995-1996 The Regents of the University of California.