TABLE OF CONTENTS


::pwtk::file_backup

SYNOPSIS

proc ::pwtk::file_backup {filename} {

PURPOSE

Backup the $filename file if the file exists.

RETURN VALUE

The name of the backup file (or empty string if the filename does not exist).

SOURCE

    if { [file exists $filename] } {
        set i ""        
        while { [file exists ${filename}.bck$i] } {
            if { $i == "" } { set i 0 }
            incr i
        }
        file copy -- $filename $filename.bck$i
        return $filename.bck$i
    }
    return {}
}