#2587 file copy -force fails when cross filesystem copy


f1 is a regular file
f2 is a regular file with read-only permissions

file copy -force $f1 $f2

Works if f1 and f2 are in a regular filesystem but fails if
f2 is in a different filesystem (e.g. inside a tclkit)

Andreas Kupries suggests this may be related to a flaw
in crossfilesystem copy function

And Vicent Darley finds out exactly where

The following test cases ilustrates the problem. The first
one pases the second one does not. You need to
execute it using

tclkit test.tcl -verbose ve

package require tcltest
package require mk4vfs

proc writeFile {dest text} {
set f [open $dest w]
puts -nonewline $f $text
close $f

proc readFile {dest} {
set f [open $dest r]
set r [::read $f]
close $f
return $r

tcltest::test copy1 {Copy file no permissions} {} {
foreach f {f1 f2} {
set $f [file join $::tcltest::testsDirectory $f]
file delete -force $f
writeFile $f $f
file attributes $f2 -permissions 0000
file copy -force $f1 $f2
set result [readFile $f2]
file delete -force $f1 $f2
set result
} {f1}

# For some reason, if both files in disk no problem, if
origin in tclkit, it fails
tcltest::test copy2 {Copy file from tclkit to disk no
permissions} {} {
set kitFile [file join $::tcltest::testsDirectory test.kit]
::vfs::mk4::Mount $kitFile $kitFile
set t $::tcltest::testsDirectory
set f2 [file join $t f2]
file delete -force $f2
writeFile $f2 f2
set f1 [file join $kitFile f1]
writeFile $f1 f1
file attributes $f2 -permissions 0000
file copy -force $f1 $f2
::vfs::unmount $kitFile
set result
} {f1}


  • Vince Darley

    Vince Darley - 2004-01-28

    diff -u with windows eols

  • Vince Darley

    Vince Darley - 2004-01-28

    Logged In: YES

    Attached is a patch to fix this and another issue. Please
    test (note: on unix the eol's in the patch must be converted

  • Nobody/Anonymous

    Logged In: NO

    Yes, it does indeed work now. Thanks!
    (patch took care automatically of CRLF issues too)

  • Vince Darley

    Vince Darley - 2004-01-29
    • status: open --> closed-fixed