Tcl Source Code

View Ticket
Login
Ticket UUID: 3597000
Title: [file copy] return value inconsistency
Type: Bug Created on: 2012-12-17 19:22:19
Submitter: bgriffin Assigned to: dgp
Subsystem: 37. File System Severity:
Priority: 5 Medium Last modified: 2013-03-19 21:35:14
Status: Closed Closed by: dgp
Resolution: Fixed Closed on: 2013-03-19 14:35:14
Version: obsolete: 8.5.13
Description:
The [file copy] command does not define a return value, yet when copying across file systems, say from a Trofs file system to the unix file system, [file copy] will return the number of bytes copied.  This return value inconsistency can be a nuisance.
User Comments:
ferrieux added on 2012-12-18 04:00:44:
The discrepancy comes from a different attitude various parts of the code towards interp-passing:
 - TclCopyChannel (aka fcopy), which is used for the cross-fs case, takes an interp and is documented to set the result to the number of bytes transferred
 - The per-fs ->copyFileProc, used otherwise for performance reasons (and its ability to copy links), happens to take no interp, and to return only TCL_OK or TCL_ERROR.

As a consequence, directly returning the number of bytes from copyFileProc seems out of reach within 8.x (compat).
One possibility though, would be to stat() the just-copied source or dest file, but that's ugly, slow, and subject to race conditions. Any better idea appreciated.

ferrieux added on 2012-12-18 04:03:49:
Another option is to use TSD (or a global in the unthreaded case). Not outstandingly elegant either.

dgp added on 2013-03-19 21:35:14:

allow_comments - 1

fix committed.