TABLE OF CONTENTS
::pwtk::xxxdir_backup_
SYNOPSIS
proc ::pwtk::xxxdir_backup_ {dir postfix} {
PURPOSE
Actual implementation of ::pwtk::outdir_backup & ::pwtk::wfcdir_backup
SOURCE
set xxxdir [file normalize [${dir}_query -hard]]; # N.B. if outdir/wfcdir is undefined, [${dir}_query -hard] returns "." if { ! [file exists $xxxdir] } { ::pwtk::error "$dir directory \"$xxxdir\" does not exist" 1 } if { $xxxdir eq "." } { set xxxdir [pwd] } set backup $xxxdir.$postfix # get a unique name set i "" while { [file exists ${backup}$i] } { if { $i eq "" } { set i 0 } incr i } set backup ${backup}$i print "Making a backup copy of '$dir':\n- $dir : $xxxdir\n- backup copy: $backup\n" try { file copy -force -- $xxxdir $backup } on error err { # this happens in the following cases: # 1. when the user does not have the permission to create $backup dir # 2. when the $xxxdir create files that the user does not have permission to copy # ... # # in such cases, return $xxxdir uplevel 1 [list ::pwtk::error "failed to make a backup copy of $dir\n\n$err"] return $xxxdir } return $backup }