Manipulate file names and attributes
file option name ?arg arg ...?
This command provides several operations on a file's name or attributes. name is the name of a file; if it starts with a tilde, then tilde substitution is done before executing the command (see the manual entry for Tcl_TildeSubst for details). option indicates what to do with the file name. Any unique abbreviation for option is acceptable. The valid options are:
Returns a decimal string giving the time when file name was last accessed. The time is measured in the standard POSIX fashion as seconds from a fixed starting time (often January 1, 1970). If the file doesn't exist or its access time cannot be queried then an error is generated.
Returns all of the characters in name up to but not including the last slash character. If there are no slashes in name then returns ".". If the last slash in name is its first character, then return "/".
Returns 1 if file name is executable by the current user, 0 otherwise.
Returns 1 if file name exists and the current user has search privileges for the directories leading to it, 0 otherwise.
Returns all of the characters in name after and including the last dot in name If there is no dot in name then returns the empty string.
Returns 1 if file name is a directory, 0 otherwise.
Returns 1 if file name is a regular file, 0 otherwise.
Same as stat option (see below) except uses the lstat kernel call instead of stat. This means that if name refers to a symbolic link the information returned in varName is for the link rather than the file it refers to. On systems that don't support symbolic links this option behaves exactly the same as the stat option.
Returns a decimal string giving the time when file name was last modified. The time is measured in the standard POSIX fashion as seconds from a fixed starting time (often January 1, 1970). If the file doesn't exist or its modified time cannot be queried then an error is generated.
eturns 1 if file name is owned by the current user, 0 otherwise.
Returns 1 if file name is readable by the current user, 0 otherwise.
Returns the value of the symbolic link given by name (i.e. the name of the file it points to). If name isn't a symbolic link or its value cannot be read, then an error is returned. On systems that don't support symbolic links this option is undefined.
Returns all of the characters in name up to but not including the last "." character in the name. If name doesn't contain a dot, then returns name.
Returns a decimal string giving the size of file name in bytes. If the file doesn't exist or its size cannot be queried then an error is generated.
Invokes the stat kernel call on name, and uses the variable given by varName to hold information returned from the kernel call. VarName is treated as an array variable, and the following elements of that variable are set: atime, ctime, dev, gid, ino , mode, mtime , nlink , size , type , uid. Each element except type is a decimal string with the value of the corresponding field from the stat return structure; see the manual entry for stat for details on the meanings of the values. The type element gives the type of the file in the same form returned by the command file type. This command returns an empty string.
Returns all of the characters in name after the last slash. If name contains no slashes then returns name.
Returns a string giving the type of file name, which will be one of file , director , characterSpecial , blockSpecial, fifo , link , or socket .
Returns 1 if file name is writable by the current user, 0 otherwise.
attributes, directory, file, name, stat