Welcome, guest | Sign In | My Account | Store | Cart

Check if file exists. Set return code.

Tcl, 12 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Proc - check if file exists. Set return code.
###############################################
proc checkFile {fileName} {
    
    if {[file exists $fileName] == 1} {
       puts "\nfile exists: $fileName\n"	
       return 0
       } else {
               puts "\nfile does not exist: $fileName\n"	
	       return -code error 1
    }
}
Created by Patrick Finnegan on Sun, 23 Jan 2005 (MIT)
Tcl recipes (162)
Patrick Finnegan's recipes (56)

Required Modules

  • (none specified)

Other Information and Tasks