What is Tcl equivalent for UNIX \"cp -pL\" command? I cannot find it in file command description
For a single file: a) Get the real path to the file. b) Copy it. c) Set the attributes, modification time and access time.
Unfortunately, there does not appear to be any way to set the change time (creation time on Windows).
set fn sourcefn
set tofn targetfn
set nfn [file normalize [file readlink $fn]]
file copy -force $nfn $tofn
foreach {key} [list attributes mtime atime] {
set temp [file $key $nfn]
file $key $tofn {*}$temp
}
This is the pure Tcl solution that will work on unix, Mac OS X and Windows. Of course you could just do:
exec cp -pLf $from $to
References: file