Version 5 of file exists

Updated 2005-11-22 19:45:33

file exists name

Returns 1 if file name exists and the current user has search privileges for the directories leading to it, 0 otherwise.


Q. What's the difference between file exists and file isfile?

A. file exists returns true (1) for all existing directories and regular files. file isfile returns true only for existing regular files.


Note: if [file exists $a] && ([file type $a] == "file") then [file exists ${a}/], which seems inconsistent.

In normal usage, it wouldn't bother anyone, but in VFS work, there can be a world of difference between a file "$a", a directory "$a", and a file "$a/". I suspect this stems from [file split a/b] == {a b} != {a b {}} - 20040613 CMcC


See also:


Tcl syntax help - Category Command - Category File