#224 file copy patch to copy files not links

open-postponed
4
2014-08-14
2002-08-06
No

Jeff,

here's a patch (just one file changed) which will
make 'file copy' operate on files instead of links.
With this patch incorporated, one test (fCmd-
28.15) needs modifying as well. All other tests
should pass.

Discussion

  • Vince Darley

    Vince Darley - 2002-08-06

    diff -bu with windows eols against current cvs head

     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2002-08-08
    • priority: 9 --> 7
    • status: open --> open-fixed
     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2002-08-08

    Logged In: YES
    user_id=72656

    had to update several more tests, but it is working now for
    8.4b2.

     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2002-08-08
    • status: open-fixed --> closed-fixed
     
  • Hemang Lavana

    Hemang Lavana - 2002-08-08

    Logged In: YES
    user_id=81875

    Here's a corner case which results in error when <srcfile>
    is a softlink and file copy is invoked from another
    directory:

    godel:43> ls -lR
    .:
    total 16
    drwxr-xr-x 2 hlavana eng 141 Aug 8 05:47 test

    ./test:
    total 16
    lrwxrwxrwx 1 hlavana eng 3 Aug 8 05:47 bar -> foo
    -rw-r--r-- 1 hlavana eng 0 Aug 8 05:46 foo
    godel:44> /tmp/hlavana/tcltk/bin/tclsh8.4
    % file copy test/bar xxx
    error copying "test/bar" to "xxx": no such file or directory
    % cd test
    % file copy bar ../xxx
    % exit
    godel:45> ls -l
    total 16
    drwxr-xr-x 2 hlavana eng 141 Aug 8 05:47 test
    -rw-r--r-- 1 hlavana eng 0 Aug 8 05:46 xxx
    godel:46>

    Thus, softlinks pointing to relative paths need to converted
    into absolute paths first before invoking the real file copy.

     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2002-08-08
    • status: closed-fixed --> open-fixed
     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2002-08-08

    Logged In: YES
    user_id=72656

    this looks like it will have lots of little problems like this ... I'm
    backing out the functionality for now, leaving the code #if 0'd
    out. The more I think about it, the more it actually seems
    reasonable what Tcl was doing ... otherwise it seems like we
    have to provide all sorts of options to enable the old behavior
    for those that might have wanted it.

     
  • Nobody/Anonymous

    Logged In: NO

    This code should do it:

    Tcl_Obj *path = Tcl_FSLink(actualSource, NULL, 0);
    if (path == NULL) {
    break;
    }
    /*
    * Now we want to check if this is a relative path,
    * and if so, to make it absolute
    */
    if (Tcl_FSGetPathType(path) == TCL_PATH_RELATIVE) {
    Tcl_Obj *abs = Tcl_FSJoinToPath
    (actualSource, 1, &path);
    if (abs == NULL) break;
    Tcl_IncrRefCount(abs);
    Tcl_DecrRefCount(path);
    path = abs;
    }
    Tcl_DecrRefCount(actualSource);
    actualSource = path;
    counter++;

     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2002-09-02
    • priority: 7 --> 4
    • status: open-fixed --> open-postponed
     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2002-09-02

    Logged In: YES
    user_id=72656

    This has been postponed for beyond 8.4, until it can be
    further discussed. It's likely better to try it as a file
    copy option, or perhaps just as a tcllib function, due to
    all the funky cases that could be hit.

     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2002-10-16
    • assigned_to: hobbs --> nobody
     
  • Don Porter

    Don Porter - 2003-11-12
    • assigned_to: nobody --> vincentdarley