Tcl Source Code

Hex Artifact Content
Login

Artifact 32e017b3052730d6440ff2395ea6f61dc9b974f4:

Attachment "c84b_rename.patch" to ticket [928545ffff] added by tauvan 2004-05-07 00:54:36.
0000: 00 11 63 38 34 62 5f 72 65 6e 61 6d 65 2e 70 61  ..c84b_rename.pa
0010: 74 63 68 00 00 00 00 00 00 00 00 00 00 00 00 00  tch.............
0020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0050: 00 00 00 00 00 1b 68 00 00 00 00 c2 bc c2 bf c3  ......h....¼¿�
0060: a8 c2 b3 c2 bc c2 bf c3 a8 c3 af 00 00 00 6d 42  �³¼¿èï...mB
0070: 49 4e 00 00 00 00 00 00 00 00 00 00 00 00 00 00  IN..............
0080: 00 00 c2 82 c2 81 7a c3 96 00 00 49 6e 64 65 78  ..‚zÖ..Index
0090: 3a 20 74 65 73 74 73 2f 66 43 6d 64 2e 74 65 73  : tests/fCmd.tes
00a0: 74 0a 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  t.==============
00b0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
00c0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
00d0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
00e0: 3d 3d 3d 3d 3d 0a 52 43 53 20 66 69 6c 65 3a 20  =====.RCS file: 
00f0: 2f 63 76 73 72 6f 6f 74 2f 74 63 6c 2f 74 63 6c  /cvsroot/tcl/tcl
0100: 2f 74 65 73 74 73 2f 66 43 6d 64 2e 74 65 73 74  /tests/fCmd.test
0110: 2c 76 0a 72 65 74 72 69 65 76 69 6e 67 20 72 65  ,v.retrieving re
0120: 76 69 73 69 6f 6e 20 31 2e 32 36 2e 32 2e 34 0a  vision 1.26.2.4.
0130: 64 69 66 66 20 2d 75 20 2d 70 20 2d 72 31 2e 32  diff -u -p -r1.2
0140: 36 2e 32 2e 34 20 66 43 6d 64 2e 74 65 73 74 0a  6.2.4 fCmd.test.
0150: 2d 2d 2d 20 74 65 73 74 73 2f 66 43 6d 64 2e 74  --- tests/fCmd.t
0160: 65 73 74 09 37 20 4f 63 74 20 32 30 30 33 20 31  est.7 Oct 2003 1
0170: 35 3a 35 37 3a 33 36 20 2d 30 30 30 30 09 31 2e  5:57:36 -0000.1.
0180: 32 36 2e 32 2e 34 0a 2b 2b 2b 20 74 65 73 74 73  26.2.4.+++ tests
0190: 2f 66 43 6d 64 2e 74 65 73 74 09 36 20 4d 61 79  /fCmd.test.6 May
01a0: 20 32 30 30 34 20 31 36 3a 33 33 3a 35 36 20 2d   2004 16:33:56 -
01b0: 30 30 30 30 0a 40 40 20 2d 31 37 37 38 2c 36 20  0000.@@ -1778,6 
01c0: 2b 31 37 37 38 2c 31 30 36 20 40 40 20 74 65 73  +1778,106 @@ tes
01d0: 74 20 66 43 6d 64 2d 31 38 2e 31 36 20 7b 54 63  t fCmd-18.16 {Tc
01e0: 6c 46 69 6c 65 52 65 6e 61 6d 65 43 6d 64 3a 20  lFileRenameCmd: 
01f0: 72 65 6e 61 6d 0a 20 7d 20 7b 31 7d 0a 20 0a 20  renam. } {1}. . 
0200: 0a 2b 23 63 61 6e 20 6e 6f 74 20 6f 76 65 72 77  .+#can not overw
0210: 72 69 74 65 20 61 20 73 79 6d 6c 69 6e 6b 20 77  rite a symlink w
0220: 69 74 68 20 73 79 6d 6c 69 6e 6b 3b 20 70 6c 61  ith symlink; pla
0230: 63 65 73 20 73 79 6d 6c 69 6e 6b 20 69 6e 73 69  ces symlink insi
0240: 64 65 20 6e 65 77 20 6e 61 6d 65 27 73 20 6f 72  de new name's or
0250: 69 67 69 6e 61 6c 0a 2b 74 65 73 74 20 66 43 6d  iginal.+test fCm
0260: 64 2d 31 38 2e 31 37 20 7b 54 63 6c 46 69 6c 65  d-18.17 {TclFile
0270: 52 65 6e 61 6d 65 43 6d 64 3a 20 72 65 6e 61 6d  RenameCmd: renam
0280: 65 20 73 79 6d 6c 69 6e 6b 20 77 69 74 68 20 73  e symlink with s
0290: 79 6d 6c 69 6e 6b 20 66 61 69 6c 73 20 2d 66 6f  ymlink fails -fo
02a0: 72 63 65 7d 20 7b 75 6e 69 78 4f 6e 6c 79 20 6e  rce} {unixOnly n
02b0: 6f 74 52 6f 6f 74 7d 20 7b 0a 2b 20 20 20 20 63  otRoot} {.+    c
02c0: 61 74 63 68 20 7b 66 69 6c 65 20 64 65 6c 65 74  atch {file delet
02d0: 65 20 2d 66 6f 72 63 65 20 2d 2d 20 74 66 61 31  e -force -- tfa1
02e0: 20 74 66 61 6c 69 6e 6b 20 74 66 61 33 7d 0a 2b   tfalink tfa3}.+
02f0: 09 0a 2b 20 20 20 20 66 69 6c 65 20 6d 6b 64 69  ..+    file mkdi
0300: 72 20 74 66 61 31 0a 2b 20 20 20 20 63 72 65 61  r tfa1.+    crea
0310: 74 65 66 69 6c 65 20 5b 66 69 6c 65 20 6a 6f 69  tefile [file joi
0320: 6e 20 74 66 61 31 2f 74 66 61 32 5d 0a 2b 20 20  n tfa1/tfa2].+  
0330: 20 20 66 69 6c 65 20 6c 69 6e 6b 20 2d 73 79 6d    file link -sym
0340: 62 6f 6c 69 63 20 74 66 61 6c 69 6e 6b 20 74 66  bolic tfalink tf
0350: 61 31 0a 2b 20 20 20 20 66 69 6c 65 20 6c 69 6e  a1.+    file lin
0360: 6b 20 2d 73 79 6d 62 6f 6c 69 63 20 74 66 61 33  k -symbolic tfa3
0370: 20 74 66 61 31 0a 2b 20 20 20 20 66 69 6c 65 20   tfa1.+    file 
0380: 72 65 6e 61 6d 65 20 2d 66 6f 72 63 65 20 74 66  rename -force tf
0390: 61 6c 69 6e 6b 20 74 66 61 33 0a 2b 20 20 20 20  alink tfa3.+    
03a0: 73 65 74 20 72 65 73 75 6c 74 20 5b 65 78 70 72  set result [expr
03b0: 20 5b 73 74 72 69 6e 67 20 63 6f 6d 70 61 72 65   [string compare
03c0: 20 5b 66 69 6c 65 20 74 79 70 65 20 74 66 61 33   [file type tfa3
03d0: 5d 20 22 6c 69 6e 6b 22 5d 20 3d 3d 20 30 5d 0a  ] "link"] == 0].
03e0: 2b 20 20 20 20 66 69 6c 65 20 64 65 6c 65 74 65  +    file delete
03f0: 20 74 66 61 31 2f 74 66 61 32 0a 2b 20 20 20 20   tfa1/tfa2.+    
0400: 66 69 6c 65 20 64 65 6c 65 74 65 20 2d 66 6f 72  file delete -for
0410: 63 65 20 74 66 61 33 0a 2b 20 20 20 20 73 65 74  ce tfa3.+    set
0420: 20 72 65 73 75 6c 74 0a 2b 7d 20 7b 31 7d 0a 2b   result.+} {1}.+
0430: 0a 2b 23 73 61 6d 65 20 61 73 20 61 62 6f 76 65  .+#same as above
0440: 20 22 2d 66 6f 72 63 65 22 20 6e 6f 20 65 66 66   "-force" no eff
0450: 65 63 74 0a 2b 74 65 73 74 20 66 43 6d 64 2d 31  ect.+test fCmd-1
0460: 38 2e 31 38 20 7b 54 63 6c 46 69 6c 65 52 65 6e  8.18 {TclFileRen
0470: 61 6d 65 43 6d 64 3a 20 72 65 6e 61 6d 65 20 73  ameCmd: rename s
0480: 79 6d 6c 69 6e 6b 20 77 69 74 68 20 73 79 6d 6c  ymlink with syml
0490: 69 6e 6b 20 66 61 69 6c 73 20 6e 6f 20 2d 66 6f  ink fails no -fo
04a0: 72 63 65 7d 20 7b 75 6e 69 78 4f 6e 6c 79 20 6e  rce} {unixOnly n
04b0: 6f 74 52 6f 6f 74 7d 20 7b 0a 2b 20 20 20 20 63  otRoot} {.+    c
04c0: 61 74 63 68 20 7b 66 69 6c 65 20 64 65 6c 65 74  atch {file delet
04d0: 65 20 2d 66 6f 72 63 65 20 2d 2d 20 74 66 61 31  e -force -- tfa1
04e0: 20 74 66 61 6c 69 6e 6b 20 74 66 61 33 7d 0a 2b   tfalink tfa3}.+
04f0: 09 0a 2b 20 20 20 20 66 69 6c 65 20 6d 6b 64 69  ..+    file mkdi
0500: 72 20 74 66 61 31 0a 2b 20 20 20 20 63 72 65 61  r tfa1.+    crea
0510: 74 65 66 69 6c 65 20 5b 66 69 6c 65 20 6a 6f 69  tefile [file joi
0520: 6e 20 74 66 61 31 2f 74 66 61 32 5d 0a 2b 20 20  n tfa1/tfa2].+  
0530: 20 20 66 69 6c 65 20 6c 69 6e 6b 20 2d 73 79 6d    file link -sym
0540: 62 6f 6c 69 63 20 74 66 61 6c 69 6e 6b 20 74 66  bolic tfalink tf
0550: 61 31 0a 2b 20 20 20 20 66 69 6c 65 20 6c 69 6e  a1.+    file lin
0560: 6b 20 2d 73 79 6d 62 6f 6c 69 63 20 74 66 61 33  k -symbolic tfa3
0570: 20 74 66 61 31 0a 2b 20 20 20 20 6c 69 73 74 20   tfa1.+    list 
0580: 5b 63 61 74 63 68 20 7b 66 69 6c 65 20 72 65 6e  [catch {file ren
0590: 61 6d 65 20 74 66 61 6c 69 6e 6b 20 74 66 61 33  ame tfalink tfa3
05a0: 7d 20 6d 73 67 5d 20 24 6d 73 67 0a 2b 20 20 20  } msg] $msg.+   
05b0: 20 66 69 6c 65 20 64 65 6c 65 74 65 20 74 66 61   file delete tfa
05c0: 31 2f 74 66 61 32 0a 2b 20 20 20 20 66 69 6c 65  1/tfa2.+    file
05d0: 20 64 65 6c 65 74 65 20 2d 66 6f 72 63 65 20 74   delete -force t
05e0: 66 61 33 0a 2b 20 20 20 20 73 65 74 20 6d 73 67  fa3.+    set msg
05f0: 0a 2b 7d 20 7b 7d 0a 2b 0a 2b 23 63 61 6e 20 6e  .+} {}.+.+#can n
0600: 6f 74 20 6f 76 65 72 77 72 69 74 65 20 61 20 73  ot overwrite a s
0610: 79 6d 6c 69 6e 6b 20 77 69 74 68 20 64 69 72 3b  ymlink with dir;
0620: 20 70 6c 61 63 65 73 20 73 79 6d 6c 69 6e 6b 20   places symlink 
0630: 69 6e 73 69 64 65 20 6e 65 77 20 6e 61 6d 65 0a  inside new name.
0640: 2b 74 65 73 74 20 66 43 6d 64 2d 31 38 2e 31 39  +test fCmd-18.19
0650: 20 7b 54 63 6c 46 69 6c 65 52 65 6e 61 6d 65 43   {TclFileRenameC
0660: 6d 64 3a 20 72 65 6e 61 6d 65 20 73 79 6d 6c 69  md: rename symli
0670: 6e 6b 20 77 69 74 68 20 64 69 72 20 66 61 69 6c  nk with dir fail
0680: 73 20 2d 66 6f 72 63 65 7d 20 7b 75 6e 69 78 4f  s -force} {unixO
0690: 6e 6c 79 20 6e 6f 74 52 6f 6f 74 7d 20 7b 0a 2b  nly notRoot} {.+
06a0: 20 20 20 20 63 61 74 63 68 20 7b 66 69 6c 65 20      catch {file 
06b0: 64 65 6c 65 74 65 20 2d 66 6f 72 63 65 20 2d 2d  delete -force --
06c0: 20 74 66 61 31 20 74 66 61 6c 69 6e 6b 20 74 66   tfa1 tfalink tf
06d0: 61 33 7d 0a 2b 09 0a 2b 20 20 20 20 66 69 6c 65  a3}.+..+    file
06e0: 20 6d 6b 64 69 72 20 74 66 61 31 0a 2b 20 20 20   mkdir tfa1.+   
06f0: 20 63 72 65 61 74 65 66 69 6c 65 20 5b 66 69 6c   createfile [fil
0700: 65 20 6a 6f 69 6e 20 74 66 61 31 2f 74 66 61 32  e join tfa1/tfa2
0710: 5d 0a 2b 20 20 20 20 66 69 6c 65 20 6c 69 6e 6b  ].+    file link
0720: 20 2d 73 79 6d 62 6f 6c 69 63 20 74 66 61 6c 69   -symbolic tfali
0730: 6e 6b 20 74 66 61 31 0a 2b 20 20 20 20 66 69 6c  nk tfa1.+    fil
0740: 65 20 6d 6b 64 69 72 20 74 66 61 33 0a 2b 20 20  e mkdir tfa3.+  
0750: 20 20 66 69 6c 65 20 72 65 6e 61 6d 65 20 2d 66    file rename -f
0760: 6f 72 63 65 20 74 66 61 6c 69 6e 6b 20 74 66 61  orce tfalink tfa
0770: 33 0a 2b 20 20 20 20 73 65 74 20 72 65 73 75 6c  3.+    set resul
0780: 74 20 5b 65 78 70 72 20 5b 73 74 72 69 6e 67 20  t [expr [string 
0790: 63 6f 6d 70 61 72 65 20 5b 66 69 6c 65 20 74 79  compare [file ty
07a0: 70 65 20 74 66 61 33 5d 20 22 6c 69 6e 6b 22 5d  pe tfa3] "link"]
07b0: 20 3d 3d 20 30 5d 0a 2b 20 20 20 20 66 69 6c 65   == 0].+    file
07c0: 20 64 65 6c 65 74 65 20 74 66 61 31 2f 74 66 61   delete tfa1/tfa
07d0: 32 0a 2b 20 20 20 20 66 69 6c 65 20 64 65 6c 65  2.+    file dele
07e0: 74 65 20 2d 66 6f 72 63 65 20 74 66 61 6c 69 6e  te -force tfalin
07f0: 6b 0a 2b 20 20 20 20 73 65 74 20 72 65 73 75 6c  k.+    set resul
0800: 74 0a 2b 7d 20 7b 30 7d 0a 2b 0a 2b 23 73 61 6d  t.+} {0}.+.+#sam
0810: 65 20 61 73 20 61 62 6f 76 65 20 22 2d 66 6f 72  e as above "-for
0820: 63 65 22 20 6e 6f 20 65 66 66 65 63 74 0a 2b 74  ce" no effect.+t
0830: 65 73 74 20 66 43 6d 64 2d 31 38 2e 32 30 20 7b  est fCmd-18.20 {
0840: 54 63 6c 46 69 6c 65 52 65 6e 61 6d 65 43 6d 64  TclFileRenameCmd
0850: 3a 20 72 65 6e 61 6d 65 20 73 79 6d 6c 69 6e 6b  : rename symlink
0860: 20 77 69 74 68 20 64 69 72 20 66 61 69 6c 73 20   with dir fails 
0870: 6e 6f 20 2d 66 6f 72 63 65 7d 20 7b 75 6e 69 78  no -force} {unix
0880: 4f 6e 6c 79 20 6e 6f 74 52 6f 6f 74 7d 20 7b 0a  Only notRoot} {.
0890: 2b 20 20 20 20 63 61 74 63 68 20 7b 66 69 6c 65  +    catch {file
08a0: 20 64 65 6c 65 74 65 20 2d 66 6f 72 63 65 20 2d   delete -force -
08b0: 2d 20 74 66 61 31 20 74 66 61 6c 69 6e 6b 20 74  - tfa1 tfalink t
08c0: 66 61 33 7d 0a 2b 09 0a 2b 20 20 20 20 66 69 6c  fa3}.+..+    fil
08d0: 65 20 6d 6b 64 69 72 20 74 66 61 31 0a 2b 20 20  e mkdir tfa1.+  
08e0: 20 20 63 72 65 61 74 65 66 69 6c 65 20 5b 66 69    createfile [fi
08f0: 6c 65 20 6a 6f 69 6e 20 74 66 61 31 2f 74 66 61  le join tfa1/tfa
0900: 32 5d 0a 2b 20 20 20 20 66 69 6c 65 20 6c 69 6e  2].+    file lin
0910: 6b 20 2d 73 79 6d 62 6f 6c 69 63 20 74 66 61 6c  k -symbolic tfal
0920: 69 6e 6b 20 74 66 61 31 0a 2b 20 20 20 20 66 69  ink tfa1.+    fi
0930: 6c 65 20 6d 6b 64 69 72 20 74 66 61 33 0a 2b 20  le mkdir tfa3.+ 
0940: 20 20 20 6c 69 73 74 20 5b 63 61 74 63 68 20 7b     list [catch {
0950: 66 69 6c 65 20 72 65 6e 61 6d 65 20 74 66 61 6c  file rename tfal
0960: 69 6e 6b 20 74 66 61 33 7d 20 6d 73 67 5d 20 24  ink tfa3} msg] $
0970: 6d 73 67 0a 2b 20 20 20 20 66 69 6c 65 20 64 65  msg.+    file de
0980: 6c 65 74 65 20 74 66 61 31 2f 74 66 61 32 0a 2b  lete tfa1/tfa2.+
0990: 20 20 20 20 66 69 6c 65 20 64 65 6c 65 74 65 20      file delete 
09a0: 2d 66 6f 72 63 65 20 74 66 61 33 0a 2b 20 20 20  -force tfa3.+   
09b0: 20 73 65 74 20 6d 73 67 0a 2b 7d 20 7b 7d 0a 2b   set msg.+} {}.+
09c0: 0a 2b 23 63 61 6e 20 6f 76 65 72 77 72 69 74 65  .+#can overwrite
09d0: 20 61 20 73 79 6d 6c 69 6e 6b 20 77 69 74 68 20   a symlink with 
09e0: 66 69 6c 65 3b 20 64 65 73 74 72 6f 79 73 20 66  file; destroys f
09f0: 69 6c 65 3b 20 20 2d 66 6f 72 63 65 20 77 6f 72  ile;  -force wor
0a00: 6b 73 0a 2b 74 65 73 74 20 66 43 6d 64 2d 31 38  ks.+test fCmd-18
0a10: 2e 32 31 20 7b 54 63 6c 46 69 6c 65 52 65 6e 61  .21 {TclFileRena
0a20: 6d 65 43 6d 64 3a 20 72 65 6e 61 6d 65 20 73 79  meCmd: rename sy
0a30: 6d 6c 69 6e 6b 20 77 69 74 68 20 66 69 6c 65 20  mlink with file 
0a40: 2d 66 6f 72 63 65 7d 20 7b 75 6e 69 78 4f 6e 6c  -force} {unixOnl
0a50: 79 20 6e 6f 74 52 6f 6f 74 7d 20 7b 0a 2b 20 20  y notRoot} {.+  
0a60: 20 20 63 61 74 63 68 20 7b 66 69 6c 65 20 64 65    catch {file de
0a70: 6c 65 74 65 20 2d 66 6f 72 63 65 20 2d 2d 20 74  lete -force -- t
0a80: 66 61 31 20 74 66 61 6c 69 6e 6b 20 74 66 61 33  fa1 tfalink tfa3
0a90: 7d 0a 2b 09 0a 2b 20 20 20 20 66 69 6c 65 20 6d  }.+..+    file m
0aa0: 6b 64 69 72 20 74 66 61 31 0a 2b 20 20 20 20 63  kdir tfa1.+    c
0ab0: 72 65 61 74 65 66 69 6c 65 20 5b 66 69 6c 65 20  reatefile [file 
0ac0: 6a 6f 69 6e 20 74 66 61 31 2f 74 66 61 32 5d 0a  join tfa1/tfa2].
0ad0: 2b 20 20 20 20 66 69 6c 65 20 6c 69 6e 6b 20 2d  +    file link -
0ae0: 73 79 6d 62 6f 6c 69 63 20 74 66 61 6c 69 6e 6b  symbolic tfalink
0af0: 20 74 66 61 31 0a 2b 20 20 20 20 63 72 65 61 74   tfa1.+    creat
0b00: 65 66 69 6c 65 20 74 66 61 33 0a 2b 20 20 20 20  efile tfa3.+    
0b10: 66 69 6c 65 20 72 65 6e 61 6d 65 20 2d 66 6f 72  file rename -for
0b20: 63 65 20 74 66 61 6c 69 6e 6b 20 74 66 61 33 0a  ce tfalink tfa3.
0b30: 2b 20 20 20 20 73 65 74 20 72 65 73 75 6c 74 20  +    set result 
0b40: 5b 65 78 70 72 20 5b 73 74 72 69 6e 67 20 63 6f  [expr [string co
0b50: 6d 70 61 72 65 20 5b 66 69 6c 65 20 74 79 70 65  mpare [file type
0b60: 20 74 66 61 33 5d 20 22 6c 69 6e 6b 22 5d 20 3d   tfa3] "link"] =
0b70: 3d 20 30 5d 0a 2b 20 20 20 20 66 69 6c 65 20 64  = 0].+    file d
0b80: 65 6c 65 74 65 20 74 66 61 31 2f 74 66 61 32 0a  elete tfa1/tfa2.
0b90: 2b 20 20 20 20 66 69 6c 65 20 64 65 6c 65 74 65  +    file delete
0ba0: 20 74 66 61 33 0a 2b 20 20 20 20 73 65 74 20 72   tfa3.+    set r
0bb0: 65 73 75 6c 74 0a 2b 7d 20 7b 31 7d 0a 2b 0a 2b  esult.+} {1}.+.+
0bc0: 23 63 61 6e 20 6e 6f 74 20 6f 76 65 72 77 72 69  #can not overwri
0bd0: 74 65 20 61 20 73 79 6d 6c 69 6e 6b 20 77 69 74  te a symlink wit
0be0: 68 20 66 69 6c 65 0a 2b 74 65 73 74 20 66 43 6d  h file.+test fCm
0bf0: 64 2d 31 38 2e 32 32 20 7b 54 63 6c 46 69 6c 65  d-18.22 {TclFile
0c00: 52 65 6e 61 6d 65 43 6d 64 3a 20 72 65 6e 61 6d  RenameCmd: renam
0c10: 65 20 73 79 6d 6c 69 6e 6b 20 77 69 74 68 20 66  e symlink with f
0c20: 69 6c 65 20 6e 6f 20 2d 66 6f 72 63 65 7d 20 7b  ile no -force} {
0c30: 75 6e 69 78 4f 6e 6c 79 20 6e 6f 74 52 6f 6f 74  unixOnly notRoot
0c40: 7d 20 7b 0a 2b 20 20 20 20 63 61 74 63 68 20 7b  } {.+    catch {
0c50: 66 69 6c 65 20 64 65 6c 65 74 65 20 2d 66 6f 72  file delete -for
0c60: 63 65 20 2d 2d 20 74 66 61 31 20 74 66 61 6c 69  ce -- tfa1 tfali
0c70: 6e 6b 20 74 66 61 33 7d 0a 2b 09 0a 2b 20 20 20  nk tfa3}.+..+   
0c80: 20 66 69 6c 65 20 6d 6b 64 69 72 20 74 66 61 31   file mkdir tfa1
0c90: 0a 2b 20 20 20 20 63 72 65 61 74 65 66 69 6c 65  .+    createfile
0ca0: 20 5b 66 69 6c 65 20 6a 6f 69 6e 20 74 66 61 31   [file join tfa1
0cb0: 2f 74 66 61 32 5d 0a 2b 20 20 20 20 66 69 6c 65  /tfa2].+    file
0cc0: 20 6c 69 6e 6b 20 2d 73 79 6d 62 6f 6c 69 63 20   link -symbolic 
0cd0: 74 66 61 6c 69 6e 6b 20 74 66 61 31 0a 2b 20 20  tfalink tfa1.+  
0ce0: 20 20 63 72 65 61 74 65 66 69 6c 65 20 74 66 61    createfile tfa
0cf0: 33 0a 2b 20 20 20 20 6c 69 73 74 20 5b 63 61 74  3.+    list [cat
0d00: 63 68 20 7b 66 69 6c 65 20 72 65 6e 61 6d 65 20  ch {file rename 
0d10: 74 66 61 6c 69 6e 6b 20 74 66 61 33 7d 20 6d 73  tfalink tfa3} ms
0d20: 67 5d 20 24 6d 73 67 0a 2b 20 20 20 20 66 69 6c  g] $msg.+    fil
0d30: 65 20 64 65 6c 65 74 65 20 74 66 61 31 2f 74 66  e delete tfa1/tf
0d40: 61 32 0a 2b 20 20 20 20 66 69 6c 65 20 64 65 6c  a2.+    file del
0d50: 65 74 65 20 74 66 61 33 0a 2b 20 20 20 20 73 65  ete tfa3.+    se
0d60: 74 20 6d 73 67 0a 2b 7d 20 7b 65 72 72 6f 72 20  t msg.+} {error 
0d70: 72 65 6e 61 6d 69 6e 67 20 22 74 66 61 6c 69 6e  renaming "tfalin
0d80: 6b 22 20 74 6f 20 22 74 66 61 33 22 3a 20 66 69  k" to "tfa3": fi
0d90: 6c 65 20 61 6c 72 65 61 64 79 20 65 78 69 73 74  le already exist
0da0: 73 7d 0a 2b 0a 2b 74 65 73 74 20 66 43 6d 64 2d  s}.+.+test fCmd-
0db0: 31 38 2e 32 33 20 7b 54 63 6c 46 69 6c 65 52 65  18.23 {TclFileRe
0dc0: 6e 61 6d 65 43 6d 64 3a 20 72 65 6e 61 6d 65 20  nameCmd: rename 
0dd0: 73 79 6d 6c 69 6e 6b 20 77 69 74 68 20 63 6f 6e  symlink with con
0de0: 74 65 6e 74 73 7d 20 7b 75 6e 69 78 4f 6e 6c 79  tents} {unixOnly
0df0: 20 6e 6f 74 52 6f 6f 74 7d 20 7b 0a 2b 20 20 20   notRoot} {.+   
0e00: 20 63 61 74 63 68 20 7b 66 69 6c 65 20 64 65 6c   catch {file del
0e10: 65 74 65 20 2d 66 6f 72 63 65 20 2d 2d 20 74 66  ete -force -- tf
0e20: 61 31 20 74 66 61 6c 69 6e 6b 7d 0a 2b 09 0a 2b  a1 tfalink}.+..+
0e30: 20 20 20 20 66 69 6c 65 20 6d 6b 64 69 72 20 74      file mkdir t
0e40: 66 61 31 0a 2b 20 20 20 20 63 72 65 61 74 65 66  fa1.+    createf
0e50: 69 6c 65 20 5b 66 69 6c 65 20 6a 6f 69 6e 20 74  ile [file join t
0e60: 66 61 31 2f 74 66 61 32 5d 0a 2b 20 20 20 20 66  fa1/tfa2].+    f
0e70: 69 6c 65 20 6c 69 6e 6b 20 2d 73 79 6d 62 6f 6c  ile link -symbol
0e80: 69 63 20 74 66 61 6c 69 6e 6b 20 74 66 61 31 0a  ic tfalink tfa1.
0e90: 2b 20 20 20 20 66 69 6c 65 20 72 65 6e 61 6d 65  +    file rename
0ea0: 20 74 66 61 6c 69 6e 6b 20 74 66 61 33 0a 2b 20   tfalink tfa3.+ 
0eb0: 20 20 20 73 65 74 20 72 65 73 75 6c 74 20 5b 65     set result [e
0ec0: 78 70 72 20 5b 73 74 72 69 6e 67 20 63 6f 6d 70  xpr [string comp
0ed0: 61 72 65 20 5b 66 69 6c 65 20 74 79 70 65 20 74  are [file type t
0ee0: 66 61 33 5d 20 22 6c 69 6e 6b 22 5d 20 3d 3d 20  fa3] "link"] == 
0ef0: 30 5d 0a 2b 20 20 20 20 66 69 6c 65 20 64 65 6c  0].+    file del
0f00: 65 74 65 20 74 66 61 31 2f 74 66 61 32 0a 2b 20  ete tfa1/tfa2.+ 
0f10: 20 20 20 66 69 6c 65 20 64 65 6c 65 74 65 20 74     file delete t
0f20: 66 61 33 0a 2b 20 20 20 20 73 65 74 20 72 65 73  fa3.+    set res
0f30: 75 6c 74 0a 2b 7d 20 7b 31 7d 0a 2b 0a 20 23 0a  ult.+} {1}.+. #.
0f40: 20 23 20 43 6f 76 65 72 61 67 65 20 74 65 73 74   # Coverage test
0f50: 73 20 66 6f 72 20 54 63 6c 55 6e 69 78 52 6d 64  s for TclUnixRmd
0f60: 69 72 0a 20 23 0a 49 6e 64 65 78 3a 20 75 6e 69  ir. #.Index: uni
0f70: 78 2f 74 63 6c 55 6e 69 78 46 43 6d 64 2e 63 0a  x/tclUnixFCmd.c.
0f80: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
0f90: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
0fa0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
0fb0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
0fc0: 3d 3d 3d 0a 52 43 53 20 66 69 6c 65 3a 20 2f 63  ===.RCS file: /c
0fd0: 76 73 72 6f 6f 74 2f 74 63 6c 2f 74 63 6c 2f 75  vsroot/tcl/tcl/u
0fe0: 6e 69 78 2f 74 63 6c 55 6e 69 78 46 43 6d 64 2e  nix/tclUnixFCmd.
0ff0: 63 2c 76 0a 72 65 74 72 69 65 76 69 6e 67 20 72  c,v.retrieving r
1000: 65 76 69 73 69 6f 6e 20 31 2e 32 38 2e 32 2e 32  evision 1.28.2.2
1010: 0a 64 69 66 66 20 2d 75 20 2d 70 20 2d 72 31 2e  .diff -u -p -r1.
1020: 32 38 2e 32 2e 32 20 74 63 6c 55 6e 69 78 46 43  28.2.2 tclUnixFC
1030: 6d 64 2e 63 0a 2d 2d 2d 20 75 6e 69 78 2f 74 63  md.c.--- unix/tc
1040: 6c 55 6e 69 78 46 43 6d 64 2e 63 09 33 20 4f 63  lUnixFCmd.c.3 Oc
1050: 74 20 32 30 30 33 20 31 37 3a 34 35 3a 33 37 20  t 2003 17:45:37 
1060: 2d 30 30 30 30 09 31 2e 32 38 2e 32 2e 32 0a 2b  -0000.1.28.2.2.+
1070: 2b 2b 20 75 6e 69 78 2f 74 63 6c 55 6e 69 78 46  ++ unix/tclUnixF
1080: 43 6d 64 2e 63 09 36 20 4d 61 79 20 32 30 30 34  Cmd.c.6 May 2004
1090: 20 31 36 3a 33 34 3a 31 30 20 2d 30 30 30 30 0a   16:34:10 -0000.
10a0: 40 40 20 2d 32 32 33 2c 37 36 20 2b 32 32 33 2c  @@ -223,76 +223,
10b0: 33 32 20 40 40 20 44 6f 52 65 6e 61 6d 65 46 69  32 @@ DoRenameFi
10c0: 6c 65 28 73 72 63 2c 20 64 73 74 29 0a 20 20 20  le(src, dst).   
10d0: 20 20 43 4f 4e 53 54 20 63 68 61 72 20 2a 64 73    CONST char *ds
10e0: 74 3b 09 09 2f 2a 20 4e 65 77 20 70 61 74 68 6e  t;../* New pathn
10f0: 61 6d 65 20 6f 66 20 66 69 6c 65 20 6f 72 20 64  ame of file or d
1100: 69 72 65 63 74 6f 72 79 0a 20 09 09 09 09 20 2a  irectory. .... *
1110: 20 28 6e 61 74 69 76 65 29 2e 20 2a 2f 0a 20 7b   (native). */. {
1120: 0a 2d 20 20 20 20 69 66 20 28 72 65 6e 61 6d 65  .-    if (rename
1130: 28 73 72 63 2c 20 64 73 74 29 20 3d 3d 20 30 29  (src, dst) == 0)
1140: 20 7b 09 09 09 2f 2a 20 49 4e 54 4c 3a 20 4e 61   {.../* INTL: Na
1150: 74 69 76 65 2e 20 2a 2f 0a 2d 09 72 65 74 75 72  tive. */.-.retur
1160: 6e 20 54 43 4c 5f 4f 4b 3b 0a 2d 20 20 20 20 7d  n TCL_OK;.-    }
1170: 0a 2d 20 20 20 20 69 66 20 28 65 72 72 6e 6f 20  .-    if (errno 
1180: 3d 3d 20 45 4e 4f 54 45 4d 50 54 59 29 20 7b 0a  == ENOTEMPTY) {.
1190: 2d 09 65 72 72 6e 6f 20 3d 20 45 45 58 49 53 54  -.errno = EEXIST
11a0: 3b 0a 2d 20 20 20 20 7d 0a 2d 0a 2d 20 20 20 20  ;.-    }.-.-    
11b0: 2f 2a 0a 2d 20 20 20 20 20 2a 20 49 52 49 58 20  /*.-     * IRIX 
11c0: 72 65 74 75 72 6e 73 20 45 49 4f 20 77 68 65 6e  returns EIO when
11d0: 20 79 6f 75 20 61 74 74 65 70 74 20 74 6f 20 6d   you attept to m
11e0: 6f 76 65 20 61 20 64 69 72 65 63 74 6f 72 79 20  ove a directory 
11f0: 69 6e 74 6f 0a 2d 20 20 20 20 20 2a 20 69 74 73  into.-     * its
1200: 65 6c 66 2e 20 20 57 65 20 6a 75 73 74 20 6d 61  elf.  We just ma
1210: 70 20 45 49 4f 20 74 6f 20 45 49 4e 56 41 4c 20  p EIO to EINVAL 
1220: 67 65 74 20 74 68 65 20 72 69 67 68 74 20 6d 65  get the right me
1230: 73 73 61 67 65 20 6f 6e 20 53 47 49 2e 0a 2d 20  ssage on SGI..- 
1240: 20 20 20 20 2a 20 4d 6f 73 74 20 70 6c 61 74 66      * Most platf
1250: 6f 72 6d 73 20 64 6f 6e 27 74 20 72 65 74 75 72  orms don't retur
1260: 6e 20 45 49 4f 20 65 78 63 65 70 74 20 69 6e 20  n EIO except in 
1270: 72 65 61 6c 6c 79 20 73 74 72 61 6e 67 65 20 63  really strange c
1280: 61 73 65 73 2e 0a 2d 20 20 20 20 20 2a 2f 0a 2d  ases..-     */.-
1290: 20 20 20 20 0a 2d 20 20 20 20 69 66 20 28 65 72      .-    if (er
12a0: 72 6e 6f 20 3d 3d 20 45 49 4f 29 20 7b 0a 2d 09  rno == EIO) {.-.
12b0: 65 72 72 6e 6f 20 3d 20 45 49 4e 56 41 4c 3b 0a  errno = EINVAL;.
12c0: 2d 20 20 20 20 7d 0a 2b 20 20 20 20 69 6e 74 20  -    }.+    int 
12d0: 65 78 69 73 74 73 3b 0a 2b 20 20 20 20 73 74 72  exists;.+    str
12e0: 75 63 74 20 73 74 61 74 20 64 73 74 53 42 3b 0a  uct stat dstSB;.
12f0: 20 20 20 20 20 0a 2d 23 69 66 6e 64 65 66 20 4e       .-#ifndef N
1300: 4f 5f 52 45 41 4c 50 41 54 48 0a 2d 20 20 20 20  O_REALPATH.-    
1310: 2f 2a 0a 2d 20 20 20 20 20 2a 20 53 75 6e 4f 53  /*.-     * SunOS
1320: 20 34 2e 31 2e 34 20 72 65 70 6f 72 74 73 20 6f   4.1.4 reports o
1330: 76 65 72 77 72 69 74 69 6e 67 20 61 20 6e 6f 6e  verwriting a non
1340: 2d 65 6d 70 74 79 20 64 69 72 65 63 74 6f 72 79  -empty directory
1350: 20 77 69 74 68 20 61 0a 2d 20 20 20 20 20 2a 20   with a.-     * 
1360: 64 69 72 65 63 74 6f 72 79 20 61 73 20 45 49 4e  directory as EIN
1370: 56 41 4c 20 69 6e 73 74 65 61 64 20 6f 66 20 45  VAL instead of E
1380: 45 58 49 53 54 20 28 66 69 72 73 74 20 72 75 6c  EXIST (first rul
1390: 65 20 6f 75 74 20 74 68 65 20 63 6f 72 72 65 63  e out the correc
13a0: 74 0a 2d 20 20 20 20 20 2a 20 45 49 4e 56 41 4c  t.-     * EINVAL
13b0: 20 72 65 73 75 6c 74 20 63 6f 64 65 20 66 6f 72   result code for
13c0: 20 6d 6f 76 69 6e 67 20 61 20 64 69 72 65 63 74   moving a direct
13d0: 6f 72 79 20 69 6e 74 6f 20 69 74 73 65 6c 66 29  ory into itself)
13e0: 2e 20 20 4d 75 73 74 20 62 65 0a 2d 20 20 20 20  .  Must be.-    
13f0: 20 2a 20 63 6f 6e 64 69 74 69 6f 6e 61 6c 6c 79   * conditionally
1400: 20 63 6f 6d 70 69 6c 65 64 20 62 65 63 61 75 73   compiled becaus
1410: 65 20 72 65 61 6c 70 61 74 68 28 29 20 6e 6f 74  e realpath() not
1420: 20 64 65 66 69 6e 65 64 20 6f 6e 20 61 6c 6c 20   defined on all 
1430: 73 79 73 74 65 6d 73 2e 0a 2d 20 20 20 20 20 2a  systems..-     *
1440: 2f 0a 2d 0a 2d 20 20 20 20 69 66 20 28 65 72 72  /.-.-    if (err
1450: 6e 6f 20 3d 3d 20 45 49 4e 56 41 4c 29 20 7b 0a  no == EINVAL) {.
1460: 2d 09 63 68 61 72 20 73 72 63 50 61 74 68 5b 4d  -.char srcPath[M
1470: 41 58 50 41 54 48 4c 45 4e 5d 2c 20 64 73 74 50  AXPATHLEN], dstP
1480: 61 74 68 5b 4d 41 58 50 41 54 48 4c 45 4e 5d 3b  ath[MAXPATHLEN];
1490: 0a 2d 09 44 49 52 20 2a 64 69 72 50 74 72 3b 0a  .-.DIR *dirPtr;.
14a0: 2d 09 54 63 6c 5f 44 69 72 45 6e 74 72 79 20 2a  -.Tcl_DirEntry *
14b0: 64 69 72 45 6e 74 50 74 72 3b 0a 2d 0a 2d 09 69  dirEntPtr;.-.-.i
14c0: 66 20 28 28 52 65 61 6c 70 61 74 68 28 28 63 68  f ((Realpath((ch
14d0: 61 72 20 2a 29 20 73 72 63 2c 20 73 72 63 50 61  ar *) src, srcPa
14e0: 74 68 29 20 21 3d 20 4e 55 4c 4c 29 09 2f 2a 20  th) != NULL)./* 
14f0: 49 4e 54 4c 3a 20 4e 61 74 69 76 65 2e 20 2a 2f  INTL: Native. */
1500: 0a 2d 09 09 26 26 20 28 52 65 61 6c 70 61 74 68  .-..&& (Realpath
1510: 28 28 63 68 61 72 20 2a 29 20 64 73 74 2c 20 64  ((char *) dst, d
1520: 73 74 50 61 74 68 29 20 21 3d 20 4e 55 4c 4c 29  stPath) != NULL)
1530: 20 2f 2a 20 49 4e 54 4c 3a 20 4e 61 74 69 76 65   /* INTL: Native
1540: 2e 20 2a 2f 0a 2d 09 09 26 26 20 28 73 74 72 6e  . */.-..&& (strn
1550: 63 6d 70 28 73 72 63 50 61 74 68 2c 20 64 73 74  cmp(srcPath, dst
1560: 50 61 74 68 2c 20 73 74 72 6c 65 6e 28 73 72 63  Path, strlen(src
1570: 50 61 74 68 29 29 20 21 3d 20 30 29 29 20 7b 0a  Path)) != 0)) {.
1580: 2d 09 20 20 20 20 64 69 72 50 74 72 20 3d 20 6f  -.    dirPtr = o
1590: 70 65 6e 64 69 72 28 64 73 74 29 3b 09 09 09 2f  pendir(dst);.../
15a0: 2a 20 49 4e 54 4c 3a 20 4e 61 74 69 76 65 2e 20  * INTL: Native. 
15b0: 2a 2f 0a 2d 09 20 20 20 20 69 66 20 28 64 69 72  */.-.    if (dir
15c0: 50 74 72 20 21 3d 20 4e 55 4c 4c 29 20 7b 0a 2d  Ptr != NULL) {.-
15d0: 09 09 77 68 69 6c 65 20 28 31 29 20 7b 0a 2d 09  ..while (1) {.-.
15e0: 09 20 20 20 20 64 69 72 45 6e 74 50 74 72 20 3d  .    dirEntPtr =
15f0: 20 54 63 6c 4f 53 72 65 61 64 64 69 72 28 64 69   TclOSreaddir(di
1600: 72 50 74 72 29 3b 20 2f 2a 20 49 4e 54 4c 3a 20  rPtr); /* INTL: 
1610: 4e 61 74 69 76 65 2e 20 2a 2f 0a 2d 09 09 20 20  Native. */.-..  
1620: 20 20 69 66 20 28 64 69 72 45 6e 74 50 74 72 20    if (dirEntPtr 
1630: 3d 3d 20 4e 55 4c 4c 29 20 7b 0a 2d 09 09 09 62  == NULL) {.-...b
1640: 72 65 61 6b 3b 0a 2d 09 09 20 20 20 20 7d 0a 2d  reak;.-..    }.-
1650: 09 09 20 20 20 20 69 66 20 28 28 73 74 72 63 6d  ..    if ((strcm
1660: 70 28 64 69 72 45 6e 74 50 74 72 2d 3e 64 5f 6e  p(dirEntPtr->d_n
1670: 61 6d 65 2c 20 22 2e 22 29 20 21 3d 20 30 29 20  ame, ".") != 0) 
1680: 26 26 0a 2d 09 09 09 20 20 20 20 28 73 74 72 63  &&.-...    (strc
1690: 6d 70 28 64 69 72 45 6e 74 50 74 72 2d 3e 64 5f  mp(dirEntPtr->d_
16a0: 6e 61 6d 65 2c 20 22 2e 2e 22 29 20 21 3d 20 30  name, "..") != 0
16b0: 29 29 20 7b 0a 2d 09 09 09 65 72 72 6e 6f 20 3d  )) {.-...errno =
16c0: 20 45 45 58 49 53 54 3b 0a 2d 09 09 09 63 6c 6f   EEXIST;.-...clo
16d0: 73 65 64 69 72 28 64 69 72 50 74 72 29 3b 0a 2d  sedir(dirPtr);.-
16e0: 09 09 09 72 65 74 75 72 6e 20 54 43 4c 5f 45 52  ...return TCL_ER
16f0: 52 4f 52 3b 0a 2d 09 09 20 20 20 20 7d 0a 2d 09  ROR;.-..    }.-.
1700: 09 7d 0a 2d 09 09 63 6c 6f 73 65 64 69 72 28 64  .}.-..closedir(d
1710: 69 72 50 74 72 29 3b 0a 2d 09 20 20 20 20 7d 0a  irPtr);.-.    }.
1720: 2d 09 7d 0a 2d 09 65 72 72 6e 6f 20 3d 20 45 49  -.}.-.errno = EI
1730: 4e 56 41 4c 3b 0a 2d 20 20 20 20 7d 0a 2d 23 65  NVAL;.-    }.-#e
1740: 6e 64 69 66 09 2f 2a 20 21 4e 4f 5f 52 45 41 4c  ndif./* !NO_REAL
1750: 50 41 54 48 20 2a 2f 0a 2d 0a 20 20 20 20 20 69  PATH */.-.     i
1760: 66 20 28 73 74 72 63 6d 70 28 73 72 63 2c 20 22  f (strcmp(src, "
1770: 2f 22 29 20 3d 3d 20 30 29 20 7b 0a 2d 09 2f 2a  /") == 0) {.-./*
1780: 0a 2d 09 20 2a 20 41 6c 70 68 61 20 72 65 70 6f  .-. * Alpha repo
1790: 72 74 73 20 72 65 6e 61 6d 69 6e 67 20 2f 20 61  rts renaming / a
17a0: 73 20 45 42 55 53 59 20 61 6e 64 20 4c 69 6e 75  s EBUSY and Linu
17b0: 78 20 72 65 70 6f 72 74 73 20 69 74 20 61 73 20  x reports it as 
17c0: 45 41 43 43 45 53 2c 0a 2d 09 20 2a 20 69 6e 73  EACCES,.-. * ins
17d0: 74 65 61 64 20 6f 66 20 45 49 4e 56 41 4c 2e 0a  tead of EINVAL..
17e0: 2d 09 20 2a 2f 0a 2d 09 20 0a 2d 09 65 72 72 6e  -. */.-. .-.errn
17f0: 6f 20 3d 20 45 49 4e 56 41 4c 3b 0a 2b 20 20 20  o = EINVAL;.+   
1800: 20 20 20 20 20 2f 2a 20 41 6c 70 68 61 20 72 65       /* Alpha re
1810: 70 6f 72 74 73 20 72 65 6e 61 6d 69 6e 67 20 2f  ports renaming /
1820: 20 61 73 20 45 42 55 53 59 2c 20 4c 69 6e 75 78   as EBUSY, Linux
1830: 20 72 65 70 6f 72 74 73 20 69 74 20 61 73 20 45   reports it as E
1840: 41 43 43 45 53 2c 0a 2b 20 20 20 20 20 20 20 20  ACCES,.+        
1850: 20 2a 20 61 6e 64 20 4f 53 58 20 72 65 70 6f 72   * and OSX repor
1860: 74 73 20 69 74 20 61 73 20 45 49 53 44 49 52 20  ts it as EISDIR 
1870: 69 6e 73 74 65 61 64 20 6f 66 20 45 49 4e 56 41  instead of EINVA
1880: 4c 2e 20 2a 2f 0a 2b 20 20 20 20 20 20 20 20 65  L. */.+        e
1890: 72 72 6e 6f 20 3d 20 45 49 4e 56 41 4c 3b 0a 2b  rrno = EINVAL;.+
18a0: 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 54          return T
18b0: 43 4c 5f 45 52 52 4f 52 3b 0a 2b 20 20 20 20 7d  CL_ERROR;.+    }
18c0: 0a 2b 20 20 20 20 65 78 69 73 74 73 20 3d 20 28  .+    exists = (
18d0: 6c 73 74 61 74 28 64 73 74 2c 20 26 64 73 74 53  lstat(dst, &dstS
18e0: 42 29 20 3d 3d 20 30 29 3b 0a 2b 20 20 20 20 2f  B) == 0);.+    /
18f0: 2a 20 64 73 74 20 6e 6f 6e 2d 65 78 73 69 73 74  * dst non-exsist
1900: 61 6e 74 20 6f 72 20 61 20 6e 6f 72 6d 61 6c 20  ant or a normal 
1910: 66 69 6c 65 20 2a 2f 0a 2b 20 20 20 20 69 66 20  file */.+    if 
1920: 28 21 65 78 69 73 74 73 20 7c 7c 20 28 21 53 5f  (!exists || (!S_
1930: 49 53 4c 4e 4b 28 64 73 74 53 42 2e 73 74 5f 6d  ISLNK(dstSB.st_m
1940: 6f 64 65 29 20 26 26 20 64 73 74 53 42 2e 73 74  ode) && dstSB.st
1950: 5f 6e 6c 69 6e 6b 20 3d 3d 20 31 29 29 20 7b 0a  _nlink == 1)) {.
1960: 2b 20 20 20 20 20 20 20 20 69 66 20 28 72 65 6e  +        if (ren
1970: 61 6d 65 28 73 72 63 2c 20 64 73 74 29 20 3d 3d  ame(src, dst) ==
1980: 20 30 29 20 7b 0a 2b 20 20 20 20 20 20 20 20 20   0) {.+         
1990: 20 20 20 72 65 74 75 72 6e 20 54 43 4c 5f 4f 4b     return TCL_OK
19a0: 3b 0a 2b 20 20 20 20 20 20 20 20 20 7d 0a 2b 20  ;.+         }.+ 
19b0: 20 20 20 7d 20 65 6c 73 65 20 7b 0a 2b 20 20 20     } else {.+   
19c0: 20 20 20 20 20 2f 2a 20 63 6f 70 79 0a 2b 20 20       /* copy.+  
19d0: 20 20 20 20 20 20 20 2a 20 6f 76 65 72 77 72 69         * overwri
19e0: 74 69 6e 67 20 61 20 6e 6f 6e 2d 65 6d 70 74 79  ting a non-empty
19f0: 20 64 69 72 65 63 74 6f 72 79 20 63 68 65 63 6b   directory check
1a00: 65 64 20 77 69 74 68 20 72 6d 64 69 72 28 29 20  ed with rmdir() 
1a10: 2a 2f 0a 2b 20 20 20 20 20 20 20 20 69 66 20 28  */.+        if (
1a20: 72 6d 64 69 72 28 64 73 74 29 20 3d 3d 20 30 29  rmdir(dst) == 0)
1a30: 20 7b 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20   {.+            
1a40: 72 65 6e 61 6d 65 28 73 72 63 2c 20 64 73 74 29  rename(src, dst)
1a50: 3b 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 72  ;.+            r
1a60: 65 74 75 72 6e 20 54 43 4c 5f 4f 4b 3b 0a 2b 20  eturn TCL_OK;.+ 
1a70: 20 20 20 20 20 20 20 7d 0a 2b 20 20 20 20 20 20         }.+      
1a80: 20 20 69 66 20 28 65 72 72 6e 6f 20 3d 3d 20 45    if (errno == E
1a90: 4e 4f 54 45 4d 50 54 59 29 20 7b 0a 2b 20 20 20  NOTEMPTY) {.+   
1aa0: 20 20 20 20 20 20 20 20 20 65 72 72 6e 6f 20 3d           errno =
1ab0: 20 45 45 58 49 53 54 3b 0a 2b 20 20 20 20 20 20   EEXIST;.+      
1ac0: 20 20 7d 0a 20 20 20 20 20 7d 0a 2d 0a 2d 20 20    }.     }.-.-  
1ad0: 20 20 2f 2a 0a 2d 20 20 20 20 20 2a 20 44 45 43    /*.-     * DEC
1ae0: 20 41 6c 70 68 61 20 4f 53 46 31 20 56 33 2e 30   Alpha OSF1 V3.0
1af0: 20 72 65 74 75 72 6e 73 20 45 41 43 43 45 53 20   returns EACCES 
1b00: 77 68 65 6e 20 61 74 74 65 6d 70 74 69 6e 67 20  when attempting 
1b10: 74 6f 20 6d 6f 76 65 20 61 0a 2d 20 20 20 20 20  to move a.-     
1b20: 2a 20 66 69 6c 65 20 61 63 72 6f 73 73 20 66 69  * file across fi
1b30: 6c 65 73 79 73 74 65 6d 73 20 61 6e 64 20 74 68  lesystems and th
1b40: 65 20 70 61 72 65 6e 74 20 64 69 72 65 63 74 6f  e parent directo
1b50: 72 79 20 6f 66 20 74 68 61 74 20 66 69 6c 65 20  ry of that file 
1b60: 69 73 0a 2d 20 20 20 20 20 2a 20 6e 6f 74 20 77  is.-     * not w
1b70: 72 69 74 61 62 6c 65 2e 20 20 4d 6f 73 74 20 6f  ritable.  Most o
1b80: 74 68 65 72 20 73 79 73 74 65 6d 73 20 72 65 74  ther systems ret
1b90: 75 72 6e 20 45 58 44 45 56 2e 20 20 44 6f 65 73  urn EXDEV.  Does
1ba0: 20 6e 6f 74 68 69 6e 67 20 74 6f 0a 2d 20 20 20   nothing to.-   
1bb0: 20 20 2a 20 63 6f 72 72 65 63 74 20 74 68 69 73    * correct this
1bc0: 20 62 65 68 61 76 69 6f 72 2e 0a 2d 20 20 20 20   behavior..-    
1bd0: 20 2a 2f 0a 2d 0a 20 20 20 20 20 72 65 74 75 72   */.-.     retur
1be0: 6e 20 54 43 4c 5f 45 52 52 4f 52 3b 0a 20 7d 0a  n TCL_ERROR;. }.
1bf0: 20 0c 0a 00 00 00 00 00 00 00 00 00 00 00 00 00   ...............
1c00: 00 00 00 00 00 00 00 00 00 00 00                 ...........