Tcl Source Code

Hex Artifact Content
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Artifact ee3766c8dd7733163cd323e159552f59138990ef7690e553aeb8f28ffdb4740b:


0000: 2f 2a 0a 20 2a 20 74 63 6c 46 43 6d 64 2e 63 0a  /*. * tclFCmd.c.
0010: 20 2a 0a 20 2a 09 54 68 69 73 20 66 69 6c 65 20   *. *.This file 
0020: 69 6d 70 6c 65 6d 65 6e 74 73 20 74 68 65 20 67  implements the g
0030: 65 6e 65 72 69 63 20 70 6f 72 74 69 6f 6e 20 6f  eneric portion o
0040: 66 20 66 69 6c 65 20 6d 61 6e 69 70 75 6c 61 74  f file manipulat
0050: 69 6f 6e 0a 20 2a 09 73 75 62 63 6f 6d 6d 61 6e  ion. *.subcomman
0060: 64 73 20 6f 66 20 74 68 65 20 22 66 69 6c 65 22  ds of the "file"
0070: 20 63 6f 6d 6d 61 6e 64 2e 0a 20 2a 0a 20 2a 20   command.. *. * 
0080: 43 6f 70 79 72 69 67 68 74 20 28 63 29 20 31 39  Copyright (c) 19
0090: 39 36 2d 31 39 39 38 20 53 75 6e 20 4d 69 63 72  96-1998 Sun Micr
00a0: 6f 73 79 73 74 65 6d 73 2c 20 49 6e 63 2e 0a 20  osystems, Inc.. 
00b0: 2a 0a 20 2a 20 53 65 65 20 74 68 65 20 66 69 6c  *. * See the fil
00c0: 65 20 22 6c 69 63 65 6e 73 65 2e 74 65 72 6d 73  e "license.terms
00d0: 22 20 66 6f 72 20 69 6e 66 6f 72 6d 61 74 69 6f  " for informatio
00e0: 6e 20 6f 6e 20 75 73 61 67 65 20 61 6e 64 20 72  n on usage and r
00f0: 65 64 69 73 74 72 69 62 75 74 69 6f 6e 20 6f 66  edistribution of
0100: 0a 20 2a 20 74 68 69 73 20 66 69 6c 65 2c 20 61  . * this file, a
0110: 6e 64 20 66 6f 72 20 61 20 44 49 53 43 4c 41 49  nd for a DISCLAI
0120: 4d 45 52 20 4f 46 20 41 4c 4c 20 57 41 52 52 41  MER OF ALL WARRA
0130: 4e 54 49 45 53 2e 0a 20 2a 2f 0a 0a 23 69 6e 63  NTIES.. */..#inc
0140: 6c 75 64 65 20 22 74 63 6c 49 6e 74 2e 68 22 0a  lude "tclInt.h".
0150: 0a 2f 2a 0a 20 2a 20 44 65 63 6c 61 72 61 74 69  ./*. * Declarati
0160: 6f 6e 73 20 66 6f 72 20 6c 6f 63 61 6c 20 66 75  ons for local fu
0170: 6e 63 74 69 6f 6e 73 20 64 65 66 69 6e 65 64 20  nctions defined 
0180: 69 6e 20 74 68 69 73 20 66 69 6c 65 3a 0a 20 2a  in this file:. *
0190: 2f 0a 0a 73 74 61 74 69 63 20 69 6e 74 09 09 43  /..static int..C
01a0: 6f 70 79 52 65 6e 61 6d 65 4f 6e 65 46 69 6c 65  opyRenameOneFile
01b0: 28 54 63 6c 5f 49 6e 74 65 72 70 20 2a 69 6e 74  (Tcl_Interp *int
01c0: 65 72 70 2c 0a 09 09 09 20 20 20 20 54 63 6c 5f  erp,....    Tcl_
01d0: 4f 62 6a 20 2a 73 72 63 50 61 74 68 50 74 72 2c  Obj *srcPathPtr,
01e0: 20 54 63 6c 5f 4f 62 6a 20 2a 64 65 73 74 50 61   Tcl_Obj *destPa
01f0: 74 68 50 74 72 2c 0a 09 09 09 20 20 20 20 69 6e  thPtr,....    in
0200: 74 20 63 6f 70 79 46 6c 61 67 2c 20 69 6e 74 20  t copyFlag, int 
0210: 66 6f 72 63 65 29 3b 0a 73 74 61 74 69 63 20 54  force);.static T
0220: 63 6c 5f 4f 62 6a 20 2a 09 46 69 6c 65 42 61 73  cl_Obj *.FileBas
0230: 65 6e 61 6d 65 28 54 63 6c 5f 49 6e 74 65 72 70  ename(Tcl_Interp
0240: 20 2a 69 6e 74 65 72 70 2c 20 54 63 6c 5f 4f 62   *interp, Tcl_Ob
0250: 6a 20 2a 70 61 74 68 50 74 72 29 3b 0a 73 74 61  j *pathPtr);.sta
0260: 74 69 63 20 69 6e 74 09 09 46 69 6c 65 43 6f 70  tic int..FileCop
0270: 79 52 65 6e 61 6d 65 28 54 63 6c 5f 49 6e 74 65  yRename(Tcl_Inte
0280: 72 70 20 2a 69 6e 74 65 72 70 2c 0a 09 09 09 20  rp *interp,.... 
0290: 20 20 20 69 6e 74 20 6f 62 6a 63 2c 20 54 63 6c     int objc, Tcl
02a0: 5f 4f 62 6a 20 2a 43 4f 4e 53 54 20 6f 62 6a 76  _Obj *CONST objv
02b0: 5b 5d 2c 20 69 6e 74 20 63 6f 70 79 46 6c 61 67  [], int copyFlag
02c0: 29 3b 0a 73 74 61 74 69 63 20 69 6e 74 09 09 46  );.static int..F
02d0: 69 6c 65 46 6f 72 63 65 4f 70 74 69 6f 6e 28 54  ileForceOption(T
02e0: 63 6c 5f 49 6e 74 65 72 70 20 2a 69 6e 74 65 72  cl_Interp *inter
02f0: 70 2c 0a 09 09 09 20 20 20 20 69 6e 74 20 6f 62  p,....    int ob
0300: 6a 63 2c 20 54 63 6c 5f 4f 62 6a 20 2a 43 4f 4e  jc, Tcl_Obj *CON
0310: 53 54 20 6f 62 6a 76 5b 5d 2c 20 69 6e 74 20 2a  ST objv[], int *
0320: 66 6f 72 63 65 50 74 72 29 3b 0a 0c 0a 2f 2a 0a  forcePtr);.../*.
0330: 20 2a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d   *--------------
0340: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0350: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0360: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0370: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 20 2a  -------------. *
0380: 0a 20 2a 20 54 63 6c 46 69 6c 65 52 65 6e 61 6d  . * TclFileRenam
0390: 65 43 6d 64 0a 20 2a 0a 20 2a 09 54 68 69 73 20  eCmd. *. *.This 
03a0: 66 75 6e 63 74 69 6f 6e 20 69 6d 70 6c 65 6d 65  function impleme
03b0: 6e 74 73 20 74 68 65 20 22 72 65 6e 61 6d 65 22  nts the "rename"
03c0: 20 73 75 62 63 6f 6d 6d 61 6e 64 20 6f 66 20 74   subcommand of t
03d0: 68 65 20 22 66 69 6c 65 22 0a 20 2a 09 63 6f 6d  he "file". *.com
03e0: 6d 61 6e 64 2e 20 46 69 6c 65 6e 61 6d 65 20 61  mand. Filename a
03f0: 72 67 75 6d 65 6e 74 73 20 6e 65 65 64 20 74 6f  rguments need to
0400: 20 62 65 20 74 72 61 6e 73 6c 61 74 65 64 20 74   be translated t
0410: 6f 20 6e 61 74 69 76 65 20 66 6f 72 6d 61 74 0a  o native format.
0420: 20 2a 09 62 65 66 6f 72 65 20 62 65 69 6e 67 20   *.before being 
0430: 70 61 73 73 65 64 20 74 6f 20 70 6c 61 74 66 6f  passed to platfo
0440: 72 6d 2d 73 70 65 63 69 66 69 63 20 63 6f 64 65  rm-specific code
0450: 20 74 68 61 74 20 69 6d 70 6c 65 6d 65 6e 74 73   that implements
0460: 20 72 65 6e 61 6d 65 0a 20 2a 09 66 75 6e 63 74   rename. *.funct
0470: 69 6f 6e 61 6c 69 74 79 2e 0a 20 2a 0a 20 2a 20  ionality.. *. * 
0480: 52 65 73 75 6c 74 73 3a 0a 20 2a 09 41 20 73 74  Results:. *.A st
0490: 61 6e 64 61 72 64 20 54 63 6c 20 72 65 73 75 6c  andard Tcl resul
04a0: 74 2e 0a 20 2a 0a 20 2a 20 53 69 64 65 20 65 66  t.. *. * Side ef
04b0: 66 65 63 74 73 3a 0a 20 2a 09 53 65 65 20 74 68  fects:. *.See th
04c0: 65 20 75 73 65 72 20 64 6f 63 75 6d 65 6e 74 61  e user documenta
04d0: 74 69 6f 6e 2e 0a 20 2a 0a 20 2a 2d 2d 2d 2d 2d  tion.. *. *-----
04e0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
04f0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0500: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0510: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0520: 2d 2d 2d 2d 2d 2d 0a 20 2a 2f 0a 0a 69 6e 74 0a  ------. */..int.
0530: 54 63 6c 46 69 6c 65 52 65 6e 61 6d 65 43 6d 64  TclFileRenameCmd
0540: 28 0a 20 20 20 20 54 63 6c 5f 49 6e 74 65 72 70  (.    Tcl_Interp
0550: 20 2a 69 6e 74 65 72 70 2c 09 09 2f 2a 20 49 6e   *interp,../* In
0560: 74 65 72 70 20 66 6f 72 20 65 72 72 6f 72 20 72  terp for error r
0570: 65 70 6f 72 74 69 6e 67 20 6f 72 20 72 65 63 75  eporting or recu
0580: 72 73 69 76 65 0a 09 09 09 09 20 2a 20 63 61 6c  rsive..... * cal
0590: 6c 73 20 69 6e 20 74 68 65 20 63 61 73 65 20 6f  ls in the case o
05a0: 66 20 61 20 74 72 69 63 6b 79 20 72 65 6e 61 6d  f a tricky renam
05b0: 65 2e 20 2a 2f 0a 20 20 20 20 69 6e 74 20 6f 62  e. */.    int ob
05c0: 6a 63 2c 09 09 09 2f 2a 20 4e 75 6d 62 65 72 20  jc,.../* Number 
05d0: 6f 66 20 61 72 67 75 6d 65 6e 74 73 2e 20 2a 2f  of arguments. */
05e0: 0a 20 20 20 20 54 63 6c 5f 4f 62 6a 20 2a 43 4f  .    Tcl_Obj *CO
05f0: 4e 53 54 20 6f 62 6a 76 5b 5d 29 09 2f 2a 20 41  NST objv[])./* A
0600: 72 67 75 6d 65 6e 74 20 73 74 72 69 6e 67 73 20  rgument strings 
0610: 70 61 73 73 65 64 20 74 6f 20 54 63 6c 5f 46 69  passed to Tcl_Fi
0620: 6c 65 43 6d 64 2e 20 2a 2f 0a 7b 0a 20 20 20 20  leCmd. */.{.    
0630: 72 65 74 75 72 6e 20 46 69 6c 65 43 6f 70 79 52  return FileCopyR
0640: 65 6e 61 6d 65 28 69 6e 74 65 72 70 2c 20 6f 62  ename(interp, ob
0650: 6a 63 2c 20 6f 62 6a 76 2c 20 30 29 3b 0a 7d 0a  jc, objv, 0);.}.
0660: 0c 0a 2f 2a 0a 20 2a 2d 2d 2d 2d 2d 2d 2d 2d 2d  ../*. *---------
0670: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0680: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0690: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
06a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
06b0: 2d 2d 0a 20 2a 0a 20 2a 20 54 63 6c 46 69 6c 65  --. *. * TclFile
06c0: 43 6f 70 79 43 6d 64 0a 20 2a 0a 20 2a 09 54 68  CopyCmd. *. *.Th
06d0: 69 73 20 66 75 6e 63 74 69 6f 6e 20 69 6d 70 6c  is function impl
06e0: 65 6d 65 6e 74 73 20 74 68 65 20 22 63 6f 70 79  ements the "copy
06f0: 22 20 73 75 62 63 6f 6d 6d 61 6e 64 20 6f 66 20  " subcommand of 
0700: 74 68 65 20 22 66 69 6c 65 22 20 63 6f 6d 6d 61  the "file" comma
0710: 6e 64 2e 0a 20 2a 09 46 69 6c 65 6e 61 6d 65 20  nd.. *.Filename 
0720: 61 72 67 75 6d 65 6e 74 73 20 6e 65 65 64 20 74  arguments need t
0730: 6f 20 62 65 20 74 72 61 6e 73 6c 61 74 65 64 20  o be translated 
0740: 74 6f 20 6e 61 74 69 76 65 20 66 6f 72 6d 61 74  to native format
0750: 20 62 65 66 6f 72 65 20 62 65 69 6e 67 0a 20 2a   before being. *
0760: 09 70 61 73 73 65 64 20 74 6f 20 70 6c 61 74 66  .passed to platf
0770: 6f 72 6d 2d 73 70 65 63 69 66 69 63 20 63 6f 64  orm-specific cod
0780: 65 20 74 68 61 74 20 69 6d 70 6c 65 6d 65 6e 74  e that implement
0790: 73 20 63 6f 70 79 20 66 75 6e 63 74 69 6f 6e 61  s copy functiona
07a0: 6c 69 74 79 2e 0a 20 2a 0a 20 2a 20 52 65 73 75  lity.. *. * Resu
07b0: 6c 74 73 3a 0a 20 2a 09 41 20 73 74 61 6e 64 61  lts:. *.A standa
07c0: 72 64 20 54 63 6c 20 72 65 73 75 6c 74 2e 0a 20  rd Tcl result.. 
07d0: 2a 0a 20 2a 20 53 69 64 65 20 65 66 66 65 63 74  *. * Side effect
07e0: 73 3a 0a 20 2a 09 53 65 65 20 74 68 65 20 75 73  s:. *.See the us
07f0: 65 72 20 64 6f 63 75 6d 65 6e 74 61 74 69 6f 6e  er documentation
0800: 2e 0a 20 2a 0a 20 2a 2d 2d 2d 2d 2d 2d 2d 2d 2d  .. *. *---------
0810: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0820: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0830: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0840: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0850: 2d 2d 0a 20 2a 2f 0a 0a 69 6e 74 0a 54 63 6c 46  --. */..int.TclF
0860: 69 6c 65 43 6f 70 79 43 6d 64 28 0a 20 20 20 20  ileCopyCmd(.    
0870: 54 63 6c 5f 49 6e 74 65 72 70 20 2a 69 6e 74 65  Tcl_Interp *inte
0880: 72 70 2c 09 09 2f 2a 20 55 73 65 64 20 66 6f 72  rp,../* Used for
0890: 20 65 72 72 6f 72 20 72 65 70 6f 72 74 69 6e 67   error reporting
08a0: 20 6f 72 20 72 65 63 75 72 73 69 76 65 20 63 61   or recursive ca
08b0: 6c 6c 73 0a 09 09 09 09 20 2a 20 69 6e 20 74 68  lls..... * in th
08c0: 65 20 63 61 73 65 20 6f 66 20 61 20 74 72 69 63  e case of a tric
08d0: 6b 79 20 63 6f 70 79 2e 20 2a 2f 0a 20 20 20 20  ky copy. */.    
08e0: 69 6e 74 20 6f 62 6a 63 2c 09 09 09 2f 2a 20 4e  int objc,.../* N
08f0: 75 6d 62 65 72 20 6f 66 20 61 72 67 75 6d 65 6e  umber of argumen
0900: 74 73 2e 20 2a 2f 0a 20 20 20 20 54 63 6c 5f 4f  ts. */.    Tcl_O
0910: 62 6a 20 2a 43 4f 4e 53 54 20 6f 62 6a 76 5b 5d  bj *CONST objv[]
0920: 29 09 2f 2a 20 41 72 67 75 6d 65 6e 74 20 73 74  )./* Argument st
0930: 72 69 6e 67 73 20 70 61 73 73 65 64 20 74 6f 20  rings passed to 
0940: 54 63 6c 5f 46 69 6c 65 43 6d 64 2e 20 2a 2f 0a  Tcl_FileCmd. */.
0950: 7b 0a 20 20 20 20 72 65 74 75 72 6e 20 46 69 6c  {.    return Fil
0960: 65 43 6f 70 79 52 65 6e 61 6d 65 28 69 6e 74 65  eCopyRename(inte
0970: 72 70 2c 20 6f 62 6a 63 2c 20 6f 62 6a 76 2c 20  rp, objc, objv, 
0980: 31 29 3b 0a 7d 0a 0c 0a 2f 2a 0a 20 2a 2d 2d 2d  1);.}.../*. *---
0990: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
09a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
09b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
09c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
09d0: 2d 2d 2d 2d 2d 2d 2d 2d 0a 20 2a 0a 20 2a 20 46  --------. *. * F
09e0: 69 6c 65 43 6f 70 79 52 65 6e 61 6d 65 20 2d 2d  ileCopyRename --
09f0: 0a 20 2a 0a 20 2a 09 50 65 72 66 6f 72 6d 73 20  . *. *.Performs 
0a00: 74 68 65 20 77 6f 72 6b 20 6f 66 20 54 63 6c 46  the work of TclF
0a10: 69 6c 65 52 65 6e 61 6d 65 43 6d 64 20 61 6e 64  ileRenameCmd and
0a20: 20 54 63 6c 46 69 6c 65 43 6f 70 79 43 6d 64 2e   TclFileCopyCmd.
0a30: 20 53 65 65 0a 20 2a 09 63 6f 6d 6d 65 6e 74 73   See. *.comments
0a40: 20 66 6f 72 20 74 68 6f 73 65 20 66 75 6e 63 74   for those funct
0a50: 69 6f 6e 73 2e 0a 20 2a 0a 20 2a 20 52 65 73 75  ions.. *. * Resu
0a60: 6c 74 73 3a 0a 20 2a 09 53 65 65 20 61 62 6f 76  lts:. *.See abov
0a70: 65 2e 0a 20 2a 0a 20 2a 20 53 69 64 65 20 65 66  e.. *. * Side ef
0a80: 66 65 63 74 73 3a 0a 20 2a 09 53 65 65 20 61 62  fects:. *.See ab
0a90: 6f 76 65 2e 0a 20 2a 0a 20 2a 2d 2d 2d 2d 2d 2d  ove.. *. *------
0aa0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0ab0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0ac0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0ad0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0ae0: 2d 2d 2d 2d 2d 0a 20 2a 2f 0a 0a 73 74 61 74 69  -----. */..stati
0af0: 63 20 69 6e 74 0a 46 69 6c 65 43 6f 70 79 52 65  c int.FileCopyRe
0b00: 6e 61 6d 65 28 0a 20 20 20 20 54 63 6c 5f 49 6e  name(.    Tcl_In
0b10: 74 65 72 70 20 2a 69 6e 74 65 72 70 2c 09 09 2f  terp *interp,../
0b20: 2a 20 55 73 65 64 20 66 6f 72 20 65 72 72 6f 72  * Used for error
0b30: 20 72 65 70 6f 72 74 69 6e 67 2e 20 2a 2f 0a 20   reporting. */. 
0b40: 20 20 20 69 6e 74 20 6f 62 6a 63 2c 09 09 09 2f     int objc,.../
0b50: 2a 20 4e 75 6d 62 65 72 20 6f 66 20 61 72 67 75  * Number of argu
0b60: 6d 65 6e 74 73 2e 20 2a 2f 0a 20 20 20 20 54 63  ments. */.    Tc
0b70: 6c 5f 4f 62 6a 20 2a 43 4f 4e 53 54 20 6f 62 6a  l_Obj *CONST obj
0b80: 76 5b 5d 2c 09 2f 2a 20 41 72 67 75 6d 65 6e 74  v[],./* Argument
0b90: 20 73 74 72 69 6e 67 73 20 70 61 73 73 65 64 20   strings passed 
0ba0: 74 6f 20 54 63 6c 5f 46 69 6c 65 43 6d 64 2e 20  to Tcl_FileCmd. 
0bb0: 2a 2f 0a 20 20 20 20 69 6e 74 20 63 6f 70 79 46  */.    int copyF
0bc0: 6c 61 67 29 09 09 2f 2a 20 49 66 20 6e 6f 6e 2d  lag)../* If non-
0bd0: 7a 65 72 6f 2c 20 63 6f 70 79 20 73 6f 75 72 63  zero, copy sourc
0be0: 65 28 73 29 2e 20 4f 74 68 65 72 77 69 73 65 2c  e(s). Otherwise,
0bf0: 0a 09 09 09 09 20 2a 20 72 65 6e 61 6d 65 20 74  ..... * rename t
0c00: 68 65 6d 2e 20 2a 2f 0a 7b 0a 20 20 20 20 69 6e  hem. */.{.    in
0c10: 74 20 69 2c 20 72 65 73 75 6c 74 2c 20 66 6f 72  t i, result, for
0c20: 63 65 3b 0a 20 20 20 20 54 63 6c 5f 53 74 61 74  ce;.    Tcl_Stat
0c30: 42 75 66 20 73 74 61 74 42 75 66 3b 0a 20 20 20  Buf statBuf;.   
0c40: 20 54 63 6c 5f 4f 62 6a 20 2a 74 61 72 67 65 74   Tcl_Obj *target
0c50: 3b 0a 0a 20 20 20 20 69 20 3d 20 46 69 6c 65 46  ;..    i = FileF
0c60: 6f 72 63 65 4f 70 74 69 6f 6e 28 69 6e 74 65 72  orceOption(inter
0c70: 70 2c 20 6f 62 6a 63 20 2d 20 32 2c 20 6f 62 6a  p, objc - 2, obj
0c80: 76 20 2b 20 32 2c 20 26 66 6f 72 63 65 29 3b 0a  v + 2, &force);.
0c90: 20 20 20 20 69 66 20 28 69 20 3c 20 30 29 20 7b      if (i < 0) {
0ca0: 0a 09 72 65 74 75 72 6e 20 54 43 4c 5f 45 52 52  ..return TCL_ERR
0cb0: 4f 52 3b 0a 20 20 20 20 7d 0a 20 20 20 20 69 20  OR;.    }.    i 
0cc0: 2b 3d 20 32 3b 0a 20 20 20 20 69 66 20 28 28 6f  += 2;.    if ((o
0cd0: 62 6a 63 20 2d 20 69 29 20 3c 20 32 29 20 7b 0a  bjc - i) < 2) {.
0ce0: 09 54 63 6c 5f 41 70 70 65 6e 64 52 65 73 75 6c  .Tcl_AppendResul
0cf0: 74 28 69 6e 74 65 72 70 2c 20 22 77 72 6f 6e 67  t(interp, "wrong
0d00: 20 23 20 61 72 67 73 3a 20 73 68 6f 75 6c 64 20   # args: should 
0d10: 62 65 20 5c 22 22 2c 0a 09 09 54 63 6c 47 65 74  be \"",...TclGet
0d20: 53 74 72 69 6e 67 28 6f 62 6a 76 5b 30 5d 29 2c  String(objv[0]),
0d30: 20 22 20 22 2c 20 54 63 6c 47 65 74 53 74 72 69   " ", TclGetStri
0d40: 6e 67 28 6f 62 6a 76 5b 31 5d 29 2c 0a 09 09 22  ng(objv[1]),..."
0d50: 20 3f 6f 70 74 69 6f 6e 73 3f 20 73 6f 75 72 63   ?options? sourc
0d60: 65 20 3f 73 6f 75 72 63 65 20 2e 2e 2e 3f 20 74  e ?source ...? t
0d70: 61 72 67 65 74 5c 22 22 2c 20 4e 55 4c 4c 29 3b  arget\"", NULL);
0d80: 0a 09 72 65 74 75 72 6e 20 54 43 4c 5f 45 52 52  ..return TCL_ERR
0d90: 4f 52 3b 0a 20 20 20 20 7d 0a 0a 20 20 20 20 2f  OR;.    }..    /
0da0: 2a 0a 20 20 20 20 20 2a 20 49 66 20 74 61 72 67  *.     * If targ
0db0: 65 74 20 64 6f 65 73 6e 27 74 20 65 78 69 73 74  et doesn't exist
0dc0: 20 6f 72 20 69 73 6e 27 74 20 61 20 64 69 72 65   or isn't a dire
0dd0: 63 74 6f 72 79 2c 20 74 72 79 20 74 68 65 20 63  ctory, try the c
0de0: 6f 70 79 2f 72 65 6e 61 6d 65 2e 0a 20 20 20 20  opy/rename..    
0df0: 20 2a 20 4d 6f 72 65 20 74 68 61 6e 20 32 20 61   * More than 2 a
0e00: 72 67 75 6d 65 6e 74 73 20 69 73 20 6f 6e 6c 79  rguments is only
0e10: 20 76 61 6c 69 64 20 69 66 20 74 68 65 20 74 61   valid if the ta
0e20: 72 67 65 74 20 69 73 20 61 6e 20 65 78 69 73 74  rget is an exist
0e30: 69 6e 67 0a 20 20 20 20 20 2a 20 64 69 72 65 63  ing.     * direc
0e40: 74 6f 72 79 2e 0a 20 20 20 20 20 2a 2f 0a 0a 20  tory..     */.. 
0e50: 20 20 20 74 61 72 67 65 74 20 3d 20 6f 62 6a 76     target = objv
0e60: 5b 6f 62 6a 63 20 2d 20 31 5d 3b 0a 20 20 20 20  [objc - 1];.    
0e70: 69 66 20 28 54 63 6c 5f 46 53 43 6f 6e 76 65 72  if (Tcl_FSConver
0e80: 74 54 6f 50 61 74 68 54 79 70 65 28 69 6e 74 65  tToPathType(inte
0e90: 72 70 2c 20 74 61 72 67 65 74 29 20 21 3d 20 54  rp, target) != T
0ea0: 43 4c 5f 4f 4b 29 20 7b 0a 09 72 65 74 75 72 6e  CL_OK) {..return
0eb0: 20 54 43 4c 5f 45 52 52 4f 52 3b 0a 20 20 20 20   TCL_ERROR;.    
0ec0: 7d 0a 0a 20 20 20 20 72 65 73 75 6c 74 20 3d 20  }..    result = 
0ed0: 54 43 4c 5f 4f 4b 3b 0a 0a 20 20 20 20 2f 2a 0a  TCL_OK;..    /*.
0ee0: 20 20 20 20 20 2a 20 43 61 6c 6c 20 54 63 6c 5f       * Call Tcl_
0ef0: 46 53 53 74 61 74 28 29 20 73 6f 20 74 68 61 74  FSStat() so that
0f00: 20 69 66 20 74 61 72 67 65 74 20 69 73 20 61 20   if target is a 
0f10: 73 79 6d 6c 69 6e 6b 20 74 68 61 74 20 70 6f 69  symlink that poi
0f20: 6e 74 73 20 74 6f 20 61 0a 20 20 20 20 20 2a 20  nts to a.     * 
0f30: 64 69 72 65 63 74 6f 72 79 20 77 65 20 77 69 6c  directory we wil
0f40: 6c 20 70 75 74 20 74 68 65 20 73 6f 75 72 63 65  l put the source
0f50: 73 20 69 6e 20 74 68 61 74 20 64 69 72 65 63 74  s in that direct
0f60: 6f 72 79 20 69 6e 73 74 65 61 64 20 6f 66 0a 20  ory instead of. 
0f70: 20 20 20 20 2a 20 6f 76 65 72 77 72 69 74 69 6e      * overwritin
0f80: 67 20 74 68 65 20 73 79 6d 6c 69 6e 6b 2e 0a 20  g the symlink.. 
0f90: 20 20 20 20 2a 2f 0a 0a 20 20 20 20 69 66 20 28      */..    if (
0fa0: 28 54 63 6c 5f 46 53 53 74 61 74 28 74 61 72 67  (Tcl_FSStat(targ
0fb0: 65 74 2c 20 26 73 74 61 74 42 75 66 29 20 21 3d  et, &statBuf) !=
0fc0: 20 30 29 20 7c 7c 20 21 53 5f 49 53 44 49 52 28   0) || !S_ISDIR(
0fd0: 73 74 61 74 42 75 66 2e 73 74 5f 6d 6f 64 65 29  statBuf.st_mode)
0fe0: 29 20 7b 0a 09 69 66 20 28 28 6f 62 6a 63 20 2d  ) {..if ((objc -
0ff0: 20 69 29 20 3e 20 32 29 20 7b 0a 09 20 20 20 20   i) > 2) {..    
1000: 65 72 72 6e 6f 20 3d 20 45 4e 4f 54 44 49 52 3b  errno = ENOTDIR;
1010: 0a 09 20 20 20 20 54 63 6c 5f 50 6f 73 69 78 45  ..    Tcl_PosixE
1020: 72 72 6f 72 28 69 6e 74 65 72 70 29 3b 0a 09 20  rror(interp);.. 
1030: 20 20 20 54 63 6c 5f 41 70 70 65 6e 64 52 65 73     Tcl_AppendRes
1040: 75 6c 74 28 69 6e 74 65 72 70 2c 20 22 65 72 72  ult(interp, "err
1050: 6f 72 20 22 2c 0a 09 09 20 20 20 20 28 63 6f 70  or ",...    (cop
1060: 79 46 6c 61 67 20 3f 20 22 63 6f 70 79 69 6e 67  yFlag ? "copying
1070: 22 20 3a 20 22 72 65 6e 61 6d 69 6e 67 22 29 2c  " : "renaming"),
1080: 20 22 3a 20 74 61 72 67 65 74 20 5c 22 22 2c 0a   ": target \"",.
1090: 09 09 20 20 20 20 54 63 6c 47 65 74 53 74 72 69  ..    TclGetStri
10a0: 6e 67 28 74 61 72 67 65 74 29 2c 20 22 5c 22 20  ng(target), "\" 
10b0: 69 73 20 6e 6f 74 20 61 20 64 69 72 65 63 74 6f  is not a directo
10c0: 72 79 22 2c 20 4e 55 4c 4c 29 3b 0a 09 20 20 20  ry", NULL);..   
10d0: 20 72 65 73 75 6c 74 20 3d 20 54 43 4c 5f 45 52   result = TCL_ER
10e0: 52 4f 52 3b 0a 09 7d 20 65 6c 73 65 20 7b 0a 09  ROR;..} else {..
10f0: 20 20 20 20 2f 2a 0a 09 20 20 20 20 20 2a 20 45      /*..     * E
1100: 76 65 6e 20 74 68 6f 75 67 68 20 61 6c 72 65 61  ven though alrea
1110: 64 79 20 68 61 76 65 20 74 61 72 67 65 74 20 3d  dy have target =
1120: 3d 20 74 72 61 6e 73 6c 61 74 65 64 28 6f 62 6a  = translated(obj
1130: 76 5b 69 2b 31 5d 29 2c 20 70 61 73 73 0a 09 20  v[i+1]), pass.. 
1140: 20 20 20 20 2a 20 74 68 65 20 6f 72 69 67 69 6e      * the origin
1150: 61 6c 20 61 72 67 75 6d 65 6e 74 20 64 6f 77 6e  al argument down
1160: 2c 20 73 6f 20 69 66 20 74 68 65 72 65 27 73 20  , so if there's 
1170: 61 6e 20 65 72 72 6f 72 2c 20 74 68 65 20 65 72  an error, the er
1180: 72 6f 72 0a 09 20 20 20 20 20 2a 20 6d 65 73 73  ror..     * mess
1190: 61 67 65 20 77 69 6c 6c 20 72 65 66 6c 65 63 74  age will reflect
11a0: 20 74 68 65 20 6f 72 69 67 69 6e 61 6c 20 61 72   the original ar
11b0: 67 75 6d 65 6e 74 73 2e 0a 09 20 20 20 20 20 2a  guments...     *
11c0: 2f 0a 0a 09 20 20 20 20 72 65 73 75 6c 74 20 3d  /...    result =
11d0: 20 43 6f 70 79 52 65 6e 61 6d 65 4f 6e 65 46 69   CopyRenameOneFi
11e0: 6c 65 28 69 6e 74 65 72 70 2c 20 6f 62 6a 76 5b  le(interp, objv[
11f0: 69 5d 2c 20 6f 62 6a 76 5b 69 20 2b 20 31 5d 2c  i], objv[i + 1],
1200: 20 63 6f 70 79 46 6c 61 67 2c 0a 09 09 20 20 20   copyFlag,...   
1210: 20 66 6f 72 63 65 29 3b 0a 09 7d 0a 09 72 65 74   force);..}..ret
1220: 75 72 6e 20 72 65 73 75 6c 74 3b 0a 20 20 20 20  urn result;.    
1230: 7d 0a 0a 20 20 20 20 2f 2a 0a 20 20 20 20 20 2a  }..    /*.     *
1240: 20 4d 6f 76 65 20 65 61 63 68 20 73 6f 75 72 63   Move each sourc
1250: 65 20 66 69 6c 65 20 69 6e 74 6f 20 74 61 72 67  e file into targ
1260: 65 74 20 64 69 72 65 63 74 6f 72 79 2e 20 45 78  et directory. Ex
1270: 74 72 61 63 74 20 74 68 65 20 62 61 73 65 6e 61  tract the basena
1280: 6d 65 20 66 72 6f 6d 0a 20 20 20 20 20 2a 20 65  me from.     * e
1290: 61 63 68 20 73 6f 75 72 63 65 2c 20 61 6e 64 20  ach source, and 
12a0: 61 70 70 65 6e 64 20 69 74 20 74 6f 20 74 68 65  append it to the
12b0: 20 65 6e 64 20 6f 66 20 74 68 65 20 74 61 72 67   end of the targ
12c0: 65 74 20 70 61 74 68 2e 0a 20 20 20 20 20 2a 2f  et path..     */
12d0: 0a 0a 20 20 20 20 66 6f 72 20 28 20 3b 20 69 3c  ..    for ( ; i<
12e0: 6f 62 6a 63 2d 31 20 3b 20 69 2b 2b 29 20 7b 0a  objc-1 ; i++) {.
12f0: 09 54 63 6c 5f 4f 62 6a 20 2a 6a 61 72 67 76 5b  .Tcl_Obj *jargv[
1300: 32 5d 3b 0a 09 54 63 6c 5f 4f 62 6a 20 2a 73 6f  2];..Tcl_Obj *so
1310: 75 72 63 65 2c 20 2a 6e 65 77 46 69 6c 65 4e 61  urce, *newFileNa
1320: 6d 65 3b 0a 09 54 63 6c 5f 4f 62 6a 20 2a 74 65  me;..Tcl_Obj *te
1330: 6d 70 3b 0a 0a 09 73 6f 75 72 63 65 20 3d 20 46  mp;...source = F
1340: 69 6c 65 42 61 73 65 6e 61 6d 65 28 69 6e 74 65  ileBasename(inte
1350: 72 70 2c 20 6f 62 6a 76 5b 69 5d 29 3b 0a 09 69  rp, objv[i]);..i
1360: 66 20 28 73 6f 75 72 63 65 20 3d 3d 20 4e 55 4c  f (source == NUL
1370: 4c 29 20 7b 0a 09 20 20 20 20 72 65 73 75 6c 74  L) {..    result
1380: 20 3d 20 54 43 4c 5f 45 52 52 4f 52 3b 0a 09 20   = TCL_ERROR;.. 
1390: 20 20 20 62 72 65 61 6b 3b 0a 09 7d 0a 09 6a 61     break;..}..ja
13a0: 72 67 76 5b 30 5d 20 3d 20 6f 62 6a 76 5b 6f 62  rgv[0] = objv[ob
13b0: 6a 63 20 2d 20 31 5d 3b 0a 09 6a 61 72 67 76 5b  jc - 1];..jargv[
13c0: 31 5d 20 3d 20 73 6f 75 72 63 65 3b 0a 09 74 65  1] = source;..te
13d0: 6d 70 20 3d 20 54 63 6c 5f 4e 65 77 4c 69 73 74  mp = Tcl_NewList
13e0: 4f 62 6a 28 32 2c 20 6a 61 72 67 76 29 3b 0a 09  Obj(2, jargv);..
13f0: 6e 65 77 46 69 6c 65 4e 61 6d 65 20 3d 20 54 63  newFileName = Tc
1400: 6c 5f 46 53 4a 6f 69 6e 50 61 74 68 28 74 65 6d  l_FSJoinPath(tem
1410: 70 2c 20 2d 31 29 3b 0a 09 54 63 6c 5f 49 6e 63  p, -1);..Tcl_Inc
1420: 72 52 65 66 43 6f 75 6e 74 28 6e 65 77 46 69 6c  rRefCount(newFil
1430: 65 4e 61 6d 65 29 3b 0a 09 72 65 73 75 6c 74 20  eName);..result 
1440: 3d 20 43 6f 70 79 52 65 6e 61 6d 65 4f 6e 65 46  = CopyRenameOneF
1450: 69 6c 65 28 69 6e 74 65 72 70 2c 20 6f 62 6a 76  ile(interp, objv
1460: 5b 69 5d 2c 20 6e 65 77 46 69 6c 65 4e 61 6d 65  [i], newFileName
1470: 2c 20 63 6f 70 79 46 6c 61 67 2c 0a 09 09 66 6f  , copyFlag,...fo
1480: 72 63 65 29 3b 0a 09 54 63 6c 5f 44 65 63 72 52  rce);..Tcl_DecrR
1490: 65 66 43 6f 75 6e 74 28 6e 65 77 46 69 6c 65 4e  efCount(newFileN
14a0: 61 6d 65 29 3b 0a 09 54 63 6c 5f 44 65 63 72 52  ame);..Tcl_DecrR
14b0: 65 66 43 6f 75 6e 74 28 74 65 6d 70 29 3b 0a 09  efCount(temp);..
14c0: 54 63 6c 5f 44 65 63 72 52 65 66 43 6f 75 6e 74  Tcl_DecrRefCount
14d0: 28 73 6f 75 72 63 65 29 3b 0a 0a 09 69 66 20 28  (source);...if (
14e0: 72 65 73 75 6c 74 20 3d 3d 20 54 43 4c 5f 45 52  result == TCL_ER
14f0: 52 4f 52 29 20 7b 0a 09 20 20 20 20 62 72 65 61  ROR) {..    brea
1500: 6b 3b 0a 09 7d 0a 20 20 20 20 7d 0a 20 20 20 20  k;..}.    }.    
1510: 72 65 74 75 72 6e 20 72 65 73 75 6c 74 3b 0a 7d  return result;.}
1520: 0a 0c 0a 2f 2a 0a 20 2a 2d 2d 2d 2d 2d 2d 2d 2d  .../*. *--------
1530: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1540: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1550: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1560: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1570: 2d 2d 2d 0a 20 2a 0a 20 2a 20 54 63 6c 46 69 6c  ---. *. * TclFil
1580: 65 4d 61 6b 65 44 69 72 73 43 6d 64 0a 20 2a 0a  eMakeDirsCmd. *.
1590: 20 2a 09 54 68 69 73 20 66 75 6e 63 74 69 6f 6e   *.This function
15a0: 20 69 6d 70 6c 65 6d 65 6e 74 73 20 74 68 65 20   implements the 
15b0: 22 6d 6b 64 69 72 22 20 73 75 62 63 6f 6d 6d 61  "mkdir" subcomma
15c0: 6e 64 20 6f 66 20 74 68 65 20 22 66 69 6c 65 22  nd of the "file"
15d0: 20 63 6f 6d 6d 61 6e 64 2e 0a 20 2a 09 46 69 6c   command.. *.Fil
15e0: 65 6e 61 6d 65 20 61 72 67 75 6d 65 6e 74 73 20  ename arguments 
15f0: 6e 65 65 64 20 74 6f 20 62 65 20 74 72 61 6e 73  need to be trans
1600: 6c 61 74 65 64 20 74 6f 20 6e 61 74 69 76 65 20  lated to native 
1610: 66 6f 72 6d 61 74 20 62 65 66 6f 72 65 20 62 65  format before be
1620: 69 6e 67 0a 20 2a 09 70 61 73 73 65 64 20 74 6f  ing. *.passed to
1630: 20 70 6c 61 74 66 6f 72 6d 2d 73 70 65 63 69 66   platform-specif
1640: 69 63 20 63 6f 64 65 20 74 68 61 74 20 69 6d 70  ic code that imp
1650: 6c 65 6d 65 6e 74 73 20 6d 6b 64 69 72 20 66 75  lements mkdir fu
1660: 6e 63 74 69 6f 6e 61 6c 69 74 79 2e 0a 20 2a 0a  nctionality.. *.
1670: 20 2a 20 52 65 73 75 6c 74 73 3a 0a 20 2a 09 41   * Results:. *.A
1680: 20 73 74 61 6e 64 61 72 64 20 54 63 6c 20 72 65   standard Tcl re
1690: 73 75 6c 74 2e 0a 20 2a 0a 20 2a 20 53 69 64 65  sult.. *. * Side
16a0: 20 65 66 66 65 63 74 73 3a 0a 20 2a 09 53 65 65   effects:. *.See
16b0: 20 74 68 65 20 75 73 65 72 20 64 6f 63 75 6d 65   the user docume
16c0: 6e 74 61 74 69 6f 6e 2e 0a 20 2a 0a 20 2a 2d 2d  ntation.. *. *--
16d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
16e0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
16f0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1700: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1710: 2d 2d 2d 2d 0a 20 2a 2f 0a 0a 69 6e 74 0a 54 63  ----. */..int.Tc
1720: 6c 46 69 6c 65 4d 61 6b 65 44 69 72 73 43 6d 64  lFileMakeDirsCmd
1730: 28 0a 20 20 20 20 54 63 6c 5f 49 6e 74 65 72 70  (.    Tcl_Interp
1740: 20 2a 69 6e 74 65 72 70 2c 09 09 2f 2a 20 55 73   *interp,../* Us
1750: 65 64 20 66 6f 72 20 65 72 72 6f 72 20 72 65 70  ed for error rep
1760: 6f 72 74 69 6e 67 2e 20 2a 2f 0a 20 20 20 20 69  orting. */.    i
1770: 6e 74 20 6f 62 6a 63 2c 09 09 09 2f 2a 20 4e 75  nt objc,.../* Nu
1780: 6d 62 65 72 20 6f 66 20 61 72 67 75 6d 65 6e 74  mber of argument
1790: 73 20 2a 2f 0a 20 20 20 20 54 63 6c 5f 4f 62 6a  s */.    Tcl_Obj
17a0: 20 2a 43 4f 4e 53 54 20 6f 62 6a 76 5b 5d 29 09   *CONST objv[]).
17b0: 2f 2a 20 41 72 67 75 6d 65 6e 74 20 73 74 72 69  /* Argument stri
17c0: 6e 67 73 20 70 61 73 73 65 64 20 74 6f 20 54 63  ngs passed to Tc
17d0: 6c 5f 46 69 6c 65 43 6d 64 2e 20 2a 2f 0a 7b 0a  l_FileCmd. */.{.
17e0: 20 20 20 20 54 63 6c 5f 4f 62 6a 20 2a 65 72 72      Tcl_Obj *err
17f0: 66 69 6c 65 3b 0a 20 20 20 20 69 6e 74 20 72 65  file;.    int re
1800: 73 75 6c 74 2c 20 69 2c 20 6a 2c 20 70 6f 62 6a  sult, i, j, pobj
1810: 63 3b 0a 20 20 20 20 54 63 6c 5f 4f 62 6a 20 2a  c;.    Tcl_Obj *
1820: 73 70 6c 69 74 20 3d 20 4e 55 4c 4c 3b 0a 20 20  split = NULL;.  
1830: 20 20 54 63 6c 5f 4f 62 6a 20 2a 74 61 72 67 65    Tcl_Obj *targe
1840: 74 20 3d 20 4e 55 4c 4c 3b 0a 20 20 20 20 54 63  t = NULL;.    Tc
1850: 6c 5f 53 74 61 74 42 75 66 20 73 74 61 74 42 75  l_StatBuf statBu
1860: 66 3b 0a 0a 20 20 20 20 65 72 72 66 69 6c 65 20  f;..    errfile 
1870: 3d 20 4e 55 4c 4c 3b 0a 0a 20 20 20 20 72 65 73  = NULL;..    res
1880: 75 6c 74 20 3d 20 54 43 4c 5f 4f 4b 3b 0a 20 20  ult = TCL_OK;.  
1890: 20 20 66 6f 72 20 28 69 20 3d 20 32 3b 20 69 20    for (i = 2; i 
18a0: 3c 20 6f 62 6a 63 3b 20 69 2b 2b 29 20 7b 0a 09  < objc; i++) {..
18b0: 69 66 20 28 54 63 6c 5f 46 53 43 6f 6e 76 65 72  if (Tcl_FSConver
18c0: 74 54 6f 50 61 74 68 54 79 70 65 28 69 6e 74 65  tToPathType(inte
18d0: 72 70 2c 20 6f 62 6a 76 5b 69 5d 29 20 21 3d 20  rp, objv[i]) != 
18e0: 54 43 4c 5f 4f 4b 29 20 7b 0a 09 20 20 20 20 72  TCL_OK) {..    r
18f0: 65 73 75 6c 74 20 3d 20 54 43 4c 5f 45 52 52 4f  esult = TCL_ERRO
1900: 52 3b 0a 09 20 20 20 20 62 72 65 61 6b 3b 0a 09  R;..    break;..
1910: 7d 0a 0a 09 73 70 6c 69 74 20 3d 20 54 63 6c 5f  }...split = Tcl_
1920: 46 53 53 70 6c 69 74 50 61 74 68 28 6f 62 6a 76  FSSplitPath(objv
1930: 5b 69 5d 2c 26 70 6f 62 6a 63 29 3b 0a 09 54 63  [i],&pobjc);..Tc
1940: 6c 5f 49 6e 63 72 52 65 66 43 6f 75 6e 74 28 73  l_IncrRefCount(s
1950: 70 6c 69 74 29 3b 0a 09 69 66 20 28 70 6f 62 6a  plit);..if (pobj
1960: 63 20 3d 3d 20 30 29 20 7b 0a 09 20 20 20 20 65  c == 0) {..    e
1970: 72 72 6e 6f 20 3d 20 45 4e 4f 45 4e 54 3b 0a 09  rrno = ENOENT;..
1980: 20 20 20 20 65 72 72 66 69 6c 65 20 3d 20 6f 62      errfile = ob
1990: 6a 76 5b 69 5d 3b 0a 09 20 20 20 20 62 72 65 61  jv[i];..    brea
19a0: 6b 3b 0a 09 7d 0a 09 66 6f 72 20 28 6a 20 3d 20  k;..}..for (j = 
19b0: 30 3b 20 6a 20 3c 20 70 6f 62 6a 63 3b 20 6a 2b  0; j < pobjc; j+
19c0: 2b 29 20 7b 0a 09 20 20 20 20 69 6e 74 20 65 72  +) {..    int er
19d0: 72 43 6f 75 6e 74 20 3d 20 32 3b 0a 0a 09 20 20  rCount = 2;...  
19e0: 20 20 74 61 72 67 65 74 20 3d 20 54 63 6c 5f 46    target = Tcl_F
19f0: 53 4a 6f 69 6e 50 61 74 68 28 73 70 6c 69 74 2c  SJoinPath(split,
1a00: 20 6a 20 2b 20 31 29 3b 0a 09 20 20 20 20 54 63   j + 1);..    Tc
1a10: 6c 5f 49 6e 63 72 52 65 66 43 6f 75 6e 74 28 74  l_IncrRefCount(t
1a20: 61 72 67 65 74 29 3b 0a 0a 09 63 72 65 61 74 65  arget);...create
1a30: 44 69 72 3a 0a 0a 09 20 20 20 20 2f 2a 0a 09 20  Dir:...    /*.. 
1a40: 20 20 20 20 2a 20 43 61 6c 6c 20 54 63 6c 5f 46      * Call Tcl_F
1a50: 53 53 74 61 74 28 29 20 73 6f 20 74 68 61 74 20  SStat() so that 
1a60: 69 66 20 74 61 72 67 65 74 20 69 73 20 61 20 73  if target is a s
1a70: 79 6d 6c 69 6e 6b 20 74 68 61 74 20 70 6f 69 6e  ymlink that poin
1a80: 74 73 20 74 6f 0a 09 20 20 20 20 20 2a 20 61 20  ts to..     * a 
1a90: 64 69 72 65 63 74 6f 72 79 20 77 65 20 77 69 6c  directory we wil
1aa0: 6c 20 63 72 65 61 74 65 20 73 75 62 64 69 72 65  l create subdire
1ab0: 63 74 6f 72 69 65 73 20 69 6e 20 74 68 61 74 20  ctories in that 
1ac0: 64 69 72 65 63 74 6f 72 79 2e 0a 09 20 20 20 20  directory...    
1ad0: 20 2a 2f 0a 0a 09 20 20 20 20 69 66 20 28 54 63   */...    if (Tc
1ae0: 6c 5f 46 53 53 74 61 74 28 74 61 72 67 65 74 2c  l_FSStat(target,
1af0: 20 26 73 74 61 74 42 75 66 29 20 3d 3d 20 30 29   &statBuf) == 0)
1b00: 20 7b 0a 09 09 69 66 20 28 21 53 5f 49 53 44 49   {...if (!S_ISDI
1b10: 52 28 73 74 61 74 42 75 66 2e 73 74 5f 6d 6f 64  R(statBuf.st_mod
1b20: 65 29 29 20 7b 0a 09 09 20 20 20 20 65 72 72 6e  e)) {...    errn
1b30: 6f 20 3d 20 45 45 58 49 53 54 3b 0a 09 09 20 20  o = EEXIST;...  
1b40: 20 20 65 72 72 66 69 6c 65 20 3d 20 74 61 72 67    errfile = targ
1b50: 65 74 3b 0a 09 09 20 20 20 20 67 6f 74 6f 20 64  et;...    goto d
1b60: 6f 6e 65 3b 0a 09 09 7d 0a 09 20 20 20 20 7d 20  one;...}..    } 
1b70: 65 6c 73 65 20 69 66 20 28 65 72 72 6e 6f 20 21  else if (errno !
1b80: 3d 20 45 4e 4f 45 4e 54 29 20 7b 0a 09 09 2f 2a  = ENOENT) {.../*
1b90: 0a 09 09 20 2a 20 49 66 20 54 63 6c 5f 46 53 53  ... * If Tcl_FSS
1ba0: 74 61 74 28 29 20 66 61 69 6c 65 64 20 61 6e 64  tat() failed and
1bb0: 20 74 68 65 20 65 72 72 6f 72 20 69 73 20 61 6e   the error is an
1bc0: 79 74 68 69 6e 67 20 6f 74 68 65 72 20 74 68 61  ything other tha
1bd0: 6e 0a 09 09 20 2a 20 6e 6f 6e 2d 65 78 69 73 74  n... * non-exist
1be0: 65 6e 63 65 20 6f 66 20 74 68 65 20 74 61 72 67  ence of the targ
1bf0: 65 74 2c 20 74 68 72 6f 77 20 74 68 65 20 65 72  et, throw the er
1c00: 72 6f 72 2e 0a 09 09 20 2a 2f 0a 0a 09 09 65 72  ror.... */....er
1c10: 72 66 69 6c 65 20 3d 20 74 61 72 67 65 74 3b 0a  rfile = target;.
1c20: 09 09 67 6f 74 6f 20 64 6f 6e 65 3b 0a 09 20 20  ..goto done;..  
1c30: 20 20 7d 20 65 6c 73 65 20 69 66 20 28 54 63 6c    } else if (Tcl
1c40: 5f 46 53 43 72 65 61 74 65 44 69 72 65 63 74 6f  _FSCreateDirecto
1c50: 72 79 28 74 61 72 67 65 74 29 20 21 3d 20 54 43  ry(target) != TC
1c60: 4c 5f 4f 4b 29 20 7b 0a 09 09 2f 2a 0a 09 09 20  L_OK) {.../*... 
1c70: 2a 20 43 72 65 61 74 65 20 6d 69 67 68 74 20 68  * Create might h
1c80: 61 76 65 20 66 61 69 6c 65 64 20 62 65 63 61 75  ave failed becau
1c90: 73 65 20 6f 66 20 62 65 69 6e 67 20 69 6e 20 61  se of being in a
1ca0: 20 72 61 63 65 0a 09 09 20 2a 20 63 6f 6e 64 69   race... * condi
1cb0: 74 69 6f 6e 20 77 69 74 68 20 61 6e 6f 74 68 65  tion with anothe
1cc0: 72 20 70 72 6f 63 65 73 73 20 74 72 79 69 6e 67  r process trying
1cd0: 20 74 6f 20 63 72 65 61 74 65 20 74 68 65 20 73   to create the s
1ce0: 61 6d 65 0a 09 09 20 2a 20 73 75 62 64 69 72 65  ame... * subdire
1cf0: 63 74 6f 72 79 2e 0a 09 09 20 2a 2f 0a 0a 09 09  ctory.... */....
1d00: 69 66 20 28 65 72 72 6e 6f 20 3d 3d 20 45 45 58  if (errno == EEX
1d10: 49 53 54 29 20 7b 0a 09 09 20 20 20 20 2f 2a 20  IST) {...    /* 
1d20: 42 65 20 61 77 61 72 65 20 6f 74 68 65 72 20 77  Be aware other w
1d30: 6f 72 6b 65 72 73 20 63 6f 75 6c 64 20 64 65 6c  orkers could del
1d40: 65 74 65 20 69 74 20 69 6d 6d 65 64 69 61 74 65  ete it immediate
1d50: 6c 79 20 61 66 74 65 72 0a 09 09 20 20 20 20 20  ly after...     
1d60: 2a 20 63 72 65 61 74 69 6f 6e 2c 20 73 6f 20 67  * creation, so g
1d70: 69 76 65 20 74 68 69 73 20 77 6f 72 6b 65 72 20  ive this worker 
1d80: 73 74 69 6c 6c 20 6f 6e 65 20 63 68 61 6e 63 65  still one chance
1d90: 20 28 72 65 70 65 61 74 20 6f 6e 63 65 29 2c 0a   (repeat once),.
1da0: 09 09 20 20 20 20 20 2a 20 73 65 65 20 5b 32 37  ..     * see [27
1db0: 30 66 37 38 63 61 39 35 5d 20 66 6f 72 20 64 65  0f78ca95] for de
1dc0: 73 63 72 69 70 74 69 6f 6e 20 6f 66 20 74 68 65  scription of the
1dd0: 20 72 61 63 65 2d 63 6f 6e 64 69 74 69 6f 6e 2e   race-condition.
1de0: 0a 09 09 20 20 20 20 20 2a 20 44 6f 6e 27 74 20  ...     * Don't 
1df0: 72 65 70 65 61 74 20 74 68 65 20 63 72 65 61 74  repeat the creat
1e00: 65 20 61 6c 77 61 79 73 20 28 74 6f 20 61 76 6f  e always (to avo
1e10: 69 64 20 65 6e 64 6c 65 73 73 20 6c 6f 6f 70 29  id endless loop)
1e20: 2e 20 2a 2f 0a 09 09 20 20 20 20 69 66 20 28 2d  . */...    if (-
1e30: 2d 65 72 72 43 6f 75 6e 74 20 3e 20 30 29 20 7b  -errCount > 0) {
1e40: 0a 09 09 09 67 6f 74 6f 20 63 72 65 61 74 65 44  ....goto createD
1e50: 69 72 3b 0a 09 09 20 20 20 20 7d 0a 09 09 20 20  ir;...    }...  
1e60: 20 20 2f 2a 20 41 6c 72 65 61 64 79 20 74 72 69    /* Already tri
1e70: 65 64 2c 20 77 69 74 68 20 64 65 6c 65 74 65 20  ed, with delete 
1e80: 69 6e 2d 62 65 74 77 65 65 6e 20 64 69 72 65 63  in-between direc
1e90: 74 6c 79 20 61 66 74 65 72 0a 09 09 20 20 20 20  tly after...    
1ea0: 20 2a 20 63 72 65 61 74 69 6f 6e 2c 20 73 6f 20   * creation, so 
1eb0: 6a 75 73 74 20 63 6f 6e 74 69 6e 75 65 20 28 61  just continue (a
1ec0: 73 73 75 6d 65 20 63 72 65 61 74 65 64 20 73 75  ssume created su
1ed0: 63 63 65 73 73 66 75 6c 29 2e 20 2a 2f 0a 09 09  ccessful). */...
1ee0: 20 20 20 20 67 6f 74 6f 20 6e 65 78 74 50 61 72      goto nextPar
1ef0: 74 3b 0a 09 09 7d 0a 0a 09 09 2f 2a 20 72 65 74  t;...}..../* ret
1f00: 75 72 6e 20 77 69 74 68 20 65 72 72 6f 72 20 2a  urn with error *
1f10: 2f 0a 09 09 65 72 72 66 69 6c 65 20 3d 20 74 61  /...errfile = ta
1f20: 72 67 65 74 3b 0a 09 09 67 6f 74 6f 20 64 6f 6e  rget;...goto don
1f30: 65 3b 0a 09 20 20 20 20 7d 0a 0a 09 6e 65 78 74  e;..    }...next
1f40: 50 61 72 74 3a 0a 09 20 20 20 20 2f 2a 0a 09 20  Part:..    /*.. 
1f50: 20 20 20 20 2a 20 46 6f 72 67 65 74 20 61 62 6f      * Forget abo
1f60: 75 74 20 74 68 69 73 20 73 75 62 2d 70 61 74 68  ut this sub-path
1f70: 2e 0a 09 20 20 20 20 20 2a 2f 0a 0a 09 20 20 20  ...     */...   
1f80: 20 54 63 6c 5f 44 65 63 72 52 65 66 43 6f 75 6e   Tcl_DecrRefCoun
1f90: 74 28 74 61 72 67 65 74 29 3b 0a 09 20 20 20 20  t(target);..    
1fa0: 74 61 72 67 65 74 20 3d 20 4e 55 4c 4c 3b 0a 09  target = NULL;..
1fb0: 7d 0a 09 54 63 6c 5f 44 65 63 72 52 65 66 43 6f  }..Tcl_DecrRefCo
1fc0: 75 6e 74 28 73 70 6c 69 74 29 3b 0a 09 73 70 6c  unt(split);..spl
1fd0: 69 74 20 3d 20 4e 55 4c 4c 3b 0a 20 20 20 20 7d  it = NULL;.    }
1fe0: 0a 0a 20 20 64 6f 6e 65 3a 0a 20 20 20 20 69 66  ..  done:.    if
1ff0: 20 28 65 72 72 66 69 6c 65 20 21 3d 20 4e 55 4c   (errfile != NUL
2000: 4c 29 20 7b 0a 09 54 63 6c 5f 41 70 70 65 6e 64  L) {..Tcl_Append
2010: 52 65 73 75 6c 74 28 69 6e 74 65 72 70 2c 20 22  Result(interp, "
2020: 63 61 6e 27 74 20 63 72 65 61 74 65 20 64 69 72  can't create dir
2030: 65 63 74 6f 72 79 20 5c 22 22 2c 0a 09 09 54 63  ectory \"",...Tc
2040: 6c 47 65 74 53 74 72 69 6e 67 28 65 72 72 66 69  lGetString(errfi
2050: 6c 65 29 2c 20 22 5c 22 3a 20 22 2c 20 54 63 6c  le), "\": ", Tcl
2060: 5f 50 6f 73 69 78 45 72 72 6f 72 28 69 6e 74 65  _PosixError(inte
2070: 72 70 29 2c 20 4e 55 4c 4c 29 3b 0a 09 72 65 73  rp), NULL);..res
2080: 75 6c 74 20 3d 20 54 43 4c 5f 45 52 52 4f 52 3b  ult = TCL_ERROR;
2090: 0a 20 20 20 20 7d 0a 20 20 20 20 69 66 20 28 73  .    }.    if (s
20a0: 70 6c 69 74 20 21 3d 20 4e 55 4c 4c 29 20 7b 0a  plit != NULL) {.
20b0: 09 54 63 6c 5f 44 65 63 72 52 65 66 43 6f 75 6e  .Tcl_DecrRefCoun
20c0: 74 28 73 70 6c 69 74 29 3b 0a 20 20 20 20 7d 0a  t(split);.    }.
20d0: 20 20 20 20 69 66 20 28 74 61 72 67 65 74 20 21      if (target !
20e0: 3d 20 4e 55 4c 4c 29 20 7b 0a 09 54 63 6c 5f 44  = NULL) {..Tcl_D
20f0: 65 63 72 52 65 66 43 6f 75 6e 74 28 74 61 72 67  ecrRefCount(targ
2100: 65 74 29 3b 0a 20 20 20 20 7d 0a 20 20 20 20 72  et);.    }.    r
2110: 65 74 75 72 6e 20 72 65 73 75 6c 74 3b 0a 7d 0a  eturn result;.}.
2120: 0c 0a 2f 2a 0a 20 2a 2d 2d 2d 2d 2d 2d 2d 2d 2d  ../*. *---------
2130: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2140: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2150: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2160: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 20 2a  -------------. *
2170: 0a 20 2a 20 54 63 6c 46 69 6c 65 44 65 6c 65 74  . * TclFileDelet
2180: 65 43 6d 64 0a 20 2a 0a 20 2a 09 54 68 69 73 20  eCmd. *. *.This 
2190: 66 75 6e 63 74 69 6f 6e 20 69 6d 70 6c 65 6d 65  function impleme
21a0: 6e 74 73 20 74 68 65 20 22 64 65 6c 65 74 65 22  nts the "delete"
21b0: 20 73 75 62 63 6f 6d 6d 61 6e 64 20 6f 66 20 74   subcommand of t
21c0: 68 65 20 22 66 69 6c 65 22 0a 20 2a 09 63 6f 6d  he "file". *.com
21d0: 6d 61 6e 64 2e 0a 20 2a 0a 20 2a 20 52 65 73 75  mand.. *. * Resu
21e0: 6c 74 73 3a 0a 20 2a 09 41 20 73 74 61 6e 64 61  lts:. *.A standa
21f0: 72 64 20 54 63 6c 20 72 65 73 75 6c 74 2e 0a 20  rd Tcl result.. 
2200: 2a 0a 20 2a 20 53 69 64 65 20 65 66 66 65 63 74  *. * Side effect
2210: 73 3a 0a 20 2a 09 53 65 65 20 74 68 65 20 75 73  s:. *.See the us
2220: 65 72 20 64 6f 63 75 6d 65 6e 74 61 74 69 6f 6e  er documentation
2230: 2e 0a 20 2a 0a 20 2a 2d 2d 2d 2d 2d 2d 2d 2d 2d  .. *. *---------
2240: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2250: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2260: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2270: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 20 2a  -------------. *
2280: 2f 0a 0a 69 6e 74 0a 54 63 6c 46 69 6c 65 44 65  /..int.TclFileDe
2290: 6c 65 74 65 43 6d 64 28 0a 20 20 20 20 54 63 6c  leteCmd(.    Tcl
22a0: 5f 49 6e 74 65 72 70 20 2a 69 6e 74 65 72 70 2c  _Interp *interp,
22b0: 09 09 2f 2a 20 55 73 65 64 20 66 6f 72 20 65 72  ../* Used for er
22c0: 72 6f 72 20 72 65 70 6f 72 74 69 6e 67 20 2a 2f  ror reporting */
22d0: 0a 20 20 20 20 69 6e 74 20 6f 62 6a 63 2c 09 09  .    int objc,..
22e0: 09 2f 2a 20 4e 75 6d 62 65 72 20 6f 66 20 61 72  ./* Number of ar
22f0: 67 75 6d 65 6e 74 73 20 2a 2f 0a 20 20 20 20 54  guments */.    T
2300: 63 6c 5f 4f 62 6a 20 2a 43 4f 4e 53 54 20 6f 62  cl_Obj *CONST ob
2310: 6a 76 5b 5d 29 09 2f 2a 20 41 72 67 75 6d 65 6e  jv[])./* Argumen
2320: 74 20 73 74 72 69 6e 67 73 20 70 61 73 73 65 64  t strings passed
2330: 20 74 6f 20 54 63 6c 5f 46 69 6c 65 43 6d 64 2e   to Tcl_FileCmd.
2340: 20 2a 2f 0a 7b 0a 20 20 20 20 69 6e 74 20 69 2c   */.{.    int i,
2350: 20 66 6f 72 63 65 2c 20 72 65 73 75 6c 74 3b 0a   force, result;.
2360: 20 20 20 20 54 63 6c 5f 4f 62 6a 20 2a 65 72 72      Tcl_Obj *err
2370: 66 69 6c 65 3b 0a 20 20 20 20 54 63 6c 5f 4f 62  file;.    Tcl_Ob
2380: 6a 20 2a 65 72 72 6f 72 42 75 66 66 65 72 20 3d  j *errorBuffer =
2390: 20 4e 55 4c 4c 3b 0a 0a 20 20 20 20 69 20 3d 20   NULL;..    i = 
23a0: 46 69 6c 65 46 6f 72 63 65 4f 70 74 69 6f 6e 28  FileForceOption(
23b0: 69 6e 74 65 72 70 2c 20 6f 62 6a 63 20 2d 20 32  interp, objc - 2
23c0: 2c 20 6f 62 6a 76 20 2b 20 32 2c 20 26 66 6f 72  , objv + 2, &for
23d0: 63 65 29 3b 0a 20 20 20 20 69 66 20 28 69 20 3c  ce);.    if (i <
23e0: 20 30 29 20 7b 0a 09 72 65 74 75 72 6e 20 54 43   0) {..return TC
23f0: 4c 5f 45 52 52 4f 52 3b 0a 20 20 20 20 7d 0a 20  L_ERROR;.    }. 
2400: 20 20 20 69 20 2b 3d 20 32 3b 0a 20 20 20 20 69     i += 2;.    i
2410: 66 20 28 28 6f 62 6a 63 20 2d 20 69 29 20 3c 20  f ((objc - i) < 
2420: 31 29 20 7b 0a 09 54 63 6c 5f 41 70 70 65 6e 64  1) {..Tcl_Append
2430: 52 65 73 75 6c 74 28 69 6e 74 65 72 70 2c 20 22  Result(interp, "
2440: 77 72 6f 6e 67 20 23 20 61 72 67 73 3a 20 73 68  wrong # args: sh
2450: 6f 75 6c 64 20 62 65 20 5c 22 22 2c 0a 09 09 54  ould be \"",...T
2460: 63 6c 47 65 74 53 74 72 69 6e 67 28 6f 62 6a 76  clGetString(objv
2470: 5b 30 5d 29 2c 20 22 20 22 2c 20 54 63 6c 47 65  [0]), " ", TclGe
2480: 74 53 74 72 69 6e 67 28 6f 62 6a 76 5b 31 5d 29  tString(objv[1])
2490: 2c 0a 09 09 22 20 3f 6f 70 74 69 6f 6e 73 3f 20  ,..." ?options? 
24a0: 66 69 6c 65 20 3f 66 69 6c 65 20 2e 2e 2e 3f 5c  file ?file ...?\
24b0: 22 22 2c 20 4e 55 4c 4c 29 3b 0a 09 72 65 74 75  "", NULL);..retu
24c0: 72 6e 20 54 43 4c 5f 45 52 52 4f 52 3b 0a 20 20  rn TCL_ERROR;.  
24d0: 20 20 7d 0a 0a 20 20 20 20 65 72 72 66 69 6c 65    }..    errfile
24e0: 20 3d 20 4e 55 4c 4c 3b 0a 20 20 20 20 72 65 73   = NULL;.    res
24f0: 75 6c 74 20 3d 20 54 43 4c 5f 4f 4b 3b 0a 0a 20  ult = TCL_OK;.. 
2500: 20 20 20 66 6f 72 20 28 20 3b 20 69 20 3c 20 6f     for ( ; i < o
2510: 62 6a 63 3b 20 69 2b 2b 29 20 7b 0a 09 54 63 6c  bjc; i++) {..Tcl
2520: 5f 53 74 61 74 42 75 66 20 73 74 61 74 42 75 66  _StatBuf statBuf
2530: 3b 0a 0a 09 65 72 72 66 69 6c 65 20 3d 20 6f 62  ;...errfile = ob
2540: 6a 76 5b 69 5d 3b 0a 09 69 66 20 28 54 63 6c 5f  jv[i];..if (Tcl_
2550: 46 53 43 6f 6e 76 65 72 74 54 6f 50 61 74 68 54  FSConvertToPathT
2560: 79 70 65 28 69 6e 74 65 72 70 2c 20 6f 62 6a 76  ype(interp, objv
2570: 5b 69 5d 29 20 21 3d 20 54 43 4c 5f 4f 4b 29 20  [i]) != TCL_OK) 
2580: 7b 0a 09 20 20 20 20 72 65 73 75 6c 74 20 3d 20  {..    result = 
2590: 54 43 4c 5f 45 52 52 4f 52 3b 0a 09 20 20 20 20  TCL_ERROR;..    
25a0: 67 6f 74 6f 20 64 6f 6e 65 3b 0a 09 7d 0a 0a 09  goto done;..}...
25b0: 2f 2a 0a 09 20 2a 20 43 61 6c 6c 20 6c 73 74 61  /*.. * Call lsta
25c0: 74 28 29 20 74 6f 20 67 65 74 20 69 6e 66 6f 20  t() to get info 
25d0: 73 6f 20 63 61 6e 20 64 65 6c 65 74 65 20 73 79  so can delete sy
25e0: 6d 62 6f 6c 69 63 20 6c 69 6e 6b 20 69 74 73 65  mbolic link itse
25f0: 6c 66 2e 0a 09 20 2a 2f 0a 0a 09 69 66 20 28 54  lf... */...if (T
2600: 63 6c 5f 46 53 4c 73 74 61 74 28 6f 62 6a 76 5b  cl_FSLstat(objv[
2610: 69 5d 2c 20 26 73 74 61 74 42 75 66 29 20 21 3d  i], &statBuf) !=
2620: 20 30 29 20 7b 0a 09 20 20 20 20 72 65 73 75 6c   0) {..    resul
2630: 74 20 3d 20 54 43 4c 5f 45 52 52 4f 52 3b 0a 09  t = TCL_ERROR;..
2640: 7d 20 65 6c 73 65 20 69 66 20 28 53 5f 49 53 44  } else if (S_ISD
2650: 49 52 28 73 74 61 74 42 75 66 2e 73 74 5f 6d 6f  IR(statBuf.st_mo
2660: 64 65 29 29 20 7b 0a 09 20 20 20 20 2f 2a 0a 09  de)) {..    /*..
2670: 20 20 20 20 20 2a 20 57 65 20 6f 77 6e 20 61 20       * We own a 
2680: 72 65 66 65 72 65 6e 63 65 20 63 6f 75 6e 74 20  reference count 
2690: 6f 6e 20 65 72 72 6f 72 42 75 66 66 65 72 2c 20  on errorBuffer, 
26a0: 69 66 20 69 74 20 77 61 73 20 73 65 74 20 61 73  if it was set as
26b0: 20 61 0a 09 20 20 20 20 20 2a 20 72 65 73 75 6c   a..     * resul
26c0: 74 20 6f 66 20 74 68 69 73 20 63 61 6c 6c 2e 0a  t of this call..
26d0: 09 20 20 20 20 20 2a 2f 0a 0a 09 20 20 20 20 72  .     */...    r
26e0: 65 73 75 6c 74 20 3d 20 54 63 6c 5f 46 53 52 65  esult = Tcl_FSRe
26f0: 6d 6f 76 65 44 69 72 65 63 74 6f 72 79 28 6f 62  moveDirectory(ob
2700: 6a 76 5b 69 5d 2c 20 66 6f 72 63 65 2c 20 26 65  jv[i], force, &e
2710: 72 72 6f 72 42 75 66 66 65 72 29 3b 0a 09 20 20  rrorBuffer);..  
2720: 20 20 69 66 20 28 72 65 73 75 6c 74 20 21 3d 20    if (result != 
2730: 54 43 4c 5f 4f 4b 29 20 7b 0a 09 09 69 66 20 28  TCL_OK) {...if (
2740: 28 66 6f 72 63 65 20 3d 3d 20 30 29 20 26 26 20  (force == 0) && 
2750: 28 65 72 72 6e 6f 20 3d 3d 20 45 45 58 49 53 54  (errno == EEXIST
2760: 29 29 20 7b 0a 09 09 20 20 20 20 54 63 6c 5f 41  )) {...    Tcl_A
2770: 70 70 65 6e 64 52 65 73 75 6c 74 28 69 6e 74 65  ppendResult(inte
2780: 72 70 2c 20 22 65 72 72 6f 72 20 64 65 6c 65 74  rp, "error delet
2790: 69 6e 67 20 5c 22 22 2c 0a 09 09 09 20 20 20 20  ing \"",....    
27a0: 54 63 6c 47 65 74 53 74 72 69 6e 67 28 6f 62 6a  TclGetString(obj
27b0: 76 5b 69 5d 29 2c 20 22 5c 22 3a 20 64 69 72 65  v[i]), "\": dire
27c0: 63 74 6f 72 79 20 6e 6f 74 20 65 6d 70 74 79 22  ctory not empty"
27d0: 2c 0a 09 09 09 20 20 20 20 4e 55 4c 4c 29 3b 0a  ,....    NULL);.
27e0: 09 09 20 20 20 20 54 63 6c 5f 50 6f 73 69 78 45  ..    Tcl_PosixE
27f0: 72 72 6f 72 28 69 6e 74 65 72 70 29 3b 0a 09 09  rror(interp);...
2800: 20 20 20 20 67 6f 74 6f 20 64 6f 6e 65 3b 0a 09      goto done;..
2810: 09 7d 0a 0a 09 09 2f 2a 0a 09 09 20 2a 20 49 66  .}..../*... * If
2820: 20 70 6f 73 73 69 62 6c 65 2c 20 75 73 65 20 74   possible, use t
2830: 68 65 20 75 6e 74 72 61 6e 73 6c 61 74 65 64 20  he untranslated 
2840: 6e 61 6d 65 20 66 6f 72 20 74 68 65 20 66 69 6c  name for the fil
2850: 65 2e 0a 09 09 20 2a 2f 0a 0a 09 09 65 72 72 66  e.... */....errf
2860: 69 6c 65 20 3d 20 65 72 72 6f 72 42 75 66 66 65  ile = errorBuffe
2870: 72 3b 0a 0a 09 09 2f 2a 0a 09 09 20 2a 20 46 53  r;..../*... * FS
2880: 20 73 75 70 70 6f 73 65 64 20 74 6f 20 63 68 65   supposed to che
2890: 63 6b 20 62 65 74 77 65 65 6e 20 74 72 61 6e 73  ck between trans
28a0: 6c 61 74 65 64 20 6f 62 6a 76 20 61 6e 64 20 65  lated objv and e
28b0: 72 72 66 69 6c 65 2e 0a 09 09 20 2a 2f 0a 0a 09  rrfile.... */...
28c0: 09 69 66 20 28 54 63 6c 5f 46 53 45 71 75 61 6c  .if (Tcl_FSEqual
28d0: 50 61 74 68 73 28 6f 62 6a 76 5b 69 5d 2c 20 65  Paths(objv[i], e
28e0: 72 72 66 69 6c 65 29 29 20 7b 0a 09 09 20 20 20  rrfile)) {...   
28f0: 20 65 72 72 66 69 6c 65 20 3d 20 6f 62 6a 76 5b   errfile = objv[
2900: 69 5d 3b 0a 09 09 7d 0a 09 20 20 20 20 7d 0a 09  i];...}..    }..
2910: 7d 20 65 6c 73 65 20 7b 0a 09 20 20 20 20 72 65  } else {..    re
2920: 73 75 6c 74 20 3d 20 54 63 6c 5f 46 53 44 65 6c  sult = Tcl_FSDel
2930: 65 74 65 46 69 6c 65 28 6f 62 6a 76 5b 69 5d 29  eteFile(objv[i])
2940: 3b 0a 09 7d 0a 0a 09 69 66 20 28 72 65 73 75 6c  ;..}...if (resul
2950: 74 20 21 3d 20 54 43 4c 5f 4f 4b 29 20 7b 0a 0a  t != TCL_OK) {..
2960: 09 20 20 20 20 2f 2a 0a 09 20 20 20 20 20 2a 20  .    /*..     * 
2970: 41 76 6f 69 64 20 70 6f 73 73 69 62 6c 65 20 72  Avoid possible r
2980: 61 63 65 20 63 6f 6e 64 69 74 69 6f 6e 20 28 66  ace condition (f
2990: 69 6c 65 2f 64 69 72 65 63 74 6f 72 79 20 64 65  ile/directory de
29a0: 6c 65 74 65 64 20 61 66 74 65 72 20 63 61 6c 6c  leted after call
29b0: 0a 09 20 20 20 20 20 2a 20 6f 66 20 6c 73 74 61  ..     * of lsta
29c0: 74 29 2c 20 73 6f 20 62 79 70 61 73 73 20 45 4e  t), so bypass EN
29d0: 4f 45 4e 54 20 62 65 63 61 75 73 65 20 6e 6f 74  OENT because not
29e0: 20 61 6e 20 65 72 72 6f 72 2c 20 6a 75 73 74 20   an error, just 
29f0: 61 20 6e 6f 2d 6f 70 0a 09 20 20 20 20 20 2a 2f  a no-op..     */
2a00: 0a 09 20 20 20 20 69 66 20 28 65 72 72 6e 6f 20  ..    if (errno 
2a10: 3d 3d 20 45 4e 4f 45 4e 54 29 20 7b 0a 09 09 72  == ENOENT) {...r
2a20: 65 73 75 6c 74 20 3d 20 54 43 4c 5f 4f 4b 3b 0a  esult = TCL_OK;.
2a30: 09 09 63 6f 6e 74 69 6e 75 65 3b 0a 09 20 20 20  ..continue;..   
2a40: 20 7d 0a 09 20 20 20 20 2f 2a 0a 09 20 20 20 20   }..    /*..    
2a50: 20 2a 20 49 74 20 69 73 20 69 6d 70 6f 72 74 61   * It is importa
2a60: 6e 74 20 74 68 61 74 20 77 65 20 62 72 65 61 6b  nt that we break
2a70: 20 6f 6e 20 65 72 72 6f 72 2c 20 6f 74 68 65 72   on error, other
2a80: 77 69 73 65 20 77 65 20 6d 69 67 68 74 20 65 6e  wise we might en
2a90: 64 0a 09 20 20 20 20 20 2a 20 75 70 20 6f 77 6e  d..     * up own
2aa0: 69 6e 67 20 72 65 66 65 72 65 6e 63 65 20 63 6f  ing reference co
2ab0: 75 6e 74 73 20 6f 6e 20 6e 75 6d 65 72 6f 75 73  unts on numerous
2ac0: 20 65 72 72 6f 72 42 75 66 66 65 72 73 2e 0a 09   errorBuffers...
2ad0: 20 20 20 20 20 2a 2f 0a 09 20 20 20 20 72 65 73       */..    res
2ae0: 75 6c 74 20 3d 20 54 43 4c 5f 45 52 52 4f 52 3b  ult = TCL_ERROR;
2af0: 0a 09 20 20 20 20 62 72 65 61 6b 3b 0a 09 7d 0a  ..    break;..}.
2b00: 20 20 20 20 7d 0a 20 20 20 20 69 66 20 28 72 65      }.    if (re
2b10: 73 75 6c 74 20 21 3d 20 54 43 4c 5f 4f 4b 29 20  sult != TCL_OK) 
2b20: 7b 0a 09 69 66 20 28 65 72 72 66 69 6c 65 20 3d  {..if (errfile =
2b30: 3d 20 4e 55 4c 4c 29 20 7b 0a 09 20 20 20 20 2f  = NULL) {..    /
2b40: 2a 0a 09 20 20 20 20 20 2a 20 57 65 20 74 72 79  *..     * We try
2b50: 20 74 6f 20 61 63 63 6f 6d 6f 64 61 74 65 20 70   to accomodate p
2b60: 6f 6f 72 20 65 72 72 6f 72 20 72 65 73 75 6c 74  oor error result
2b70: 73 20 66 72 6f 6d 20 6f 75 72 20 54 63 6c 5f 46  s from our Tcl_F
2b80: 53 20 63 61 6c 6c 73 2e 0a 09 20 20 20 20 20 2a  S calls...     *
2b90: 2f 0a 0a 09 20 20 20 20 54 63 6c 5f 41 70 70 65  /...    Tcl_Appe
2ba0: 6e 64 52 65 73 75 6c 74 28 69 6e 74 65 72 70 2c  ndResult(interp,
2bb0: 20 22 65 72 72 6f 72 20 64 65 6c 65 74 69 6e 67   "error deleting
2bc0: 20 75 6e 6b 6e 6f 77 6e 20 66 69 6c 65 3a 20 22   unknown file: "
2bd0: 2c 0a 09 09 20 20 20 20 54 63 6c 5f 50 6f 73 69  ,...    Tcl_Posi
2be0: 78 45 72 72 6f 72 28 69 6e 74 65 72 70 29 2c 20  xError(interp), 
2bf0: 4e 55 4c 4c 29 3b 0a 09 7d 20 65 6c 73 65 20 7b  NULL);..} else {
2c00: 0a 09 20 20 20 20 54 63 6c 5f 41 70 70 65 6e 64  ..    Tcl_Append
2c10: 52 65 73 75 6c 74 28 69 6e 74 65 72 70 2c 20 22  Result(interp, "
2c20: 65 72 72 6f 72 20 64 65 6c 65 74 69 6e 67 20 5c  error deleting \
2c30: 22 22 2c 0a 09 09 20 20 20 20 54 63 6c 47 65 74  "",...    TclGet
2c40: 53 74 72 69 6e 67 28 65 72 72 66 69 6c 65 29 2c  String(errfile),
2c50: 20 22 5c 22 3a 20 22 2c 20 54 63 6c 5f 50 6f 73   "\": ", Tcl_Pos
2c60: 69 78 45 72 72 6f 72 28 69 6e 74 65 72 70 29 2c  ixError(interp),
2c70: 0a 09 09 20 20 20 20 4e 55 4c 4c 29 3b 0a 09 7d  ...    NULL);..}
2c80: 0a 20 20 20 20 7d 0a 0a 20 20 64 6f 6e 65 3a 0a  .    }..  done:.
2c90: 20 20 20 20 69 66 20 28 65 72 72 6f 72 42 75 66      if (errorBuf
2ca0: 66 65 72 20 21 3d 20 4e 55 4c 4c 29 20 7b 0a 09  fer != NULL) {..
2cb0: 54 63 6c 5f 44 65 63 72 52 65 66 43 6f 75 6e 74  Tcl_DecrRefCount
2cc0: 28 65 72 72 6f 72 42 75 66 66 65 72 29 3b 0a 20  (errorBuffer);. 
2cd0: 20 20 20 7d 0a 20 20 20 20 72 65 74 75 72 6e 20     }.    return 
2ce0: 72 65 73 75 6c 74 3b 0a 7d 0a 0c 0a 2f 2a 0a 20  result;.}.../*. 
2cf0: 2a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  *---------------
2d00: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2d10: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2d20: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2d30: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 20 2a 0a  ------------. *.
2d40: 20 2a 20 43 6f 70 79 52 65 6e 61 6d 65 4f 6e 65   * CopyRenameOne
2d50: 46 69 6c 65 0a 20 2a 0a 20 2a 09 43 6f 70 69 65  File. *. *.Copie
2d60: 73 20 6f 72 20 72 65 6e 61 6d 65 73 20 73 70 65  s or renames spe
2d70: 63 69 66 69 65 64 20 73 6f 75 72 63 65 20 66 69  cified source fi
2d80: 6c 65 20 6f 72 20 64 69 72 65 63 74 6f 72 79 20  le or directory 
2d90: 68 69 65 72 61 72 63 68 79 20 74 6f 20 74 68 65  hierarchy to the
2da0: 0a 20 2a 09 73 70 65 63 69 66 69 65 64 20 74 61  . *.specified ta
2db0: 72 67 65 74 2e 0a 20 2a 0a 20 2a 20 52 65 73 75  rget.. *. * Resu
2dc0: 6c 74 73 3a 0a 20 2a 09 41 20 73 74 61 6e 64 61  lts:. *.A standa
2dd0: 72 64 20 54 63 6c 20 72 65 73 75 6c 74 2e 0a 20  rd Tcl result.. 
2de0: 2a 0a 20 2a 20 53 69 64 65 20 65 66 66 65 63 74  *. * Side effect
2df0: 73 3a 0a 20 2a 09 54 61 72 67 65 74 20 69 73 20  s:. *.Target is 
2e00: 6f 76 65 72 77 72 69 74 74 65 6e 20 69 66 20 74  overwritten if t
2e10: 68 65 20 66 6f 72 63 65 20 66 6c 61 67 20 69 73  he force flag is
2e20: 20 73 65 74 2e 20 41 74 74 65 6d 70 74 69 6e 67   set. Attempting
2e30: 20 74 6f 0a 20 2a 09 63 6f 70 79 2f 72 65 6e 61   to. *.copy/rena
2e40: 6d 65 20 61 20 66 69 6c 65 20 6f 6e 74 6f 20 61  me a file onto a
2e50: 20 64 69 72 65 63 74 6f 72 79 20 6f 72 20 61 20   directory or a 
2e60: 64 69 72 65 63 74 6f 72 79 20 6f 6e 74 6f 20 61  directory onto a
2e70: 20 66 69 6c 65 20 77 69 6c 6c 0a 20 2a 09 61 6c   file will. *.al
2e80: 77 61 79 73 20 72 65 73 75 6c 74 20 69 6e 20 61  ways result in a
2e90: 6e 20 65 72 72 6f 72 2e 0a 20 2a 0a 20 2a 2d 2d  n error.. *. *--
2ea0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2eb0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2ec0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2ed0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2ee0: 2d 2d 2d 2d 0a 20 2a 2f 0a 0a 73 74 61 74 69 63  ----. */..static
2ef0: 20 69 6e 74 0a 43 6f 70 79 52 65 6e 61 6d 65 4f   int.CopyRenameO
2f00: 6e 65 46 69 6c 65 28 0a 20 20 20 20 54 63 6c 5f  neFile(.    Tcl_
2f10: 49 6e 74 65 72 70 20 2a 69 6e 74 65 72 70 2c 09  Interp *interp,.
2f20: 09 2f 2a 20 55 73 65 64 20 66 6f 72 20 65 72 72  ./* Used for err
2f30: 6f 72 20 72 65 70 6f 72 74 69 6e 67 2e 20 2a 2f  or reporting. */
2f40: 0a 20 20 20 20 54 63 6c 5f 4f 62 6a 20 2a 73 6f  .    Tcl_Obj *so
2f50: 75 72 63 65 2c 09 09 2f 2a 20 50 61 74 68 6e 61  urce,../* Pathna
2f60: 6d 65 20 6f 66 20 66 69 6c 65 20 74 6f 20 63 6f  me of file to co
2f70: 70 79 2e 20 4d 61 79 20 6e 65 65 64 20 74 6f 20  py. May need to 
2f80: 62 65 0a 09 09 09 09 20 2a 20 74 72 61 6e 73 6c  be..... * transl
2f90: 61 74 65 64 2e 20 2a 2f 0a 20 20 20 20 54 63 6c  ated. */.    Tcl
2fa0: 5f 4f 62 6a 20 2a 74 61 72 67 65 74 2c 09 09 2f  _Obj *target,../
2fb0: 2a 20 50 61 74 68 6e 61 6d 65 20 6f 66 20 66 69  * Pathname of fi
2fc0: 6c 65 20 74 6f 20 63 72 65 61 74 65 2f 6f 76 65  le to create/ove
2fd0: 72 77 72 69 74 65 2e 20 4d 61 79 0a 09 09 09 09  rwrite. May.....
2fe0: 20 2a 20 6e 65 65 64 20 74 6f 20 62 65 20 74 72   * need to be tr
2ff0: 61 6e 73 6c 61 74 65 64 2e 20 2a 2f 0a 20 20 20  anslated. */.   
3000: 20 69 6e 74 20 63 6f 70 79 46 6c 61 67 2c 09 09   int copyFlag,..
3010: 2f 2a 20 49 66 20 6e 6f 6e 2d 7a 65 72 6f 2c 20  /* If non-zero, 
3020: 63 6f 70 79 20 66 69 6c 65 73 2e 20 4f 74 68 65  copy files. Othe
3030: 72 77 69 73 65 2c 20 72 65 6e 61 6d 65 0a 09 09  rwise, rename...
3040: 09 09 20 2a 20 74 68 65 6d 2e 20 2a 2f 0a 20 20  .. * them. */.  
3050: 20 20 69 6e 74 20 66 6f 72 63 65 29 09 09 09 2f    int force).../
3060: 2a 20 49 66 20 6e 6f 6e 2d 7a 65 72 6f 2c 20 6f  * If non-zero, o
3070: 76 65 72 77 72 69 74 65 20 74 61 72 67 65 74 20  verwrite target 
3080: 66 69 6c 65 20 69 66 20 69 74 0a 09 09 09 09 20  file if it..... 
3090: 2a 20 65 78 69 73 74 73 2e 20 4f 74 68 65 72 77  * exists. Otherw
30a0: 69 73 65 2c 20 65 72 72 6f 72 20 69 66 20 74 61  ise, error if ta
30b0: 72 67 65 74 20 61 6c 72 65 61 64 79 0a 09 09 09  rget already....
30c0: 09 20 2a 20 65 78 69 73 74 73 2e 20 2a 2f 0a 7b  . * exists. */.{
30d0: 0a 20 20 20 20 69 6e 74 20 72 65 73 75 6c 74 3b  .    int result;
30e0: 0a 20 20 20 20 54 63 6c 5f 4f 62 6a 20 2a 65 72  .    Tcl_Obj *er
30f0: 72 66 69 6c 65 2c 20 2a 65 72 72 6f 72 42 75 66  rfile, *errorBuf
3100: 66 65 72 3b 0a 20 20 20 20 54 63 6c 5f 4f 62 6a  fer;.    Tcl_Obj
3110: 20 2a 61 63 74 75 61 6c 53 6f 75 72 63 65 3d 4e   *actualSource=N
3120: 55 4c 4c 3b 09 2f 2a 20 49 66 20 73 6f 75 72 63  ULL;./* If sourc
3130: 65 20 69 73 20 61 20 6c 69 6e 6b 2c 20 74 68 65  e is a link, the
3140: 6e 20 74 68 69 73 20 69 73 20 74 68 65 20 72 65  n this is the re
3150: 61 6c 0a 09 09 09 09 20 2a 20 66 69 6c 65 2f 64  al..... * file/d
3160: 69 72 65 63 74 6f 72 79 2e 20 2a 2f 0a 20 20 20  irectory. */.   
3170: 20 54 63 6c 5f 53 74 61 74 42 75 66 20 73 6f 75   Tcl_StatBuf sou
3180: 72 63 65 53 74 61 74 42 75 66 2c 20 74 61 72 67  rceStatBuf, targ
3190: 65 74 53 74 61 74 42 75 66 3b 0a 0a 20 20 20 20  etStatBuf;..    
31a0: 69 66 20 28 54 63 6c 5f 46 53 43 6f 6e 76 65 72  if (Tcl_FSConver
31b0: 74 54 6f 50 61 74 68 54 79 70 65 28 69 6e 74 65  tToPathType(inte
31c0: 72 70 2c 20 73 6f 75 72 63 65 29 20 21 3d 20 54  rp, source) != T
31d0: 43 4c 5f 4f 4b 29 20 7b 0a 09 72 65 74 75 72 6e  CL_OK) {..return
31e0: 20 54 43 4c 5f 45 52 52 4f 52 3b 0a 20 20 20 20   TCL_ERROR;.    
31f0: 7d 0a 20 20 20 20 69 66 20 28 54 63 6c 5f 46 53  }.    if (Tcl_FS
3200: 43 6f 6e 76 65 72 74 54 6f 50 61 74 68 54 79 70  ConvertToPathTyp
3210: 65 28 69 6e 74 65 72 70 2c 20 74 61 72 67 65 74  e(interp, target
3220: 29 20 21 3d 20 54 43 4c 5f 4f 4b 29 20 7b 0a 09  ) != TCL_OK) {..
3230: 72 65 74 75 72 6e 20 54 43 4c 5f 45 52 52 4f 52  return TCL_ERROR
3240: 3b 0a 20 20 20 20 7d 0a 0a 20 20 20 20 65 72 72  ;.    }..    err
3250: 66 69 6c 65 20 3d 20 4e 55 4c 4c 3b 0a 20 20 20  file = NULL;.   
3260: 20 65 72 72 6f 72 42 75 66 66 65 72 20 3d 20 4e   errorBuffer = N
3270: 55 4c 4c 3b 0a 20 20 20 20 72 65 73 75 6c 74 20  ULL;.    result 
3280: 3d 20 54 43 4c 5f 45 52 52 4f 52 3b 0a 0a 20 20  = TCL_ERROR;..  
3290: 20 20 2f 2a 0a 20 20 20 20 20 2a 20 57 65 20 77    /*.     * We w
32a0: 61 6e 74 20 74 6f 20 63 6f 70 79 2f 72 65 6e 61  ant to copy/rena
32b0: 6d 65 20 6c 69 6e 6b 73 20 61 6e 64 20 6e 6f 74  me links and not
32c0: 20 74 68 65 20 66 69 6c 65 73 20 74 68 65 79 20   the files they 
32d0: 70 6f 69 6e 74 20 74 6f 2c 20 73 6f 20 77 65 20  point to, so we 
32e0: 75 73 65 0a 20 20 20 20 20 2a 20 6c 73 74 61 74  use.     * lstat
32f0: 28 29 2e 20 49 66 20 74 61 72 67 65 74 20 69 73  (). If target is
3300: 20 61 20 6c 69 6e 6b 2c 20 77 65 20 61 6c 73 6f   a link, we also
3310: 20 77 61 6e 74 20 74 6f 20 72 65 70 6c 61 63 65   want to replace
3320: 20 74 68 65 20 6c 69 6e 6b 20 61 6e 64 20 6e 6f   the link and no
3330: 74 0a 20 20 20 20 20 2a 20 74 68 65 20 66 69 6c  t.     * the fil
3340: 65 20 69 74 20 70 6f 69 6e 74 73 20 74 6f 2c 20  e it points to, 
3350: 73 6f 20 77 65 20 61 6c 73 6f 20 75 73 65 20 6c  so we also use l
3360: 73 74 61 74 28 29 20 6f 6e 20 74 68 65 20 74 61  stat() on the ta
3370: 72 67 65 74 2e 0a 20 20 20 20 20 2a 2f 0a 0a 20  rget..     */.. 
3380: 20 20 20 69 66 20 28 54 63 6c 5f 46 53 4c 73 74     if (Tcl_FSLst
3390: 61 74 28 73 6f 75 72 63 65 2c 20 26 73 6f 75 72  at(source, &sour
33a0: 63 65 53 74 61 74 42 75 66 29 20 21 3d 20 30 29  ceStatBuf) != 0)
33b0: 20 7b 0a 09 65 72 72 66 69 6c 65 20 3d 20 73 6f   {..errfile = so
33c0: 75 72 63 65 3b 0a 09 67 6f 74 6f 20 64 6f 6e 65  urce;..goto done
33d0: 3b 0a 20 20 20 20 7d 0a 20 20 20 20 69 66 20 28  ;.    }.    if (
33e0: 54 63 6c 5f 46 53 4c 73 74 61 74 28 74 61 72 67  Tcl_FSLstat(targ
33f0: 65 74 2c 20 26 74 61 72 67 65 74 53 74 61 74 42  et, &targetStatB
3400: 75 66 29 20 21 3d 20 30 29 20 7b 0a 09 69 66 20  uf) != 0) {..if 
3410: 28 65 72 72 6e 6f 20 21 3d 20 45 4e 4f 45 4e 54  (errno != ENOENT
3420: 29 20 7b 0a 09 20 20 20 20 65 72 72 66 69 6c 65  ) {..    errfile
3430: 20 3d 20 74 61 72 67 65 74 3b 0a 09 20 20 20 20   = target;..    
3440: 67 6f 74 6f 20 64 6f 6e 65 3b 0a 09 7d 0a 20 20  goto done;..}.  
3450: 20 20 7d 20 65 6c 73 65 20 7b 0a 09 69 66 20 28    } else {..if (
3460: 66 6f 72 63 65 20 3d 3d 20 30 29 20 7b 0a 09 20  force == 0) {.. 
3470: 20 20 20 65 72 72 6e 6f 20 3d 20 45 45 58 49 53     errno = EEXIS
3480: 54 3b 0a 09 20 20 20 20 65 72 72 66 69 6c 65 20  T;..    errfile 
3490: 3d 20 74 61 72 67 65 74 3b 0a 09 20 20 20 20 67  = target;..    g
34a0: 6f 74 6f 20 64 6f 6e 65 3b 0a 09 7d 0a 0a 09 2f  oto done;..}.../
34b0: 2a 0a 09 20 2a 20 50 72 65 76 65 6e 74 20 63 6f  *.. * Prevent co
34c0: 70 79 69 6e 67 20 6f 72 20 72 65 6e 61 6d 69 6e  pying or renamin
34d0: 67 20 61 20 66 69 6c 65 20 6f 6e 74 6f 20 69 74  g a file onto it
34e0: 73 65 6c 66 2e 20 4f 6e 20 57 69 6e 64 6f 77 73  self. On Windows
34f0: 20 73 69 6e 63 65 0a 09 20 2a 20 38 2e 35 20 77   since.. * 8.5 w
3500: 65 20 64 6f 20 67 65 74 20 61 6e 20 69 6e 6f 64  e do get an inod
3510: 65 20 6e 75 6d 62 65 72 2c 20 68 6f 77 65 76 65  e number, howeve
3520: 72 20 74 68 65 20 75 6e 73 69 67 6e 65 64 20 73  r the unsigned s
3530: 68 6f 72 74 20 66 69 65 6c 64 20 69 73 0a 09 20  hort field is.. 
3540: 2a 20 69 6e 73 75 66 66 69 63 69 65 6e 74 20 74  * insufficient t
3550: 6f 20 61 63 63 65 70 74 20 74 68 65 20 57 69 6e  o accept the Win
3560: 33 32 20 41 50 49 20 66 69 6c 65 20 69 64 20 73  32 API file id s
3570: 6f 20 69 74 20 69 73 20 74 72 75 6e 63 61 74 65  o it is truncate
3580: 64 20 74 6f 0a 09 20 2a 20 31 36 20 62 69 74 73  d to.. * 16 bits
3590: 20 61 6e 64 20 77 65 20 67 65 74 20 63 6f 6c 6c   and we get coll
35a0: 69 73 69 6f 6e 73 2e 20 53 65 65 20 62 75 67 20  isions. See bug 
35b0: 23 32 30 31 35 37 32 33 2e 0a 09 20 2a 2f 0a 0a  #2015723... */..
35c0: 23 69 66 20 21 64 65 66 69 6e 65 64 28 57 49 4e  #if !defined(WIN
35d0: 33 32 29 20 26 26 20 21 64 65 66 69 6e 65 64 28  32) && !defined(
35e0: 5f 5f 43 59 47 57 49 4e 5f 5f 29 0a 09 69 66 20  __CYGWIN__)..if 
35f0: 28 28 73 6f 75 72 63 65 53 74 61 74 42 75 66 2e  ((sourceStatBuf.
3600: 73 74 5f 69 6e 6f 20 21 3d 20 30 29 20 26 26 20  st_ino != 0) && 
3610: 28 74 61 72 67 65 74 53 74 61 74 42 75 66 2e 73  (targetStatBuf.s
3620: 74 5f 69 6e 6f 20 21 3d 20 30 29 29 20 7b 0a 09  t_ino != 0)) {..
3630: 20 20 20 20 69 66 20 28 28 73 6f 75 72 63 65 53      if ((sourceS
3640: 74 61 74 42 75 66 2e 73 74 5f 69 6e 6f 20 3d 3d  tatBuf.st_ino ==
3650: 20 74 61 72 67 65 74 53 74 61 74 42 75 66 2e 73   targetStatBuf.s
3660: 74 5f 69 6e 6f 29 20 26 26 0a 09 09 20 20 20 20  t_ino) &&...    
3670: 28 73 6f 75 72 63 65 53 74 61 74 42 75 66 2e 73  (sourceStatBuf.s
3680: 74 5f 64 65 76 20 3d 3d 20 74 61 72 67 65 74 53  t_dev == targetS
3690: 74 61 74 42 75 66 2e 73 74 5f 64 65 76 29 29 20  tatBuf.st_dev)) 
36a0: 7b 0a 09 09 72 65 73 75 6c 74 20 3d 20 54 43 4c  {...result = TCL
36b0: 5f 4f 4b 3b 0a 09 09 67 6f 74 6f 20 64 6f 6e 65  _OK;...goto done
36c0: 3b 0a 09 20 20 20 20 7d 0a 09 7d 0a 23 65 6e 64  ;..    }..}.#end
36d0: 69 66 0a 0a 09 2f 2a 0a 09 20 2a 20 50 72 65 76  if.../*.. * Prev
36e0: 65 6e 74 20 63 6f 70 79 69 6e 67 2f 72 65 6e 61  ent copying/rena
36f0: 6d 69 6e 67 20 61 20 66 69 6c 65 20 6f 6e 74 6f  ming a file onto
3700: 20 61 20 64 69 72 65 63 74 6f 72 79 20 61 6e 64   a directory and
3710: 20 76 69 63 65 2d 76 65 72 73 61 2e 0a 09 20 2a   vice-versa... *
3720: 20 54 68 69 73 20 69 73 20 61 20 70 6f 6c 69 63   This is a polic
3730: 79 20 64 65 63 69 73 69 6f 6e 20 62 61 73 65 64  y decision based
3740: 20 6f 6e 20 74 68 65 20 66 61 63 74 20 74 68 61   on the fact tha
3750: 74 20 65 78 69 73 74 69 6e 67 0a 09 20 2a 20 69  t existing.. * i
3760: 6d 70 6c 65 6d 65 6e 74 61 74 69 6f 6e 73 20 6f  mplementations o
3770: 66 20 63 6f 70 79 20 61 6e 64 20 72 65 6e 61 6d  f copy and renam
3780: 65 20 6f 6e 20 61 6c 6c 20 70 6c 61 74 66 6f 72  e on all platfor
3790: 6d 73 20 61 6c 73 6f 20 70 72 65 76 65 6e 74 0a  ms also prevent.
37a0: 09 20 2a 20 74 68 69 73 2e 0a 09 20 2a 2f 0a 0a  . * this... */..
37b0: 09 69 66 20 28 53 5f 49 53 44 49 52 28 73 6f 75  .if (S_ISDIR(sou
37c0: 72 63 65 53 74 61 74 42 75 66 2e 73 74 5f 6d 6f  rceStatBuf.st_mo
37d0: 64 65 29 0a 09 09 26 26 20 21 53 5f 49 53 44 49  de)...&& !S_ISDI
37e0: 52 28 74 61 72 67 65 74 53 74 61 74 42 75 66 2e  R(targetStatBuf.
37f0: 73 74 5f 6d 6f 64 65 29 29 20 7b 0a 09 20 20 20  st_mode)) {..   
3800: 20 65 72 72 6e 6f 20 3d 20 45 49 53 44 49 52 3b   errno = EISDIR;
3810: 0a 09 20 20 20 20 54 63 6c 5f 41 70 70 65 6e 64  ..    Tcl_Append
3820: 52 65 73 75 6c 74 28 69 6e 74 65 72 70 2c 20 22  Result(interp, "
3830: 63 61 6e 27 74 20 6f 76 65 72 77 72 69 74 65 20  can't overwrite 
3840: 66 69 6c 65 20 5c 22 22 2c 0a 09 09 20 20 20 20  file \"",...    
3850: 54 63 6c 47 65 74 53 74 72 69 6e 67 28 74 61 72  TclGetString(tar
3860: 67 65 74 29 2c 20 22 5c 22 20 77 69 74 68 20 64  get), "\" with d
3870: 69 72 65 63 74 6f 72 79 20 5c 22 22 2c 0a 09 09  irectory \"",...
3880: 20 20 20 20 54 63 6c 47 65 74 53 74 72 69 6e 67      TclGetString
3890: 28 73 6f 75 72 63 65 29 2c 20 22 5c 22 22 2c 20  (source), "\"", 
38a0: 4e 55 4c 4c 29 3b 0a 09 20 20 20 20 67 6f 74 6f  NULL);..    goto
38b0: 20 64 6f 6e 65 3b 0a 09 7d 0a 09 69 66 20 28 21   done;..}..if (!
38c0: 53 5f 49 53 44 49 52 28 73 6f 75 72 63 65 53 74  S_ISDIR(sourceSt
38d0: 61 74 42 75 66 2e 73 74 5f 6d 6f 64 65 29 0a 09  atBuf.st_mode)..
38e0: 09 26 26 20 53 5f 49 53 44 49 52 28 74 61 72 67  .&& S_ISDIR(targ
38f0: 65 74 53 74 61 74 42 75 66 2e 73 74 5f 6d 6f 64  etStatBuf.st_mod
3900: 65 29 29 20 7b 0a 09 20 20 20 20 65 72 72 6e 6f  e)) {..    errno
3910: 20 3d 20 45 49 53 44 49 52 3b 0a 09 20 20 20 20   = EISDIR;..    
3920: 54 63 6c 5f 41 70 70 65 6e 64 52 65 73 75 6c 74  Tcl_AppendResult
3930: 28 69 6e 74 65 72 70 2c 20 22 63 61 6e 27 74 20  (interp, "can't 
3940: 6f 76 65 72 77 72 69 74 65 20 64 69 72 65 63 74  overwrite direct
3950: 6f 72 79 20 5c 22 22 2c 0a 09 09 20 20 20 20 54  ory \"",...    T
3960: 63 6c 47 65 74 53 74 72 69 6e 67 28 74 61 72 67  clGetString(targ
3970: 65 74 29 2c 20 22 5c 22 20 77 69 74 68 20 66 69  et), "\" with fi
3980: 6c 65 20 5c 22 22 2c 0a 09 09 20 20 20 20 54 63  le \"",...    Tc
3990: 6c 47 65 74 53 74 72 69 6e 67 28 73 6f 75 72 63  lGetString(sourc
39a0: 65 29 2c 20 22 5c 22 22 2c 20 4e 55 4c 4c 29 3b  e), "\"", NULL);
39b0: 0a 09 20 20 20 20 67 6f 74 6f 20 64 6f 6e 65 3b  ..    goto done;
39c0: 0a 09 7d 0a 0a 09 2f 2a 0a 09 20 2a 20 54 68 65  ..}.../*.. * The
39d0: 20 64 65 73 74 69 6e 61 74 69 6f 6e 20 65 78 69   destination exi
39e0: 73 74 73 2c 20 62 75 74 20 61 70 70 65 61 72 73  sts, but appears
39f0: 20 74 6f 20 62 65 20 6f 6b 20 74 6f 20 6f 76 65   to be ok to ove
3a00: 72 2d 77 72 69 74 65 2c 20 61 6e 64 0a 09 20 2a  r-write, and.. *
3a10: 20 2d 66 6f 72 63 65 20 69 73 20 67 69 76 65 6e   -force is given
3a20: 2e 20 57 65 20 6e 6f 77 20 74 72 79 20 74 6f 20  . We now try to 
3a30: 61 64 6a 75 73 74 20 70 65 72 6d 69 73 73 69 6f  adjust permissio
3a40: 6e 73 20 74 6f 20 65 6e 73 75 72 65 20 74 68 65  ns to ensure the
3a50: 0a 09 20 2a 20 6f 70 65 72 61 74 69 6f 6e 20 73  .. * operation s
3a60: 75 63 63 65 65 64 73 2e 20 49 66 20 77 65 20 63  ucceeds. If we c
3a70: 61 6e 27 74 20 61 64 6a 75 73 74 20 70 65 72 6d  an't adjust perm
3a80: 69 73 73 69 6f 6e 73 2c 20 77 65 27 6c 6c 20 6c  issions, we'll l
3a90: 65 74 20 74 68 65 0a 09 20 2a 20 61 63 74 75 61  et the.. * actua
3aa0: 6c 20 63 6f 70 79 2f 72 65 6e 61 6d 65 20 72 65  l copy/rename re
3ab0: 74 75 72 6e 20 61 6e 20 65 72 72 6f 72 20 6c 61  turn an error la
3ac0: 74 65 72 2e 0a 09 20 2a 2f 0a 0a 09 7b 0a 09 20  ter... */...{.. 
3ad0: 20 20 20 54 63 6c 5f 4f 62 6a 20 2a 70 65 72 6d     Tcl_Obj *perm
3ae0: 3b 0a 09 20 20 20 20 69 6e 74 20 69 6e 64 65 78  ;..    int index
3af0: 3b 0a 0a 09 20 20 20 20 54 63 6c 4e 65 77 4c 69  ;...    TclNewLi
3b00: 74 65 72 61 6c 53 74 72 69 6e 67 4f 62 6a 28 70  teralStringObj(p
3b10: 65 72 6d 2c 20 22 75 2b 77 22 29 3b 0a 09 20 20  erm, "u+w");..  
3b20: 20 20 54 63 6c 5f 49 6e 63 72 52 65 66 43 6f 75    Tcl_IncrRefCou
3b30: 6e 74 28 70 65 72 6d 29 3b 0a 09 20 20 20 20 69  nt(perm);..    i
3b40: 66 20 28 54 63 6c 46 53 46 69 6c 65 41 74 74 72  f (TclFSFileAttr
3b50: 49 6e 64 65 78 28 74 61 72 67 65 74 2c 20 22 2d  Index(target, "-
3b60: 70 65 72 6d 69 73 73 69 6f 6e 73 22 2c 20 26 69  permissions", &i
3b70: 6e 64 65 78 29 20 3d 3d 20 54 43 4c 5f 4f 4b 29  ndex) == TCL_OK)
3b80: 20 7b 0a 09 09 54 63 6c 5f 46 53 46 69 6c 65 41   {...Tcl_FSFileA
3b90: 74 74 72 73 53 65 74 28 4e 55 4c 4c 2c 20 69 6e  ttrsSet(NULL, in
3ba0: 64 65 78 2c 20 74 61 72 67 65 74 2c 20 70 65 72  dex, target, per
3bb0: 6d 29 3b 0a 09 20 20 20 20 7d 0a 09 20 20 20 20  m);..    }..    
3bc0: 54 63 6c 5f 44 65 63 72 52 65 66 43 6f 75 6e 74  Tcl_DecrRefCount
3bd0: 28 70 65 72 6d 29 3b 0a 09 7d 0a 20 20 20 20 7d  (perm);..}.    }
3be0: 0a 0a 20 20 20 20 69 66 20 28 63 6f 70 79 46 6c  ..    if (copyFl
3bf0: 61 67 20 3d 3d 20 30 29 20 7b 0a 09 72 65 73 75  ag == 0) {..resu
3c00: 6c 74 20 3d 20 54 63 6c 5f 46 53 52 65 6e 61 6d  lt = Tcl_FSRenam
3c10: 65 46 69 6c 65 28 73 6f 75 72 63 65 2c 20 74 61  eFile(source, ta
3c20: 72 67 65 74 29 3b 0a 09 69 66 20 28 72 65 73 75  rget);..if (resu
3c30: 6c 74 20 3d 3d 20 54 43 4c 5f 4f 4b 29 20 7b 0a  lt == TCL_OK) {.
3c40: 09 20 20 20 20 67 6f 74 6f 20 64 6f 6e 65 3b 0a  .    goto done;.
3c50: 09 7d 0a 0a 09 69 66 20 28 65 72 72 6e 6f 20 3d  .}...if (errno =
3c60: 3d 20 45 49 4e 56 41 4c 29 20 7b 0a 09 20 20 20  = EINVAL) {..   
3c70: 20 54 63 6c 5f 41 70 70 65 6e 64 52 65 73 75 6c   Tcl_AppendResul
3c80: 74 28 69 6e 74 65 72 70 2c 20 22 65 72 72 6f 72  t(interp, "error
3c90: 20 72 65 6e 61 6d 69 6e 67 20 5c 22 22 2c 0a 09   renaming \"",..
3ca0: 09 20 20 20 20 54 63 6c 47 65 74 53 74 72 69 6e  .    TclGetStrin
3cb0: 67 28 73 6f 75 72 63 65 29 2c 20 22 5c 22 20 74  g(source), "\" t
3cc0: 6f 20 5c 22 22 2c 20 54 63 6c 47 65 74 53 74 72  o \"", TclGetStr
3cd0: 69 6e 67 28 74 61 72 67 65 74 29 2c 0a 09 09 20  ing(target),... 
3ce0: 20 20 20 22 5c 22 3a 20 74 72 79 69 6e 67 20 74     "\": trying t
3cf0: 6f 20 72 65 6e 61 6d 65 20 61 20 76 6f 6c 75 6d  o rename a volum
3d00: 65 20 6f 72 20 22 0a 09 09 20 20 20 20 22 6d 6f  e or "...    "mo
3d10: 76 65 20 61 20 64 69 72 65 63 74 6f 72 79 20 69  ve a directory i
3d20: 6e 74 6f 20 69 74 73 65 6c 66 22 2c 20 4e 55 4c  nto itself", NUL
3d30: 4c 29 3b 0a 09 20 20 20 20 67 6f 74 6f 20 64 6f  L);..    goto do
3d40: 6e 65 3b 0a 09 7d 20 65 6c 73 65 20 69 66 20 28  ne;..} else if (
3d50: 65 72 72 6e 6f 20 21 3d 20 45 58 44 45 56 29 20  errno != EXDEV) 
3d60: 7b 0a 09 20 20 20 20 65 72 72 66 69 6c 65 20 3d  {..    errfile =
3d70: 20 74 61 72 67 65 74 3b 0a 09 20 20 20 20 67 6f   target;..    go
3d80: 74 6f 20 64 6f 6e 65 3b 0a 09 7d 0a 0a 09 2f 2a  to done;..}.../*
3d90: 0a 09 20 2a 20 54 68 65 20 72 65 6e 61 6d 65 20  .. * The rename 
3da0: 66 61 69 6c 65 64 20 62 65 63 61 75 73 65 20 74  failed because t
3db0: 68 65 20 6d 6f 76 65 20 77 61 73 20 61 63 72 6f  he move was acro
3dc0: 73 73 20 66 69 6c 65 20 73 79 73 74 65 6d 73 2e  ss file systems.
3dd0: 20 46 61 6c 6c 0a 09 20 2a 20 74 68 72 6f 75 67   Fall.. * throug
3de0: 68 20 74 6f 20 63 6f 70 79 20 66 69 6c 65 20 61  h to copy file a
3df0: 6e 64 20 74 68 65 6e 20 72 65 6d 6f 76 65 20 6f  nd then remove o
3e00: 72 69 67 69 6e 61 6c 2e 20 4e 6f 74 65 20 74 68  riginal. Note th
3e10: 61 74 20 74 68 65 0a 09 20 2a 20 6c 6f 77 2d 6c  at the.. * low-l
3e20: 65 76 65 6c 20 54 63 6c 5f 46 53 52 65 6e 61 6d  evel Tcl_FSRenam
3e30: 65 46 69 6c 65 50 72 6f 63 20 69 6e 20 74 68 65  eFileProc in the
3e40: 20 66 69 6c 65 73 79 73 74 65 6d 20 69 73 20 61   filesystem is a
3e50: 6c 6c 6f 77 65 64 20 74 6f 0a 09 20 2a 20 69 6d  llowed to.. * im
3e60: 70 6c 65 6d 65 6e 74 20 63 72 6f 73 73 2d 66 69  plement cross-fi
3e70: 6c 65 73 79 73 74 65 6d 20 6d 6f 76 65 73 20 69  lesystem moves i
3e80: 74 73 65 6c 66 2c 20 69 66 20 69 74 20 64 65 73  tself, if it des
3e90: 69 72 65 73 2e 0a 09 20 2a 2f 0a 20 20 20 20 7d  ires... */.    }
3ea0: 0a 0a 20 20 20 20 61 63 74 75 61 6c 53 6f 75 72  ..    actualSour
3eb0: 63 65 20 3d 20 73 6f 75 72 63 65 3b 0a 20 20 20  ce = source;.   
3ec0: 20 54 63 6c 5f 49 6e 63 72 52 65 66 43 6f 75 6e   Tcl_IncrRefCoun
3ed0: 74 28 61 63 74 75 61 6c 53 6f 75 72 63 65 29 3b  t(actualSource);
3ee0: 0a 0a 20 20 20 20 2f 2a 0a 20 20 20 20 20 2a 20  ..    /*.     * 
3ef0: 41 63 74 69 76 61 74 65 20 74 68 65 20 66 6f 6c  Activate the fol
3f00: 6c 6f 77 69 6e 67 20 62 6c 6f 63 6b 20 74 6f 20  lowing block to 
3f10: 63 6f 70 79 20 66 69 6c 65 73 20 69 6e 73 74 65  copy files inste
3f20: 61 64 20 6f 66 20 6c 69 6e 6b 73 2e 20 48 6f 77  ad of links. How
3f30: 65 76 65 72 0a 20 20 20 20 20 2a 20 54 63 6c 27  ever.     * Tcl'
3f40: 73 20 73 65 6d 61 6e 74 69 63 73 20 63 75 72 72  s semantics curr
3f50: 65 6e 74 6c 79 20 73 61 79 20 77 65 20 73 68 6f  ently say we sho
3f60: 75 6c 64 20 63 6f 70 79 20 6c 69 6e 6b 73 2c 20  uld copy links, 
3f70: 73 6f 20 61 6e 79 20 73 75 63 68 20 63 68 61 6e  so any such chan
3f80: 67 65 0a 20 20 20 20 20 2a 20 73 68 6f 75 6c 64  ge.     * should
3f90: 20 62 65 20 74 68 65 20 73 75 62 6a 65 63 74 20   be the subject 
3fa0: 6f 66 20 63 61 72 65 66 75 6c 20 73 74 75 64 79  of careful study
3fb0: 20 6f 6e 20 74 68 65 20 63 6f 6e 73 65 71 75 65   on the conseque
3fc0: 6e 63 65 73 2e 0a 20 20 20 20 20 2a 0a 20 20 20  nces..     *.   
3fd0: 20 20 2a 20 50 65 72 68 61 70 73 20 74 68 65 72    * Perhaps ther
3fe0: 65 20 63 6f 75 6c 64 20 62 65 20 61 6e 20 6f 70  e could be an op
3ff0: 74 69 6f 6e 61 6c 20 66 6c 61 67 20 74 6f 20 27  tional flag to '
4000: 66 69 6c 65 20 63 6f 70 79 27 20 74 6f 20 64 69  file copy' to di
4010: 63 74 61 74 65 20 77 68 69 63 68 0a 20 20 20 20  ctate which.    
4020: 20 2a 20 61 70 70 72 6f 61 63 68 20 74 6f 20 75   * approach to u
4030: 73 65 2c 20 77 69 74 68 20 74 68 65 20 64 65 66  se, with the def
4040: 61 75 6c 74 20 62 65 69 6e 67 20 5f 6e 6f 74 5f  ault being _not_
4050: 20 74 6f 20 68 61 76 65 20 74 68 69 73 20 62 6c   to have this bl
4060: 6f 63 6b 0a 20 20 20 20 20 2a 20 61 63 74 69 76  ock.     * activ
4070: 65 2e 0a 20 20 20 20 20 2a 2f 0a 0a 23 69 66 20  e..     */..#if 
4080: 30 0a 23 69 66 64 65 66 20 53 5f 49 53 4c 4e 4b  0.#ifdef S_ISLNK
4090: 0a 20 20 20 20 69 66 20 28 63 6f 70 79 46 6c 61  .    if (copyFla
40a0: 67 20 26 26 20 53 5f 49 53 4c 4e 4b 28 73 6f 75  g && S_ISLNK(sou
40b0: 72 63 65 53 74 61 74 42 75 66 2e 73 74 5f 6d 6f  rceStatBuf.st_mo
40c0: 64 65 29 29 20 7b 0a 09 2f 2a 0a 09 20 2a 20 57  de)) {../*.. * W
40d0: 65 20 77 61 6e 74 20 74 6f 20 63 6f 70 79 20 66  e want to copy f
40e0: 69 6c 65 73 20 6e 6f 74 20 6c 69 6e 6b 73 2e 20  iles not links. 
40f0: 54 68 65 72 65 66 6f 72 65 20 77 65 20 6d 75 73  Therefore we mus
4100: 74 20 66 6f 6c 6c 6f 77 20 74 68 65 20 6c 69 6e  t follow the lin
4110: 6b 2e 0a 09 20 2a 20 54 68 65 72 65 20 61 72 65  k... * There are
4120: 20 74 77 6f 20 70 75 72 70 6f 73 65 73 20 74 6f   two purposes to
4130: 20 74 68 69 73 20 27 73 74 61 74 27 20 63 61 6c   this 'stat' cal
4140: 6c 20 68 65 72 65 2e 20 46 69 72 73 74 20 77 65  l here. First we
4150: 20 77 61 6e 74 20 74 6f 0a 09 20 2a 20 6b 6e 6f   want to.. * kno
4160: 77 20 69 66 20 74 68 65 20 6c 69 6e 6b 65 64 2d  w if the linked-
4170: 66 69 6c 65 2f 64 69 72 20 61 63 74 75 61 6c 6c  file/dir actuall
4180: 79 20 65 78 69 73 74 73 2c 20 61 6e 64 20 73 65  y exists, and se
4190: 63 6f 6e 64 2c 20 69 6e 20 74 68 65 0a 09 20 2a  cond, in the.. *
41a0: 20 62 6c 6f 63 6b 20 6f 66 20 63 6f 64 65 20 77   block of code w
41b0: 68 69 63 68 20 66 6f 6c 6c 6f 77 73 2c 20 73 6f  hich follows, so
41c0: 6d 65 20 32 30 20 6c 69 6e 65 73 20 64 6f 77 6e  me 20 lines down
41d0: 2c 20 77 65 20 77 61 6e 74 20 74 6f 20 63 68 65  , we want to che
41e0: 63 6b 0a 09 20 2a 20 69 66 20 74 68 65 20 74 68  ck.. * if the th
41f0: 69 6e 67 20 69 73 20 61 20 66 69 6c 65 20 6f 72  ing is a file or
4200: 20 64 69 72 65 63 74 6f 72 79 2e 0a 09 20 2a 2f   directory... */
4210: 0a 0a 09 69 66 20 28 54 63 6c 5f 46 53 53 74 61  ...if (Tcl_FSSta
4220: 74 28 73 6f 75 72 63 65 2c 20 26 73 6f 75 72 63  t(source, &sourc
4230: 65 53 74 61 74 42 75 66 29 20 21 3d 20 30 29 20  eStatBuf) != 0) 
4240: 7b 0a 09 20 20 20 20 2f 2a 0a 09 20 20 20 20 20  {..    /*..     
4250: 2a 20 41 63 74 75 61 6c 20 66 69 6c 65 20 64 6f  * Actual file do
4260: 65 73 6e 27 74 20 65 78 69 73 74 2e 0a 09 20 20  esn't exist...  
4270: 20 20 20 2a 2f 0a 0a 09 20 20 20 20 54 63 6c 5f     */...    Tcl_
4280: 41 70 70 65 6e 64 52 65 73 75 6c 74 28 69 6e 74  AppendResult(int
4290: 65 72 70 2c 20 22 65 72 72 6f 72 20 63 6f 70 79  erp, "error copy
42a0: 69 6e 67 20 5c 22 22 2c 20 54 63 6c 47 65 74 53  ing \"", TclGetS
42b0: 74 72 69 6e 67 28 73 6f 75 72 63 65 29 2c 0a 09  tring(source),..
42c0: 09 20 20 20 20 22 5c 22 3a 20 74 68 65 20 74 61  .    "\": the ta
42d0: 72 67 65 74 20 6f 66 20 74 68 69 73 20 6c 69 6e  rget of this lin
42e0: 6b 20 64 6f 65 73 6e 27 74 20 65 78 69 73 74 22  k doesn't exist"
42f0: 2c 20 4e 55 4c 4c 29 3b 0a 09 20 20 20 20 67 6f  , NULL);..    go
4300: 74 6f 20 64 6f 6e 65 3b 0a 09 7d 20 65 6c 73 65  to done;..} else
4310: 20 7b 0a 09 20 20 20 20 69 6e 74 20 63 6f 75 6e   {..    int coun
4320: 74 65 72 20 3d 20 30 3b 0a 0a 09 20 20 20 20 77  ter = 0;...    w
4330: 68 69 6c 65 20 28 31 29 20 7b 0a 09 09 54 63 6c  hile (1) {...Tcl
4340: 5f 4f 62 6a 20 2a 70 61 74 68 20 3d 20 54 63 6c  _Obj *path = Tcl
4350: 5f 46 53 4c 69 6e 6b 28 61 63 74 75 61 6c 53 6f  _FSLink(actualSo
4360: 75 72 63 65 2c 20 4e 55 4c 4c 2c 20 30 29 3b 0a  urce, NULL, 0);.
4370: 09 09 69 66 20 28 70 61 74 68 20 3d 3d 20 4e 55  ..if (path == NU
4380: 4c 4c 29 20 7b 0a 09 09 20 20 20 20 62 72 65 61  LL) {...    brea
4390: 6b 3b 0a 09 09 7d 0a 0a 09 09 2f 2a 0a 09 09 20  k;...}..../*... 
43a0: 2a 20 4e 6f 77 20 77 65 20 77 61 6e 74 20 74 6f  * Now we want to
43b0: 20 63 68 65 63 6b 20 69 66 20 74 68 69 73 20 69   check if this i
43c0: 73 20 61 20 72 65 6c 61 74 69 76 65 20 70 61 74  s a relative pat
43d0: 68 2c 20 61 6e 64 20 69 66 20 73 6f 2c 0a 09 09  h, and if so,...
43e0: 20 2a 20 74 6f 20 6d 61 6b 65 20 69 74 20 61 62   * to make it ab
43f0: 73 6f 6c 75 74 65 2e 0a 09 09 20 2a 2f 0a 0a 09  solute.... */...
4400: 09 69 66 20 28 54 63 6c 5f 46 53 47 65 74 50 61  .if (Tcl_FSGetPa
4410: 74 68 54 79 70 65 28 70 61 74 68 29 20 3d 3d 20  thType(path) == 
4420: 54 43 4c 5f 50 41 54 48 5f 52 45 4c 41 54 49 56  TCL_PATH_RELATIV
4430: 45 29 20 7b 0a 09 09 20 20 20 20 54 63 6c 5f 4f  E) {...    Tcl_O
4440: 62 6a 20 2a 61 62 73 20 3d 20 54 63 6c 5f 46 53  bj *abs = Tcl_FS
4450: 4a 6f 69 6e 54 6f 50 61 74 68 28 61 63 74 75 61  JoinToPath(actua
4460: 6c 53 6f 75 72 63 65 2c 20 31 2c 20 26 70 61 74  lSource, 1, &pat
4470: 68 29 3b 0a 0a 09 09 20 20 20 20 69 66 20 28 61  h);....    if (a
4480: 62 73 20 3d 3d 20 4e 55 4c 4c 29 20 7b 0a 09 09  bs == NULL) {...
4490: 09 62 72 65 61 6b 3b 0a 09 09 20 20 20 20 7d 0a  .break;...    }.
44a0: 09 09 20 20 20 20 54 63 6c 5f 49 6e 63 72 52 65  ..    Tcl_IncrRe
44b0: 66 43 6f 75 6e 74 28 61 62 73 29 3b 0a 09 09 20  fCount(abs);... 
44c0: 20 20 20 54 63 6c 5f 44 65 63 72 52 65 66 43 6f     Tcl_DecrRefCo
44d0: 75 6e 74 28 70 61 74 68 29 3b 0a 09 09 20 20 20  unt(path);...   
44e0: 20 70 61 74 68 20 3d 20 61 62 73 3b 0a 09 09 7d   path = abs;...}
44f0: 0a 09 09 54 63 6c 5f 44 65 63 72 52 65 66 43 6f  ...Tcl_DecrRefCo
4500: 75 6e 74 28 61 63 74 75 61 6c 53 6f 75 72 63 65  unt(actualSource
4510: 29 3b 0a 09 09 61 63 74 75 61 6c 53 6f 75 72 63  );...actualSourc
4520: 65 20 3d 20 70 61 74 68 3b 0a 09 09 63 6f 75 6e  e = path;...coun
4530: 74 65 72 2b 2b 3b 0a 0a 09 09 2f 2a 0a 09 09 20  ter++;..../*... 
4540: 2a 20 41 72 62 69 74 72 61 72 79 20 6c 69 6d 69  * Arbitrary limi
4550: 74 20 6f 66 20 32 30 20 6c 69 6e 6b 73 20 74 6f  t of 20 links to
4560: 20 66 6f 6c 6c 6f 77 2e 0a 09 09 20 2a 2f 0a 0a   follow.... */..
4570: 09 09 69 66 20 28 63 6f 75 6e 74 65 72 20 3e 20  ..if (counter > 
4580: 32 30 29 20 7b 0a 09 09 20 20 20 20 2f 2a 0a 09  20) {...    /*..
4590: 09 20 20 20 20 20 2a 20 54 6f 6f 20 6d 61 6e 79  .     * Too many
45a0: 20 6c 69 6e 6b 73 2e 0a 09 09 20 20 20 20 20 2a   links....     *
45b0: 2f 0a 0a 09 09 20 20 20 20 54 63 6c 5f 53 65 74  /....    Tcl_Set
45c0: 45 72 72 6e 6f 28 45 4d 4c 49 4e 4b 29 3b 0a 09  Errno(EMLINK);..
45d0: 09 20 20 20 20 65 72 72 66 69 6c 65 20 3d 20 73  .    errfile = s
45e0: 6f 75 72 63 65 3b 0a 09 09 20 20 20 20 67 6f 74  ource;...    got
45f0: 6f 20 64 6f 6e 65 3b 0a 09 09 7d 0a 09 20 20 20  o done;...}..   
4600: 20 7d 0a 09 20 20 20 20 2f 2a 20 4e 6f 77 20 27   }..    /* Now '
4610: 61 63 74 75 61 6c 53 6f 75 72 63 65 27 20 69 73  actualSource' is
4620: 20 74 68 65 20 63 6f 72 72 65 63 74 20 66 69 6c   the correct fil
4630: 65 20 2a 2f 0a 09 7d 0a 20 20 20 20 7d 0a 23 65  e */..}.    }.#e
4640: 6e 64 69 66 20 2f 2a 20 53 5f 49 53 4c 4e 4b 20  ndif /* S_ISLNK 
4650: 2a 2f 0a 23 65 6e 64 69 66 0a 0a 20 20 20 20 69  */.#endif..    i
4660: 66 20 28 53 5f 49 53 44 49 52 28 73 6f 75 72 63  f (S_ISDIR(sourc
4670: 65 53 74 61 74 42 75 66 2e 73 74 5f 6d 6f 64 65  eStatBuf.st_mode
4680: 29 29 20 7b 0a 09 72 65 73 75 6c 74 20 3d 20 54  )) {..result = T
4690: 63 6c 5f 46 53 43 6f 70 79 44 69 72 65 63 74 6f  cl_FSCopyDirecto
46a0: 72 79 28 61 63 74 75 61 6c 53 6f 75 72 63 65 2c  ry(actualSource,
46b0: 20 74 61 72 67 65 74 2c 20 26 65 72 72 6f 72 42   target, &errorB
46c0: 75 66 66 65 72 29 3b 0a 09 69 66 20 28 72 65 73  uffer);..if (res
46d0: 75 6c 74 20 21 3d 20 54 43 4c 5f 4f 4b 29 20 7b  ult != TCL_OK) {
46e0: 0a 09 20 20 20 20 69 66 20 28 65 72 72 6e 6f 20  ..    if (errno 
46f0: 3d 3d 20 45 58 44 45 56 29 20 7b 0a 09 09 2f 2a  == EXDEV) {.../*
4700: 0a 09 09 20 2a 20 54 68 65 20 63 6f 70 79 20 66  ... * The copy f
4710: 61 69 6c 65 64 20 62 65 63 61 75 73 65 20 77 65  ailed because we
4720: 27 72 65 20 74 72 79 69 6e 67 20 74 6f 20 64 6f  're trying to do
4730: 20 61 0a 09 09 20 2a 20 63 72 6f 73 73 2d 66 69   a... * cross-fi
4740: 6c 65 73 79 73 74 65 6d 20 63 6f 70 79 2e 20 57  lesystem copy. W
4750: 65 20 64 6f 20 74 68 69 73 20 74 68 72 6f 75 67  e do this throug
4760: 68 20 6f 75 72 20 54 63 6c 20 6c 69 62 72 61 72  h our Tcl librar
4770: 79 2e 0a 09 09 20 2a 2f 0a 0a 09 09 54 63 6c 5f  y.... */....Tcl_
4780: 4f 62 6a 20 2a 63 6f 70 79 43 6f 6d 6d 61 6e 64  Obj *copyCommand
4790: 2c 20 2a 63 6d 64 4f 62 6a 2c 20 2a 6f 70 4f 62  , *cmdObj, *opOb
47a0: 6a 3b 0a 0a 09 09 54 63 6c 4e 65 77 4f 62 6a 28  j;....TclNewObj(
47b0: 63 6f 70 79 43 6f 6d 6d 61 6e 64 29 3b 0a 09 09  copyCommand);...
47c0: 54 63 6c 4e 65 77 4c 69 74 65 72 61 6c 53 74 72  TclNewLiteralStr
47d0: 69 6e 67 4f 62 6a 28 63 6d 64 4f 62 6a 2c 20 22  ingObj(cmdObj, "
47e0: 3a 3a 74 63 6c 3a 3a 43 6f 70 79 44 69 72 65 63  ::tcl::CopyDirec
47f0: 74 6f 72 79 22 29 3b 0a 09 09 54 63 6c 5f 4c 69  tory");...Tcl_Li
4800: 73 74 4f 62 6a 41 70 70 65 6e 64 45 6c 65 6d 65  stObjAppendEleme
4810: 6e 74 28 69 6e 74 65 72 70 2c 20 63 6f 70 79 43  nt(interp, copyC
4820: 6f 6d 6d 61 6e 64 2c 20 63 6d 64 4f 62 6a 29 3b  ommand, cmdObj);
4830: 0a 09 09 69 66 20 28 63 6f 70 79 46 6c 61 67 29  ...if (copyFlag)
4840: 20 7b 0a 09 09 20 20 20 20 54 63 6c 4e 65 77 4c   {...    TclNewL
4850: 69 74 65 72 61 6c 53 74 72 69 6e 67 4f 62 6a 28  iteralStringObj(
4860: 6f 70 4f 62 6a 2c 20 22 63 6f 70 79 69 6e 67 22  opObj, "copying"
4870: 29 3b 0a 09 09 7d 20 65 6c 73 65 20 7b 0a 09 09  );...} else {...
4880: 20 20 20 20 54 63 6c 4e 65 77 4c 69 74 65 72 61      TclNewLitera
4890: 6c 53 74 72 69 6e 67 4f 62 6a 28 6f 70 4f 62 6a  lStringObj(opObj
48a0: 2c 20 22 72 65 6e 61 6d 69 6e 67 22 29 3b 0a 09  , "renaming");..
48b0: 09 7d 0a 09 09 54 63 6c 5f 4c 69 73 74 4f 62 6a  .}...Tcl_ListObj
48c0: 41 70 70 65 6e 64 45 6c 65 6d 65 6e 74 28 69 6e  AppendElement(in
48d0: 74 65 72 70 2c 20 63 6f 70 79 43 6f 6d 6d 61 6e  terp, copyComman
48e0: 64 2c 20 6f 70 4f 62 6a 29 3b 0a 09 09 54 63 6c  d, opObj);...Tcl
48f0: 5f 4c 69 73 74 4f 62 6a 41 70 70 65 6e 64 45 6c  _ListObjAppendEl
4900: 65 6d 65 6e 74 28 69 6e 74 65 72 70 2c 20 63 6f  ement(interp, co
4910: 70 79 43 6f 6d 6d 61 6e 64 2c 20 73 6f 75 72 63  pyCommand, sourc
4920: 65 29 3b 0a 09 09 54 63 6c 5f 4c 69 73 74 4f 62  e);...Tcl_ListOb
4930: 6a 41 70 70 65 6e 64 45 6c 65 6d 65 6e 74 28 69  jAppendElement(i
4940: 6e 74 65 72 70 2c 20 63 6f 70 79 43 6f 6d 6d 61  nterp, copyComma
4950: 6e 64 2c 20 74 61 72 67 65 74 29 3b 0a 09 09 54  nd, target);...T
4960: 63 6c 5f 49 6e 63 72 52 65 66 43 6f 75 6e 74 28  cl_IncrRefCount(
4970: 63 6f 70 79 43 6f 6d 6d 61 6e 64 29 3b 0a 09 09  copyCommand);...
4980: 72 65 73 75 6c 74 20 3d 20 54 63 6c 5f 45 76 61  result = Tcl_Eva
4990: 6c 4f 62 6a 45 78 28 69 6e 74 65 72 70 2c 20 63  lObjEx(interp, c
49a0: 6f 70 79 43 6f 6d 6d 61 6e 64 2c 0a 09 09 09 54  opyCommand,....T
49b0: 43 4c 5f 45 56 41 4c 5f 47 4c 4f 42 41 4c 20 7c  CL_EVAL_GLOBAL |
49c0: 20 54 43 4c 5f 45 56 41 4c 5f 44 49 52 45 43 54   TCL_EVAL_DIRECT
49d0: 29 3b 0a 09 09 54 63 6c 5f 44 65 63 72 52 65 66  );...Tcl_DecrRef
49e0: 43 6f 75 6e 74 28 63 6f 70 79 43 6f 6d 6d 61 6e  Count(copyComman
49f0: 64 29 3b 0a 09 09 69 66 20 28 72 65 73 75 6c 74  d);...if (result
4a00: 20 21 3d 20 54 43 4c 5f 4f 4b 29 20 7b 0a 09 09   != TCL_OK) {...
4a10: 20 20 20 20 2f 2a 0a 09 09 20 20 20 20 20 2a 20      /*...     * 
4a20: 54 68 65 72 65 20 77 61 73 20 61 6e 20 65 72 72  There was an err
4a30: 6f 72 20 69 6e 20 74 68 65 20 54 63 6c 2d 6c 65  or in the Tcl-le
4a40: 76 65 6c 20 63 6f 70 79 2e 20 57 65 20 77 69 6c  vel copy. We wil
4a50: 6c 20 70 61 73 73 0a 09 09 20 20 20 20 20 2a 20  l pass...     * 
4a60: 6f 6e 20 74 68 65 20 54 63 6c 20 65 72 72 6f 72  on the Tcl error
4a70: 20 6d 65 73 73 61 67 65 20 61 6e 64 20 63 61 6e   message and can
4a80: 20 65 6e 73 75 72 65 20 74 68 69 73 20 62 79 20   ensure this by 
4a90: 73 65 74 74 69 6e 67 0a 09 09 20 20 20 20 20 2a  setting...     *
4aa0: 20 65 72 72 66 69 6c 65 20 74 6f 20 4e 55 4c 4c   errfile to NULL
4ab0: 0a 09 09 20 20 20 20 20 2a 2f 0a 0a 09 09 20 20  ...     */....  
4ac0: 20 20 65 72 72 66 69 6c 65 20 3d 20 4e 55 4c 4c    errfile = NULL
4ad0: 3b 0a 09 09 7d 0a 09 20 20 20 20 7d 20 65 6c 73  ;...}..    } els
4ae0: 65 20 7b 0a 09 09 65 72 72 66 69 6c 65 20 3d 20  e {...errfile = 
4af0: 65 72 72 6f 72 42 75 66 66 65 72 3b 0a 09 09 69  errorBuffer;...i
4b00: 66 20 28 54 63 6c 5f 46 53 45 71 75 61 6c 50 61  f (Tcl_FSEqualPa
4b10: 74 68 73 28 65 72 72 66 69 6c 65 2c 20 73 6f 75  ths(errfile, sou
4b20: 72 63 65 29 29 20 7b 0a 09 09 20 20 20 20 65 72  rce)) {...    er
4b30: 72 66 69 6c 65 20 3d 20 73 6f 75 72 63 65 3b 0a  rfile = source;.
4b40: 09 09 7d 20 65 6c 73 65 20 69 66 20 28 54 63 6c  ..} else if (Tcl
4b50: 5f 46 53 45 71 75 61 6c 50 61 74 68 73 28 65 72  _FSEqualPaths(er
4b60: 72 66 69 6c 65 2c 20 74 61 72 67 65 74 29 29 20  rfile, target)) 
4b70: 7b 0a 09 09 20 20 20 20 65 72 72 66 69 6c 65 20  {...    errfile 
4b80: 3d 20 74 61 72 67 65 74 3b 0a 09 09 7d 0a 09 20  = target;...}.. 
4b90: 20 20 20 7d 0a 09 7d 0a 20 20 20 20 7d 20 65 6c     }..}.    } el
4ba0: 73 65 20 7b 0a 09 72 65 73 75 6c 74 20 3d 20 54  se {..result = T
4bb0: 63 6c 5f 46 53 43 6f 70 79 46 69 6c 65 28 61 63  cl_FSCopyFile(ac
4bc0: 74 75 61 6c 53 6f 75 72 63 65 2c 20 74 61 72 67  tualSource, targ
4bd0: 65 74 29 3b 0a 09 69 66 20 28 28 72 65 73 75 6c  et);..if ((resul
4be0: 74 20 21 3d 20 54 43 4c 5f 4f 4b 29 20 26 26 20  t != TCL_OK) && 
4bf0: 28 65 72 72 6e 6f 20 3d 3d 20 45 58 44 45 56 29  (errno == EXDEV)
4c00: 29 20 7b 0a 09 20 20 20 20 72 65 73 75 6c 74 20  ) {..    result 
4c10: 3d 20 54 63 6c 43 72 6f 73 73 46 69 6c 65 73 79  = TclCrossFilesy
4c20: 73 74 65 6d 43 6f 70 79 28 69 6e 74 65 72 70 2c  stemCopy(interp,
4c30: 20 73 6f 75 72 63 65 2c 20 74 61 72 67 65 74 29   source, target)
4c40: 3b 0a 09 7d 0a 09 69 66 20 28 72 65 73 75 6c 74  ;..}..if (result
4c50: 20 21 3d 20 54 43 4c 5f 4f 4b 29 20 7b 0a 09 20   != TCL_OK) {.. 
4c60: 20 20 20 2f 2a 0a 09 20 20 20 20 20 2a 20 57 65     /*..     * We
4c70: 20 63 6f 75 6c 64 20 65 78 61 6d 69 6e 65 20 27   could examine '
4c80: 65 72 72 6e 6f 27 20 74 6f 20 64 6f 75 62 6c 65  errno' to double
4c90: 2d 63 68 65 63 6b 20 69 66 20 74 68 65 20 70 72  -check if the pr
4ca0: 6f 62 6c 65 6d 20 77 61 73 0a 09 20 20 20 20 20  oblem was..     
4cb0: 2a 20 77 69 74 68 20 74 68 65 20 74 61 72 67 65  * with the targe
4cc0: 74 2c 20 62 75 74 20 77 65 20 63 68 65 63 6b 65  t, but we checke
4cd0: 64 20 74 68 65 20 73 6f 75 72 63 65 20 61 62 6f  d the source abo
4ce0: 76 65 2c 20 73 6f 20 69 74 20 73 68 6f 75 6c 64  ve, so it should
4cf0: 0a 09 20 20 20 20 20 2a 20 62 65 20 71 75 69 74  ..     * be quit
4d00: 65 20 63 6c 65 61 72 0a 09 20 20 20 20 20 2a 2f  e clear..     */
4d10: 0a 0a 09 20 20 20 20 65 72 72 66 69 6c 65 20 3d  ...    errfile =
4d20: 20 74 61 72 67 65 74 3b 0a 09 7d 0a 09 2f 2a 0a   target;..}../*.
4d30: 09 20 2a 20 57 65 20 6e 6f 77 20 6e 65 65 64 20  . * We now need 
4d40: 74 6f 20 72 65 73 65 74 20 74 68 65 20 72 65 73  to reset the res
4d50: 75 6c 74 2c 20 62 65 63 61 75 73 65 20 74 68 65  ult, because the
4d60: 20 61 62 6f 76 65 20 63 61 6c 6c 2c 0a 09 20 2a   above call,.. *
4d70: 20 6d 61 79 20 68 61 76 65 20 6c 65 66 74 20 73   may have left s
4d80: 65 74 20 69 74 2e 20 20 28 49 64 65 61 6c 6c 79  et it.  (Ideally
4d90: 20 77 65 20 77 6f 75 6c 64 20 70 72 65 66 65 72   we would prefer
4da0: 20 6e 6f 74 20 74 6f 20 70 61 73 73 0a 09 20 2a   not to pass.. *
4db0: 20 61 6e 20 69 6e 74 65 72 70 72 65 74 65 72 20   an interpreter 
4dc0: 69 6e 20 61 62 6f 76 65 2c 20 62 75 74 20 74 68  in above, but th
4dd0: 65 20 63 68 61 6e 6e 65 6c 20 49 4f 20 63 6f 64  e channel IO cod
4de0: 65 20 75 73 65 64 20 62 79 0a 09 20 2a 20 54 63  e used by.. * Tc
4df0: 6c 43 72 6f 73 73 46 69 6c 65 73 79 73 74 65 6d  lCrossFilesystem
4e00: 43 6f 70 79 20 63 75 72 72 65 6e 74 6c 79 20 72  Copy currently r
4e10: 65 71 75 69 72 65 73 20 6f 6e 65 29 0a 09 20 2a  equires one).. *
4e20: 2f 0a 09 54 63 6c 5f 52 65 73 65 74 52 65 73 75  /..Tcl_ResetResu
4e30: 6c 74 28 69 6e 74 65 72 70 29 3b 0a 20 20 20 20  lt(interp);.    
4e40: 7d 0a 20 20 20 20 69 66 20 28 28 63 6f 70 79 46  }.    if ((copyF
4e50: 6c 61 67 20 3d 3d 20 30 29 20 26 26 20 28 72 65  lag == 0) && (re
4e60: 73 75 6c 74 20 3d 3d 20 54 43 4c 5f 4f 4b 29 29  sult == TCL_OK))
4e70: 20 7b 0a 09 69 66 20 28 53 5f 49 53 44 49 52 28   {..if (S_ISDIR(
4e80: 73 6f 75 72 63 65 53 74 61 74 42 75 66 2e 73 74  sourceStatBuf.st
4e90: 5f 6d 6f 64 65 29 29 20 7b 0a 09 20 20 20 20 72  _mode)) {..    r
4ea0: 65 73 75 6c 74 20 3d 20 54 63 6c 5f 46 53 52 65  esult = Tcl_FSRe
4eb0: 6d 6f 76 65 44 69 72 65 63 74 6f 72 79 28 73 6f  moveDirectory(so
4ec0: 75 72 63 65 2c 20 31 2c 20 26 65 72 72 6f 72 42  urce, 1, &errorB
4ed0: 75 66 66 65 72 29 3b 0a 09 20 20 20 20 69 66 20  uffer);..    if 
4ee0: 28 72 65 73 75 6c 74 20 21 3d 20 54 43 4c 5f 4f  (result != TCL_O
4ef0: 4b 29 20 7b 0a 09 09 69 66 20 28 54 63 6c 5f 46  K) {...if (Tcl_F
4f00: 53 45 71 75 61 6c 50 61 74 68 73 28 65 72 72 66  SEqualPaths(errf
4f10: 69 6c 65 2c 20 73 6f 75 72 63 65 29 20 3d 3d 20  ile, source) == 
4f20: 30 29 20 7b 0a 09 09 20 20 20 20 65 72 72 66 69  0) {...    errfi
4f30: 6c 65 20 3d 20 73 6f 75 72 63 65 3b 0a 09 09 7d  le = source;...}
4f40: 0a 09 20 20 20 20 7d 0a 09 7d 20 65 6c 73 65 20  ..    }..} else 
4f50: 7b 0a 09 20 20 20 20 72 65 73 75 6c 74 20 3d 20  {..    result = 
4f60: 54 63 6c 5f 46 53 44 65 6c 65 74 65 46 69 6c 65  Tcl_FSDeleteFile
4f70: 28 73 6f 75 72 63 65 29 3b 0a 09 20 20 20 20 69  (source);..    i
4f80: 66 20 28 72 65 73 75 6c 74 20 21 3d 20 54 43 4c  f (result != TCL
4f90: 5f 4f 4b 29 20 7b 0a 09 09 65 72 72 66 69 6c 65  _OK) {...errfile
4fa0: 20 3d 20 73 6f 75 72 63 65 3b 0a 09 20 20 20 20   = source;..    
4fb0: 7d 0a 09 7d 0a 09 69 66 20 28 72 65 73 75 6c 74  }..}..if (result
4fc0: 20 21 3d 20 54 43 4c 5f 4f 4b 29 20 7b 0a 09 20   != TCL_OK) {.. 
4fd0: 20 20 20 54 63 6c 5f 41 70 70 65 6e 64 52 65 73     Tcl_AppendRes
4fe0: 75 6c 74 28 69 6e 74 65 72 70 2c 20 22 63 61 6e  ult(interp, "can
4ff0: 27 74 20 75 6e 6c 69 6e 6b 20 5c 22 22 2c 20 54  't unlink \"", T
5000: 63 6c 47 65 74 53 74 72 69 6e 67 28 65 72 72 66  clGetString(errf
5010: 69 6c 65 29 2c 0a 09 09 20 20 20 20 22 5c 22 3a  ile),...    "\":
5020: 20 22 2c 20 54 63 6c 5f 50 6f 73 69 78 45 72 72   ", Tcl_PosixErr
5030: 6f 72 28 69 6e 74 65 72 70 29 2c 20 4e 55 4c 4c  or(interp), NULL
5040: 29 3b 0a 09 20 20 20 20 65 72 72 66 69 6c 65 20  );..    errfile 
5050: 3d 20 4e 55 4c 4c 3b 0a 09 7d 0a 20 20 20 20 7d  = NULL;..}.    }
5060: 0a 0a 20 20 64 6f 6e 65 3a 0a 20 20 20 20 69 66  ..  done:.    if
5070: 20 28 65 72 72 66 69 6c 65 20 21 3d 20 4e 55 4c   (errfile != NUL
5080: 4c 29 20 7b 0a 09 54 63 6c 5f 41 70 70 65 6e 64  L) {..Tcl_Append
5090: 52 65 73 75 6c 74 28 69 6e 74 65 72 70 2c 20 22  Result(interp, "
50a0: 65 72 72 6f 72 20 22 2c 20 28 63 6f 70 79 46 6c  error ", (copyFl
50b0: 61 67 20 3f 20 22 63 6f 70 79 69 6e 67 22 20 3a  ag ? "copying" :
50c0: 20 22 72 65 6e 61 6d 69 6e 67 22 29 2c 0a 09 09   "renaming"),...
50d0: 20 22 20 5c 22 22 2c 20 54 63 6c 47 65 74 53 74   " \"", TclGetSt
50e0: 72 69 6e 67 28 73 6f 75 72 63 65 29 2c 20 4e 55  ring(source), NU
50f0: 4c 4c 29 3b 0a 09 69 66 20 28 65 72 72 66 69 6c  LL);..if (errfil
5100: 65 20 21 3d 20 73 6f 75 72 63 65 29 20 7b 0a 09  e != source) {..
5110: 20 20 20 20 54 63 6c 5f 41 70 70 65 6e 64 52 65      Tcl_AppendRe
5120: 73 75 6c 74 28 69 6e 74 65 72 70 2c 20 22 5c 22  sult(interp, "\"
5130: 20 74 6f 20 5c 22 22 2c 20 54 63 6c 47 65 74 53   to \"", TclGetS
5140: 74 72 69 6e 67 28 74 61 72 67 65 74 29 2c 20 4e  tring(target), N
5150: 55 4c 4c 29 3b 0a 09 20 20 20 20 69 66 20 28 65  ULL);..    if (e
5160: 72 72 66 69 6c 65 20 21 3d 20 74 61 72 67 65 74  rrfile != target
5170: 29 20 7b 0a 09 09 54 63 6c 5f 41 70 70 65 6e 64  ) {...Tcl_Append
5180: 52 65 73 75 6c 74 28 69 6e 74 65 72 70 2c 20 22  Result(interp, "
5190: 5c 22 3a 20 5c 22 22 2c 20 54 63 6c 47 65 74 53  \": \"", TclGetS
51a0: 74 72 69 6e 67 28 65 72 72 66 69 6c 65 29 2c 4e  tring(errfile),N
51b0: 55 4c 4c 29 3b 0a 09 20 20 20 20 7d 0a 09 7d 0a  ULL);..    }..}.
51c0: 09 54 63 6c 5f 41 70 70 65 6e 64 52 65 73 75 6c  .Tcl_AppendResul
51d0: 74 28 69 6e 74 65 72 70 2c 20 22 5c 22 3a 20 22  t(interp, "\": "
51e0: 2c 20 54 63 6c 5f 50 6f 73 69 78 45 72 72 6f 72  , Tcl_PosixError
51f0: 28 69 6e 74 65 72 70 29 2c 20 4e 55 4c 4c 29 3b  (interp), NULL);
5200: 0a 20 20 20 20 7d 0a 20 20 20 20 69 66 20 28 65  .    }.    if (e
5210: 72 72 6f 72 42 75 66 66 65 72 20 21 3d 20 4e 55  rrorBuffer != NU
5220: 4c 4c 29 20 7b 0a 09 54 63 6c 5f 44 65 63 72 52  LL) {..Tcl_DecrR
5230: 65 66 43 6f 75 6e 74 28 65 72 72 6f 72 42 75 66  efCount(errorBuf
5240: 66 65 72 29 3b 0a 20 20 20 20 7d 0a 20 20 20 20  fer);.    }.    
5250: 69 66 20 28 61 63 74 75 61 6c 53 6f 75 72 63 65  if (actualSource
5260: 20 21 3d 20 4e 55 4c 4c 29 20 7b 0a 09 54 63 6c   != NULL) {..Tcl
5270: 5f 44 65 63 72 52 65 66 43 6f 75 6e 74 28 61 63  _DecrRefCount(ac
5280: 74 75 61 6c 53 6f 75 72 63 65 29 3b 0a 20 20 20  tualSource);.   
5290: 20 7d 0a 20 20 20 20 72 65 74 75 72 6e 20 72 65   }.    return re
52a0: 73 75 6c 74 3b 0a 7d 0a 0c 0a 2f 2a 0a 20 2a 2d  sult;.}.../*. *-
52b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
52c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
52d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
52e0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
52f0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 20 2a 0a 20 2a  ----------. *. *
5300: 20 46 69 6c 65 46 6f 72 63 65 4f 70 74 69 6f 6e   FileForceOption
5310: 20 2d 2d 0a 20 2a 0a 20 2a 09 48 65 6c 70 73 20   --. *. *.Helps 
5320: 70 61 72 73 65 20 63 6f 6d 6d 61 6e 64 20 6c 69  parse command li
5330: 6e 65 20 6f 70 74 69 6f 6e 73 20 66 6f 72 20 66  ne options for f
5340: 69 6c 65 20 63 6f 6d 6d 61 6e 64 73 20 74 68 61  ile commands tha
5350: 74 20 74 61 6b 65 20 74 68 65 0a 20 2a 09 22 2d  t take the. *."-
5360: 66 6f 72 63 65 22 20 61 6e 64 20 22 2d 2d 22 20  force" and "--" 
5370: 6f 70 74 69 6f 6e 73 2e 0a 20 2a 0a 20 2a 20 52  options.. *. * R
5380: 65 73 75 6c 74 73 3a 0a 20 2a 09 54 68 65 20 72  esults:. *.The r
5390: 65 74 75 72 6e 20 76 61 6c 75 65 20 69 73 20 68  eturn value is h
53a0: 6f 77 20 6d 61 6e 79 20 61 72 67 75 6d 65 6e 74  ow many argument
53b0: 73 20 66 72 6f 6d 20 61 72 67 76 20 77 65 72 65  s from argv were
53c0: 20 63 6f 6e 73 75 6d 65 64 20 62 79 20 74 68 69   consumed by thi
53d0: 73 0a 20 2a 09 66 75 6e 63 74 69 6f 6e 2c 20 6f  s. *.function, o
53e0: 72 20 2d 31 20 69 66 20 74 68 65 72 65 20 77 61  r -1 if there wa
53f0: 73 20 61 6e 20 65 72 72 6f 72 20 70 61 72 73 69  s an error parsi
5400: 6e 67 20 74 68 65 20 6f 70 74 69 6f 6e 73 2e 20  ng the options. 
5410: 49 66 20 61 6e 20 65 72 72 6f 72 0a 20 2a 09 6f  If an error. *.o
5420: 63 63 75 72 72 65 64 2c 20 61 6e 20 65 72 72 6f  ccurred, an erro
5430: 72 20 6d 65 73 73 61 67 65 20 69 73 20 6c 65 66  r message is lef
5440: 74 20 69 6e 20 74 68 65 20 69 6e 74 65 72 70 27  t in the interp'
5450: 73 20 72 65 73 75 6c 74 2e 0a 20 2a 0a 20 2a 20  s result.. *. * 
5460: 53 69 64 65 20 65 66 66 65 63 74 73 3a 0a 20 2a  Side effects:. *
5470: 09 4e 6f 6e 65 2e 0a 20 2a 0a 20 2a 2d 2d 2d 2d  .None.. *. *----
5480: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
5490: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
54a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
54b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
54c0: 2d 2d 2d 2d 2d 2d 2d 0a 20 2a 2f 0a 0a 73 74 61  -------. */..sta
54d0: 74 69 63 20 69 6e 74 0a 46 69 6c 65 46 6f 72 63  tic int.FileForc
54e0: 65 4f 70 74 69 6f 6e 28 0a 20 20 20 20 54 63 6c  eOption(.    Tcl
54f0: 5f 49 6e 74 65 72 70 20 2a 69 6e 74 65 72 70 2c  _Interp *interp,
5500: 09 09 2f 2a 20 49 6e 74 65 72 70 2c 20 66 6f 72  ../* Interp, for
5510: 20 65 72 72 6f 72 20 72 65 74 75 72 6e 2e 20 2a   error return. *
5520: 2f 0a 20 20 20 20 69 6e 74 20 6f 62 6a 63 2c 09  /.    int objc,.
5530: 09 09 2f 2a 20 4e 75 6d 62 65 72 20 6f 66 20 61  ../* Number of a
5540: 72 67 75 6d 65 6e 74 73 2e 20 2a 2f 0a 20 20 20  rguments. */.   
5550: 20 54 63 6c 5f 4f 62 6a 20 2a 43 4f 4e 53 54 20   Tcl_Obj *CONST 
5560: 6f 62 6a 76 5b 5d 2c 09 2f 2a 20 41 72 67 75 6d  objv[],./* Argum
5570: 65 6e 74 20 73 74 72 69 6e 67 73 2e 20 20 46 69  ent strings.  Fi
5580: 72 73 74 20 63 6f 6d 6d 61 6e 64 20 6c 69 6e 65  rst command line
5590: 0a 09 09 09 09 20 2a 20 6f 70 74 69 6f 6e 2c 20  ..... * option, 
55a0: 69 66 20 69 74 20 65 78 69 73 74 73 2c 20 62 65  if it exists, be
55b0: 67 69 6e 73 20 61 74 20 30 2e 20 2a 2f 0a 20 20  gins at 0. */.  
55c0: 20 20 69 6e 74 20 2a 66 6f 72 63 65 50 74 72 29    int *forcePtr)
55d0: 09 09 2f 2a 20 49 66 20 74 68 65 20 22 2d 66 6f  ../* If the "-fo
55e0: 72 63 65 22 20 77 61 73 20 73 70 65 63 69 66 69  rce" was specifi
55f0: 65 64 2c 20 2a 66 6f 72 63 65 50 74 72 20 69 73  ed, *forcePtr is
5600: 0a 09 09 09 09 20 2a 20 66 69 6c 6c 65 64 20 77  ..... * filled w
5610: 69 74 68 20 31 2c 20 6f 74 68 65 72 77 69 73 65  ith 1, otherwise
5620: 20 77 69 74 68 20 30 2e 20 2a 2f 0a 7b 0a 20 20   with 0. */.{.  
5630: 20 20 69 6e 74 20 66 6f 72 63 65 2c 20 69 3b 0a    int force, i;.
5640: 0a 20 20 20 20 66 6f 72 63 65 20 3d 20 30 3b 0a  .    force = 0;.
5650: 20 20 20 20 66 6f 72 20 28 69 20 3d 20 30 3b 20      for (i = 0; 
5660: 69 20 3c 20 6f 62 6a 63 3b 20 69 2b 2b 29 20 7b  i < objc; i++) {
5670: 0a 09 69 66 20 28 54 63 6c 47 65 74 53 74 72 69  ..if (TclGetStri
5680: 6e 67 28 6f 62 6a 76 5b 69 5d 29 5b 30 5d 20 21  ng(objv[i])[0] !
5690: 3d 20 27 2d 27 29 20 7b 0a 09 20 20 20 20 62 72  = '-') {..    br
56a0: 65 61 6b 3b 0a 09 7d 0a 09 69 66 20 28 73 74 72  eak;..}..if (str
56b0: 63 6d 70 28 54 63 6c 47 65 74 53 74 72 69 6e 67  cmp(TclGetString
56c0: 28 6f 62 6a 76 5b 69 5d 29 2c 20 22 2d 66 6f 72  (objv[i]), "-for
56d0: 63 65 22 29 20 3d 3d 20 30 29 20 7b 0a 09 20 20  ce") == 0) {..  
56e0: 20 20 66 6f 72 63 65 20 3d 20 31 3b 0a 09 7d 20    force = 1;..} 
56f0: 65 6c 73 65 20 69 66 20 28 73 74 72 63 6d 70 28  else if (strcmp(
5700: 54 63 6c 47 65 74 53 74 72 69 6e 67 28 6f 62 6a  TclGetString(obj
5710: 76 5b 69 5d 29 2c 20 22 2d 2d 22 29 20 3d 3d 20  v[i]), "--") == 
5720: 30 29 20 7b 0a 09 20 20 20 20 69 2b 2b 3b 0a 09  0) {..    i++;..
5730: 20 20 20 20 62 72 65 61 6b 3b 0a 09 7d 20 65 6c      break;..} el
5740: 73 65 20 7b 0a 09 20 20 20 20 54 63 6c 5f 41 70  se {..    Tcl_Ap
5750: 70 65 6e 64 52 65 73 75 6c 74 28 69 6e 74 65 72  pendResult(inter
5760: 70 2c 20 22 62 61 64 20 6f 70 74 69 6f 6e 20 5c  p, "bad option \
5770: 22 22 2c 20 54 63 6c 47 65 74 53 74 72 69 6e 67  "", TclGetString
5780: 28 6f 62 6a 76 5b 69 5d 29 2c 0a 09 09 20 20 20  (objv[i]),...   
5790: 20 22 5c 22 3a 20 73 68 6f 75 6c 64 20 62 65 20   "\": should be 
57a0: 2d 66 6f 72 63 65 20 6f 72 20 2d 2d 22 2c 20 4e  -force or --", N
57b0: 55 4c 4c 29 3b 0a 09 20 20 20 20 72 65 74 75 72  ULL);..    retur
57c0: 6e 20 2d 31 3b 0a 09 7d 0a 20 20 20 20 7d 0a 20  n -1;..}.    }. 
57d0: 20 20 20 2a 66 6f 72 63 65 50 74 72 20 3d 20 66     *forcePtr = f
57e0: 6f 72 63 65 3b 0a 20 20 20 20 72 65 74 75 72 6e  orce;.    return
57f0: 20 69 3b 0a 7d 0a 2f 2a 0a 20 2a 2d 2d 2d 2d 2d   i;.}./*. *-----
5800: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
5810: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
5820: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
5830: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
5840: 2d 2d 2d 2d 2d 2d 0a 20 2a 0a 20 2a 20 46 69 6c  ------. *. * Fil
5850: 65 42 61 73 65 6e 61 6d 65 20 2d 2d 0a 20 2a 0a  eBasename --. *.
5860: 20 2a 09 47 69 76 65 6e 20 61 20 70 61 74 68 20   *.Given a path 
5870: 69 6e 20 65 69 74 68 65 72 20 74 63 6c 20 66 6f  in either tcl fo
5880: 72 6d 61 74 20 28 77 69 74 68 20 2f 20 73 65 70  rmat (with / sep
5890: 61 72 61 74 6f 72 73 29 2c 20 6f 72 20 69 6e 20  arators), or in 
58a0: 74 68 65 0a 20 2a 09 70 6c 61 74 66 6f 72 6d 2d  the. *.platform-
58b0: 73 70 65 63 69 66 69 63 20 66 6f 72 6d 61 74 20  specific format 
58c0: 66 6f 72 20 74 68 65 20 63 75 72 72 65 6e 74 20  for the current 
58d0: 70 6c 61 74 66 6f 72 6d 2c 20 72 65 74 75 72 6e  platform, return
58e0: 20 61 6c 6c 20 74 68 65 0a 20 2a 09 63 68 61 72   all the. *.char
58f0: 61 63 74 65 72 73 20 69 6e 20 74 68 65 20 70 61  acters in the pa
5900: 74 68 20 61 66 74 65 72 20 74 68 65 20 6c 61 73  th after the las
5910: 74 20 64 69 72 65 63 74 6f 72 79 20 73 65 70 61  t directory sepa
5920: 72 61 74 6f 72 2e 20 42 75 74 2c 20 69 66 0a 20  rator. But, if. 
5930: 2a 09 70 61 74 68 20 69 73 20 74 68 65 20 72 6f  *.path is the ro
5940: 6f 74 20 64 69 72 65 63 74 6f 72 79 2c 20 72 65  ot directory, re
5950: 74 75 72 6e 73 20 6e 6f 20 63 68 61 72 61 63 74  turns no charact
5960: 65 72 73 2e 0a 20 2a 0a 20 2a 20 52 65 73 75 6c  ers.. *. * Resul
5970: 74 73 3a 0a 20 2a 09 52 65 74 75 72 6e 73 20 74  ts:. *.Returns t
5980: 68 65 20 73 74 72 69 6e 67 20 6f 62 6a 65 63 74  he string object
5990: 20 74 68 61 74 20 72 65 70 72 65 73 65 6e 74 73   that represents
59a0: 20 74 68 65 20 62 61 73 65 6e 61 6d 65 2e 20 49   the basename. I
59b0: 66 20 74 68 65 72 65 20 69 73 20 61 6e 0a 20 2a  f there is an. *
59c0: 09 65 72 72 6f 72 2c 20 61 6e 20 65 72 72 6f 72  .error, an error
59d0: 20 6d 65 73 73 61 67 65 20 69 73 20 6c 65 66 74   message is left
59e0: 20 69 6e 20 69 6e 74 65 72 70 2c 20 61 6e 64 20   in interp, and 
59f0: 4e 55 4c 4c 20 69 73 20 72 65 74 75 72 6e 65 64  NULL is returned
5a00: 2e 0a 20 2a 0a 20 2a 20 53 69 64 65 20 65 66 66  .. *. * Side eff
5a10: 65 63 74 73 3a 0a 20 2a 09 4e 6f 6e 65 2e 0a 20  ects:. *.None.. 
5a20: 2a 0a 20 2a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  *. *------------
5a30: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
5a40: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
5a50: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
5a60: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a  ---------------.
5a70: 20 2a 2f 0a 0a 73 74 61 74 69 63 20 54 63 6c 5f   */..static Tcl_
5a80: 4f 62 6a 20 2a 0a 46 69 6c 65 42 61 73 65 6e 61  Obj *.FileBasena
5a90: 6d 65 28 0a 20 20 20 20 54 63 6c 5f 49 6e 74 65  me(.    Tcl_Inte
5aa0: 72 70 20 2a 69 6e 74 65 72 70 2c 09 09 2f 2a 20  rp *interp,../* 
5ab0: 49 6e 74 65 72 70 2c 20 66 6f 72 20 65 72 72 6f  Interp, for erro
5ac0: 72 20 72 65 74 75 72 6e 2e 20 2a 2f 0a 20 20 20  r return. */.   
5ad0: 20 54 63 6c 5f 4f 62 6a 20 2a 70 61 74 68 50 74   Tcl_Obj *pathPt
5ae0: 72 29 09 09 2f 2a 20 50 61 74 68 20 77 68 6f 73  r)../* Path whos
5af0: 65 20 62 61 73 65 6e 61 6d 65 20 74 6f 20 65 78  e basename to ex
5b00: 74 72 61 63 74 2e 20 2a 2f 0a 7b 0a 20 20 20 20  tract. */.{.    
5b10: 69 6e 74 20 6f 62 6a 63 3b 0a 20 20 20 20 54 63  int objc;.    Tc
5b20: 6c 5f 4f 62 6a 20 2a 73 70 6c 69 74 50 74 72 3b  l_Obj *splitPtr;
5b30: 0a 20 20 20 20 54 63 6c 5f 4f 62 6a 20 2a 72 65  .    Tcl_Obj *re
5b40: 73 75 6c 74 50 74 72 20 3d 20 4e 55 4c 4c 3b 0a  sultPtr = NULL;.
5b50: 0a 20 20 20 20 73 70 6c 69 74 50 74 72 20 3d 20  .    splitPtr = 
5b60: 54 63 6c 5f 46 53 53 70 6c 69 74 50 61 74 68 28  Tcl_FSSplitPath(
5b70: 70 61 74 68 50 74 72 2c 20 26 6f 62 6a 63 29 3b  pathPtr, &objc);
5b80: 0a 20 20 20 20 54 63 6c 5f 49 6e 63 72 52 65 66  .    Tcl_IncrRef
5b90: 43 6f 75 6e 74 28 73 70 6c 69 74 50 74 72 29 3b  Count(splitPtr);
5ba0: 0a 0a 20 20 20 20 69 66 20 28 6f 62 6a 63 20 21  ..    if (objc !
5bb0: 3d 20 30 29 20 7b 0a 09 69 66 20 28 28 6f 62 6a  = 0) {..if ((obj
5bc0: 63 20 3d 3d 20 31 29 20 26 26 20 28 2a 54 63 6c  c == 1) && (*Tcl
5bd0: 47 65 74 53 74 72 69 6e 67 28 70 61 74 68 50 74  GetString(pathPt
5be0: 72 29 20 3d 3d 20 27 7e 27 29 29 20 7b 0a 09 20  r) == '~')) {.. 
5bf0: 20 20 20 54 63 6c 5f 44 65 63 72 52 65 66 43 6f     Tcl_DecrRefCo
5c00: 75 6e 74 28 73 70 6c 69 74 50 74 72 29 3b 0a 09  unt(splitPtr);..
5c10: 20 20 20 20 69 66 20 28 54 63 6c 5f 46 53 43 6f      if (Tcl_FSCo
5c20: 6e 76 65 72 74 54 6f 50 61 74 68 54 79 70 65 28  nvertToPathType(
5c30: 69 6e 74 65 72 70 2c 20 70 61 74 68 50 74 72 29  interp, pathPtr)
5c40: 20 21 3d 20 54 43 4c 5f 4f 4b 29 20 7b 0a 09 09   != TCL_OK) {...
5c50: 72 65 74 75 72 6e 20 4e 55 4c 4c 3b 0a 09 20 20  return NULL;..  
5c60: 20 20 7d 0a 09 20 20 20 20 73 70 6c 69 74 50 74    }..    splitPt
5c70: 72 20 3d 20 54 63 6c 5f 46 53 53 70 6c 69 74 50  r = Tcl_FSSplitP
5c80: 61 74 68 28 70 61 74 68 50 74 72 2c 20 26 6f 62  ath(pathPtr, &ob
5c90: 6a 63 29 3b 0a 09 20 20 20 20 54 63 6c 5f 49 6e  jc);..    Tcl_In
5ca0: 63 72 52 65 66 43 6f 75 6e 74 28 73 70 6c 69 74  crRefCount(split
5cb0: 50 74 72 29 3b 0a 09 7d 0a 0a 09 2f 2a 0a 09 20  Ptr);..}.../*.. 
5cc0: 2a 20 52 65 74 75 72 6e 20 74 68 65 20 6c 61 73  * Return the las
5cd0: 74 20 63 6f 6d 70 6f 6e 65 6e 74 2c 20 75 6e 6c  t component, unl
5ce0: 65 73 73 20 69 74 20 69 73 20 74 68 65 20 6f 6e  ess it is the on
5cf0: 6c 79 20 63 6f 6d 70 6f 6e 65 6e 74 2c 20 61 6e  ly component, an
5d00: 64 20 69 74 0a 09 20 2a 20 69 73 20 74 68 65 20  d it.. * is the 
5d10: 72 6f 6f 74 20 6f 66 20 61 6e 20 61 62 73 6f 6c  root of an absol
5d20: 75 74 65 20 70 61 74 68 2e 0a 09 20 2a 2f 0a 0a  ute path... */..
5d30: 09 69 66 20 28 6f 62 6a 63 20 3e 20 30 29 20 7b  .if (objc > 0) {
5d40: 0a 09 20 20 20 20 54 63 6c 5f 4c 69 73 74 4f 62  ..    Tcl_ListOb
5d50: 6a 49 6e 64 65 78 28 4e 55 4c 4c 2c 20 73 70 6c  jIndex(NULL, spl
5d60: 69 74 50 74 72 2c 20 6f 62 6a 63 2d 31 2c 20 26  itPtr, objc-1, &
5d70: 72 65 73 75 6c 74 50 74 72 29 3b 0a 09 20 20 20  resultPtr);..   
5d80: 20 69 66 20 28 28 6f 62 6a 63 20 3d 3d 20 31 29   if ((objc == 1)
5d90: 20 26 26 0a 09 09 20 20 20 20 28 54 63 6c 5f 46   &&...    (Tcl_F
5da0: 53 47 65 74 50 61 74 68 54 79 70 65 28 72 65 73  SGetPathType(res
5db0: 75 6c 74 50 74 72 29 20 21 3d 20 54 43 4c 5f 50  ultPtr) != TCL_P
5dc0: 41 54 48 5f 52 45 4c 41 54 49 56 45 29 29 20 7b  ATH_RELATIVE)) {
5dd0: 0a 09 09 72 65 73 75 6c 74 50 74 72 20 3d 20 4e  ...resultPtr = N
5de0: 55 4c 4c 3b 0a 09 20 20 20 20 7d 0a 09 7d 0a 20  ULL;..    }..}. 
5df0: 20 20 20 7d 0a 20 20 20 20 69 66 20 28 72 65 73     }.    if (res
5e00: 75 6c 74 50 74 72 20 3d 3d 20 4e 55 4c 4c 29 20  ultPtr == NULL) 
5e10: 7b 0a 09 72 65 73 75 6c 74 50 74 72 20 3d 20 54  {..resultPtr = T
5e20: 63 6c 5f 4e 65 77 4f 62 6a 28 29 3b 0a 20 20 20  cl_NewObj();.   
5e30: 20 7d 0a 20 20 20 20 54 63 6c 5f 49 6e 63 72 52   }.    Tcl_IncrR
5e40: 65 66 43 6f 75 6e 74 28 72 65 73 75 6c 74 50 74  efCount(resultPt
5e50: 72 29 3b 0a 20 20 20 20 54 63 6c 5f 44 65 63 72  r);.    Tcl_Decr
5e60: 52 65 66 43 6f 75 6e 74 28 73 70 6c 69 74 50 74  RefCount(splitPt
5e70: 72 29 3b 0a 20 20 20 20 72 65 74 75 72 6e 20 72  r);.    return r
5e80: 65 73 75 6c 74 50 74 72 3b 0a 7d 0a 0c 0a 2f 2a  esultPtr;.}.../*
5e90: 0a 20 2a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  . *-------------
5ea0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
5eb0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
5ec0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
5ed0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 20 2a 0a 20 2a 20  ---------. *. * 
5ee0: 54 63 6c 46 69 6c 65 41 74 74 72 73 43 6d 64 20  TclFileAttrsCmd 
5ef0: 2d 2d 0a 20 2a 0a 20 2a 09 53 65 74 73 20 6f 72  --. *. *.Sets or
5f00: 20 67 65 74 73 20 74 68 65 20 70 6c 61 74 66 6f   gets the platfo
5f10: 72 6d 2d 73 70 65 63 69 66 69 63 20 61 74 74 72  rm-specific attr
5f20: 69 62 75 74 65 73 20 6f 66 20 61 20 66 69 6c 65  ibutes of a file
5f30: 2e 20 54 68 65 20 6f 62 6a 63 2d 6f 62 6a 76 0a  . The objc-objv.
5f40: 20 2a 09 70 6f 69 6e 74 73 20 74 6f 20 74 68 65   *.points to the
5f50: 20 66 69 6c 65 20 6e 61 6d 65 20 77 69 74 68 20   file name with 
5f60: 74 68 65 20 72 65 73 74 20 6f 66 20 74 68 65 20  the rest of the 
5f70: 63 6f 6d 6d 61 6e 64 20 6c 69 6e 65 20 66 6f 6c  command line fol
5f80: 6c 6f 77 69 6e 67 2e 0a 20 2a 09 54 68 69 73 20  lowing.. *.This 
5f90: 72 6f 75 74 69 6e 65 20 75 73 65 73 20 70 6c 61  routine uses pla
5fa0: 74 66 6f 72 6d 2d 73 70 65 63 69 66 69 63 20 74  tform-specific t
5fb0: 61 62 6c 65 73 20 6f 66 20 6f 70 74 69 6f 6e 20  ables of option 
5fc0: 73 74 72 69 6e 67 73 20 61 6e 64 0a 20 2a 09 63  strings and. *.c
5fd0: 61 6c 6c 62 61 63 6b 73 2e 20 54 68 65 20 63 61  allbacks. The ca
5fe0: 6c 6c 62 61 63 6b 20 74 6f 20 67 65 74 20 74 68  llback to get th
5ff0: 65 20 61 74 74 72 69 62 75 74 65 73 20 74 61 6b  e attributes tak
6000: 65 20 74 68 72 65 65 20 70 61 72 61 6d 65 74 65  e three paramete
6010: 72 73 3a 0a 20 2a 09 20 20 20 20 54 63 6c 5f 49  rs:. *.    Tcl_I
6020: 6e 74 65 72 70 20 2a 69 6e 74 65 72 70 3b 09 20  nterp *interp;. 
6030: 20 20 20 54 68 65 20 69 6e 74 65 72 70 20 74 6f     The interp to
6040: 20 72 65 70 6f 72 74 20 65 72 72 6f 72 73 20 77   report errors w
6050: 69 74 68 2e 20 53 69 6e 63 65 0a 20 2a 09 09 09  ith. Since. *...
6060: 09 20 20 20 20 74 68 69 73 20 69 73 20 61 6e 20  .    this is an 
6070: 6f 62 6a 65 63 74 2d 62 61 73 65 64 20 41 50 49  object-based API
6080: 2c 20 74 68 65 20 6f 62 6a 65 63 74 0a 20 2a 09  , the object. *.
6090: 09 09 09 20 20 20 20 66 6f 72 6d 20 6f 66 20 74  ...    form of t
60a0: 68 65 20 72 65 73 75 6c 74 20 73 68 6f 75 6c 64  he result should
60b0: 20 62 65 20 75 73 65 64 2e 0a 20 2a 09 20 20 20   be used.. *.   
60c0: 20 43 4f 4e 53 54 20 63 68 61 72 20 2a 66 69 6c   CONST char *fil
60d0: 65 4e 61 6d 65 3b 20 20 20 54 68 69 73 20 69 73  eName;   This is
60e0: 20 65 78 74 72 61 63 74 65 64 20 75 73 69 6e 67   extracted using
60f0: 0a 20 2a 09 09 09 09 20 20 20 20 54 63 6c 5f 54  . *....    Tcl_T
6100: 72 61 6e 73 6c 61 74 65 46 69 6c 65 4e 61 6d 65  ranslateFileName
6110: 2e 0a 20 2a 09 20 20 20 20 54 63 6c 4f 62 6a 20  .. *.    TclObj 
6120: 2a 2a 61 74 74 72 4f 62 6a 50 74 72 50 74 72 3b  **attrObjPtrPtr;
6130: 20 41 20 6e 65 77 20 6f 62 6a 65 63 74 20 74 6f   A new object to
6140: 20 68 6f 6c 64 20 74 68 65 20 61 74 74 72 69 62   hold the attrib
6150: 75 74 65 20 69 73 0a 20 2a 09 09 09 09 20 20 20  ute is. *....   
6160: 20 61 6c 6c 6f 63 61 74 65 64 20 61 6e 64 20 70   allocated and p
6170: 75 74 20 68 65 72 65 2e 0a 20 2a 09 54 68 65 20  ut here.. *.The 
6180: 66 69 72 73 74 20 74 77 6f 20 70 61 72 61 6d 65  first two parame
6190: 74 65 72 73 20 6f 66 20 74 68 65 20 63 61 6c 6c  ters of the call
61a0: 62 61 63 6b 20 75 73 65 64 20 74 6f 20 77 72 69  back used to wri
61b0: 74 65 20 6f 75 74 20 74 68 65 0a 20 2a 09 61 74  te out the. *.at
61c0: 74 72 69 62 75 74 65 73 20 61 72 65 20 74 68 65  tributes are the
61d0: 20 73 61 6d 65 2e 20 54 68 65 20 74 68 69 72 64   same. The third
61e0: 20 70 61 72 61 6d 65 74 65 72 20 69 73 3a 0a 20   parameter is:. 
61f0: 2a 09 20 20 20 20 43 4f 4e 53 54 20 2a 61 74 74  *.    CONST *att
6200: 72 4f 62 6a 50 74 72 3b 09 20 20 20 20 41 20 70  rObjPtr;.    A p
6210: 6f 69 6e 74 65 72 20 74 6f 20 74 68 65 20 6f 62  ointer to the ob
6220: 6a 65 63 74 20 74 68 61 74 20 68 61 73 20 74 68  ject that has th
6230: 65 20 6e 65 77 0a 20 2a 09 09 09 09 20 20 20 20  e new. *....    
6240: 61 74 74 72 69 62 75 74 65 2e 0a 20 2a 09 54 68  attribute.. *.Th
6250: 65 79 20 62 6f 74 68 20 72 65 74 75 72 6e 20 73  ey both return s
6260: 74 61 6e 64 61 72 64 20 54 43 4c 20 65 72 72 6f  tandard TCL erro
6270: 72 73 3b 20 69 66 20 74 68 65 20 72 6f 75 74 69  rs; if the routi
6280: 6e 65 20 74 6f 20 67 65 74 20 61 6e 0a 20 2a 09  ne to get an. *.
6290: 61 74 74 72 69 62 75 74 65 20 66 61 69 6c 73 2c  attribute fails,
62a0: 20 6e 6f 20 6f 62 6a 65 63 74 20 69 73 20 61 6c   no object is al
62b0: 6c 6f 63 61 74 65 64 20 61 6e 64 20 2a 61 74 74  located and *att
62c0: 72 4f 62 6a 50 74 72 50 74 72 20 69 73 0a 20 2a  rObjPtrPtr is. *
62d0: 09 75 6e 63 68 61 6e 67 65 64 2e 0a 20 2a 0a 20  .unchanged.. *. 
62e0: 2a 20 52 65 73 75 6c 74 73 3a 0a 20 2a 09 53 74  * Results:. *.St
62f0: 61 6e 64 61 72 64 20 54 43 4c 20 65 72 72 6f 72  andard TCL error
6300: 2e 0a 20 2a 0a 20 2a 20 53 69 64 65 20 65 66 66  .. *. * Side eff
6310: 65 63 74 73 3a 0a 20 2a 09 4d 61 79 20 73 65 74  ects:. *.May set
6320: 20 66 69 6c 65 20 61 74 74 72 69 62 75 74 65 73   file attributes
6330: 20 66 6f 72 20 74 68 65 20 66 69 6c 65 20 6e 61   for the file na
6340: 6d 65 2e 0a 20 2a 0a 20 2a 2d 2d 2d 2d 2d 2d 2d  me.. *. *-------
6350: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
6360: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
6370: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
6380: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a  ---------------.
6390: 20 2a 2f 0a 0a 69 6e 74 0a 54 63 6c 46 69 6c 65   */..int.TclFile
63a0: 41 74 74 72 73 43 6d 64 28 0a 20 20 20 20 54 63  AttrsCmd(.    Tc
63b0: 6c 5f 49 6e 74 65 72 70 20 2a 69 6e 74 65 72 70  l_Interp *interp
63c0: 2c 09 09 2f 2a 20 54 68 65 20 69 6e 74 65 72 70  ,../* The interp
63d0: 72 65 74 65 72 20 66 6f 72 20 65 72 72 6f 72 20  reter for error 
63e0: 72 65 70 6f 72 74 69 6e 67 2e 20 2a 2f 0a 20 20  reporting. */.  
63f0: 20 20 69 6e 74 20 6f 62 6a 63 2c 09 09 09 2f 2a    int objc,.../*
6400: 20 4e 75 6d 62 65 72 20 6f 66 20 63 6f 6d 6d 61   Number of comma
6410: 6e 64 20 6c 69 6e 65 20 61 72 67 75 6d 65 6e 74  nd line argument
6420: 73 2e 20 2a 2f 0a 20 20 20 20 54 63 6c 5f 4f 62  s. */.    Tcl_Ob
6430: 6a 20 2a 43 4f 4e 53 54 20 6f 62 6a 76 5b 5d 29  j *CONST objv[])
6440: 09 2f 2a 20 54 68 65 20 63 6f 6d 6d 61 6e 64 20  ./* The command 
6450: 6c 69 6e 65 20 6f 62 6a 65 63 74 73 2e 20 2a 2f  line objects. */
6460: 0a 7b 0a 20 20 20 20 69 6e 74 20 72 65 73 75 6c  .{.    int resul
6470: 74 3b 0a 20 20 20 20 43 4f 4e 53 54 20 63 68 61  t;.    CONST cha
6480: 72 20 2a 2a 20 61 74 74 72 69 62 75 74 65 53 74  r ** attributeSt
6490: 72 69 6e 67 73 3b 0a 20 20 20 20 54 63 6c 5f 4f  rings;.    Tcl_O
64a0: 62 6a 2a 20 6f 62 6a 53 74 72 69 6e 67 73 20 3d  bj* objStrings =
64b0: 20 4e 55 4c 4c 3b 0a 20 20 20 20 69 6e 74 20 6e   NULL;.    int n
64c0: 75 6d 4f 62 6a 53 74 72 69 6e 67 73 20 3d 20 2d  umObjStrings = -
64d0: 31 2c 20 64 69 64 41 6c 6c 6f 63 20 3d 20 30 3b  1, didAlloc = 0;
64e0: 0a 20 20 20 20 54 63 6c 5f 4f 62 6a 20 2a 66 69  .    Tcl_Obj *fi
64f0: 6c 65 50 74 72 3b 0a 0a 20 20 20 20 69 66 20 28  lePtr;..    if (
6500: 6f 62 6a 63 20 3c 20 33 29 20 7b 0a 09 54 63 6c  objc < 3) {..Tcl
6510: 5f 57 72 6f 6e 67 4e 75 6d 41 72 67 73 28 69 6e  _WrongNumArgs(in
6520: 74 65 72 70 2c 20 32 2c 20 6f 62 6a 76 2c 0a 09  terp, 2, objv,..
6530: 09 22 6e 61 6d 65 20 3f 6f 70 74 69 6f 6e 3f 20  ."name ?option? 
6540: 3f 76 61 6c 75 65 3f 20 3f 6f 70 74 69 6f 6e 20  ?value? ?option 
6550: 76 61 6c 75 65 20 2e 2e 2e 3f 22 29 3b 0a 09 72  value ...?");..r
6560: 65 74 75 72 6e 20 54 43 4c 5f 45 52 52 4f 52 3b  eturn TCL_ERROR;
6570: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 66 69 6c 65  .    }..    file
6580: 50 74 72 20 3d 20 6f 62 6a 76 5b 32 5d 3b 0a 20  Ptr = objv[2];. 
6590: 20 20 20 69 66 20 28 54 63 6c 5f 46 53 43 6f 6e     if (Tcl_FSCon
65a0: 76 65 72 74 54 6f 50 61 74 68 54 79 70 65 28 69  vertToPathType(i
65b0: 6e 74 65 72 70 2c 20 66 69 6c 65 50 74 72 29 20  nterp, filePtr) 
65c0: 21 3d 20 54 43 4c 5f 4f 4b 29 20 7b 0a 20 20 20  != TCL_OK) {.   
65d0: 20 09 72 65 74 75 72 6e 20 54 43 4c 5f 45 52 52   .return TCL_ERR
65e0: 4f 52 3b 0a 20 20 20 20 7d 0a 0a 20 20 20 20 6f  OR;.    }..    o
65f0: 62 6a 63 20 2d 3d 20 33 3b 0a 20 20 20 20 6f 62  bjc -= 3;.    ob
6600: 6a 76 20 2b 3d 20 33 3b 0a 20 20 20 20 72 65 73  jv += 3;.    res
6610: 75 6c 74 20 3d 20 54 43 4c 5f 45 52 52 4f 52 3b  ult = TCL_ERROR;
6620: 0a 20 20 20 20 54 63 6c 5f 53 65 74 45 72 72 6e  .    Tcl_SetErrn
6630: 6f 28 30 29 3b 0a 0a 20 20 20 20 61 74 74 72 69  o(0);..    attri
6640: 62 75 74 65 53 74 72 69 6e 67 73 20 3d 20 54 63  buteStrings = Tc
6650: 6c 5f 46 53 46 69 6c 65 41 74 74 72 53 74 72 69  l_FSFileAttrStri
6660: 6e 67 73 28 66 69 6c 65 50 74 72 2c 20 26 6f 62  ngs(filePtr, &ob
6670: 6a 53 74 72 69 6e 67 73 29 3b 0a 20 20 20 20 69  jStrings);.    i
6680: 66 20 28 61 74 74 72 69 62 75 74 65 53 74 72 69  f (attributeStri
6690: 6e 67 73 20 3d 3d 20 4e 55 4c 4c 29 20 7b 0a 09  ngs == NULL) {..
66a0: 69 6e 74 20 69 6e 64 65 78 3b 0a 09 54 63 6c 5f  int index;..Tcl_
66b0: 4f 62 6a 20 2a 6f 62 6a 50 74 72 3b 0a 0a 09 69  Obj *objPtr;...i
66c0: 66 20 28 6f 62 6a 53 74 72 69 6e 67 73 20 3d 3d  f (objStrings ==
66d0: 20 4e 55 4c 4c 29 20 7b 0a 09 20 20 20 20 69 66   NULL) {..    if
66e0: 20 28 54 63 6c 5f 47 65 74 45 72 72 6e 6f 28 29   (Tcl_GetErrno()
66f0: 20 21 3d 20 30 29 20 7b 0a 09 09 2f 2a 0a 09 09   != 0) {.../*...
6700: 20 2a 20 54 68 65 72 65 20 77 61 73 20 61 6e 20   * There was an 
6710: 65 72 72 6f 72 2c 20 70 72 6f 62 61 62 6c 79 20  error, probably 
6720: 74 68 61 74 20 74 68 65 20 66 69 6c 65 50 74 72  that the filePtr
6730: 20 69 73 20 6e 6f 74 0a 09 09 20 2a 20 61 63 63   is not... * acc
6740: 65 70 74 65 64 20 62 79 20 61 6e 79 20 66 69 6c  epted by any fil
6750: 65 73 79 73 74 65 6d 0a 09 09 20 2a 2f 0a 09 09  esystem... */...
6760: 54 63 6c 5f 41 70 70 65 6e 64 52 65 73 75 6c 74  Tcl_AppendResult
6770: 28 69 6e 74 65 72 70 2c 20 22 63 6f 75 6c 64 20  (interp, "could 
6780: 6e 6f 74 20 72 65 61 64 20 5c 22 22 2c 0a 09 09  not read \"",...
6790: 09 54 63 6c 47 65 74 53 74 72 69 6e 67 28 66 69  .TclGetString(fi
67a0: 6c 65 50 74 72 29 2c 20 22 5c 22 3a 20 22 2c 20  lePtr), "\": ", 
67b0: 54 63 6c 5f 50 6f 73 69 78 45 72 72 6f 72 28 69  Tcl_PosixError(i
67c0: 6e 74 65 72 70 29 2c 0a 09 09 09 4e 55 4c 4c 29  nterp),....NULL)
67d0: 3b 0a 09 20 20 20 20 7d 0a 09 20 20 20 20 72 65  ;..    }..    re
67e0: 74 75 72 6e 20 54 43 4c 5f 45 52 52 4f 52 3b 0a  turn TCL_ERROR;.
67f0: 09 7d 0a 0a 09 2f 2a 0a 09 20 2a 20 57 65 20 6f  .}.../*.. * We o
6800: 77 6e 20 74 68 65 20 6f 62 6a 65 63 74 20 6e 6f  wn the object no
6810: 77 2e 0a 09 20 2a 2f 0a 0a 09 54 63 6c 5f 49 6e  w... */...Tcl_In
6820: 63 72 52 65 66 43 6f 75 6e 74 28 6f 62 6a 53 74  crRefCount(objSt
6830: 72 69 6e 67 73 29 3b 0a 0a 09 2f 2a 0a 09 20 2a  rings);.../*.. *
6840: 20 55 73 65 20 6f 62 6a 53 74 72 69 6e 67 73 20   Use objStrings 
6850: 61 73 20 61 20 6c 69 73 74 20 6f 62 6a 65 63 74  as a list object
6860: 2e 0a 09 20 2a 2f 0a 0a 09 69 66 20 28 54 63 6c  ... */...if (Tcl
6870: 5f 4c 69 73 74 4f 62 6a 4c 65 6e 67 74 68 28 69  _ListObjLength(i
6880: 6e 74 65 72 70 2c 20 6f 62 6a 53 74 72 69 6e 67  nterp, objString
6890: 73 2c 20 26 6e 75 6d 4f 62 6a 53 74 72 69 6e 67  s, &numObjString
68a0: 73 29 20 21 3d 20 54 43 4c 5f 4f 4b 29 20 7b 0a  s) != TCL_OK) {.
68b0: 09 20 20 20 20 67 6f 74 6f 20 65 6e 64 3b 0a 09  .    goto end;..
68c0: 7d 0a 09 61 74 74 72 69 62 75 74 65 53 74 72 69  }..attributeStri
68d0: 6e 67 73 20 3d 20 28 43 4f 4e 53 54 20 63 68 61  ngs = (CONST cha
68e0: 72 20 2a 2a 29 20 54 63 6c 53 74 61 63 6b 41 6c  r **) TclStackAl
68f0: 6c 6f 63 28 69 6e 74 65 72 70 2c 0a 09 09 28 31  loc(interp,...(1
6900: 2b 6e 75 6d 4f 62 6a 53 74 72 69 6e 67 73 29 20  +numObjStrings) 
6910: 2a 20 73 69 7a 65 6f 66 28 63 68 61 72 2a 29 29  * sizeof(char*))
6920: 3b 0a 09 64 69 64 41 6c 6c 6f 63 20 3d 20 31 3b  ;..didAlloc = 1;
6930: 0a 09 66 6f 72 20 28 69 6e 64 65 78 20 3d 20 30  ..for (index = 0
6940: 3b 20 69 6e 64 65 78 20 3c 20 6e 75 6d 4f 62 6a  ; index < numObj
6950: 53 74 72 69 6e 67 73 3b 20 69 6e 64 65 78 2b 2b  Strings; index++
6960: 29 20 7b 0a 09 20 20 20 20 54 63 6c 5f 4c 69 73  ) {..    Tcl_Lis
6970: 74 4f 62 6a 49 6e 64 65 78 28 69 6e 74 65 72 70  tObjIndex(interp
6980: 2c 20 6f 62 6a 53 74 72 69 6e 67 73 2c 20 69 6e  , objStrings, in
6990: 64 65 78 2c 20 26 6f 62 6a 50 74 72 29 3b 0a 09  dex, &objPtr);..
69a0: 20 20 20 20 61 74 74 72 69 62 75 74 65 53 74 72      attributeStr
69b0: 69 6e 67 73 5b 69 6e 64 65 78 5d 20 3d 20 54 63  ings[index] = Tc
69c0: 6c 47 65 74 53 74 72 69 6e 67 28 6f 62 6a 50 74  lGetString(objPt
69d0: 72 29 3b 0a 09 7d 0a 09 61 74 74 72 69 62 75 74  r);..}..attribut
69e0: 65 53 74 72 69 6e 67 73 5b 69 6e 64 65 78 5d 20  eStrings[index] 
69f0: 3d 20 4e 55 4c 4c 3b 0a 20 20 20 20 7d 20 65 6c  = NULL;.    } el
6a00: 73 65 20 69 66 20 28 6f 62 6a 53 74 72 69 6e 67  se if (objString
6a10: 73 20 21 3d 20 4e 55 4c 4c 29 20 7b 0a 09 54 63  s != NULL) {..Tc
6a20: 6c 5f 50 61 6e 69 63 28 22 6d 75 73 74 20 6e 6f  l_Panic("must no
6a30: 74 20 75 70 64 61 74 65 20 6f 62 6a 50 74 72 52  t update objPtrR
6a40: 65 66 27 73 20 76 61 72 69 61 62 6c 65 20 61 6e  ef's variable an
6a50: 64 20 72 65 74 75 72 6e 20 6e 6f 6e 2d 4e 55 4c  d return non-NUL
6a60: 4c 22 29 3b 0a 20 20 20 20 7d 0a 0a 20 20 20 20  L");.    }..    
6a70: 69 66 20 28 6f 62 6a 63 20 3d 3d 20 30 29 20 7b  if (objc == 0) {
6a80: 0a 09 2f 2a 0a 09 20 2a 20 47 65 74 20 61 6c 6c  ../*.. * Get all
6a90: 20 61 74 74 72 69 62 75 74 65 73 2e 0a 09 20 2a   attributes... *
6aa0: 2f 0a 0a 09 69 6e 74 20 69 6e 64 65 78 2c 20 72  /...int index, r
6ab0: 65 73 20 3d 20 54 43 4c 5f 4f 4b 2c 20 6e 62 41  es = TCL_OK, nbA
6ac0: 74 74 73 20 3d 20 30 3b 0a 09 54 63 6c 5f 4f 62  tts = 0;..Tcl_Ob
6ad0: 6a 20 2a 6c 69 73 74 50 74 72 3b 0a 0a 09 6c 69  j *listPtr;...li
6ae0: 73 74 50 74 72 20 3d 20 54 63 6c 5f 4e 65 77 4c  stPtr = Tcl_NewL
6af0: 69 73 74 4f 62 6a 28 30 2c 20 4e 55 4c 4c 29 3b  istObj(0, NULL);
6b00: 0a 09 66 6f 72 20 28 69 6e 64 65 78 20 3d 20 30  ..for (index = 0
6b10: 3b 20 61 74 74 72 69 62 75 74 65 53 74 72 69 6e  ; attributeStrin
6b20: 67 73 5b 69 6e 64 65 78 5d 20 21 3d 20 4e 55 4c  gs[index] != NUL
6b30: 4c 3b 20 69 6e 64 65 78 2b 2b 29 20 7b 0a 09 20  L; index++) {.. 
6b40: 20 20 20 54 63 6c 5f 4f 62 6a 20 2a 6f 62 6a 50     Tcl_Obj *objP
6b50: 74 72 41 74 74 72 3b 0a 0a 09 20 20 20 20 69 66  trAttr;...    if
6b60: 20 28 72 65 73 20 21 3d 20 54 43 4c 5f 4f 4b 29   (res != TCL_OK)
6b70: 20 7b 0a 09 09 2f 2a 0a 09 09 20 2a 20 43 6c 65   {.../*... * Cle
6b80: 61 72 20 74 68 65 20 65 72 72 6f 72 20 66 72 6f  ar the error fro
6b90: 6d 20 74 68 65 20 6c 61 73 74 20 69 74 65 72 61  m the last itera
6ba0: 74 69 6f 6e 2e 0a 09 09 20 2a 2f 0a 0a 09 09 54  tion.... */....T
6bb0: 63 6c 5f 52 65 73 65 74 52 65 73 75 6c 74 28 69  cl_ResetResult(i
6bc0: 6e 74 65 72 70 29 3b 0a 09 20 20 20 20 7d 0a 0a  nterp);..    }..
6bd0: 09 20 20 20 20 72 65 73 20 3d 20 54 63 6c 5f 46  .    res = Tcl_F
6be0: 53 46 69 6c 65 41 74 74 72 73 47 65 74 28 69 6e  SFileAttrsGet(in
6bf0: 74 65 72 70 2c 20 69 6e 64 65 78 2c 20 66 69 6c  terp, index, fil
6c00: 65 50 74 72 2c 20 26 6f 62 6a 50 74 72 41 74 74  ePtr, &objPtrAtt
6c10: 72 29 3b 0a 09 20 20 20 20 69 66 20 28 72 65 73  r);..    if (res
6c20: 20 3d 3d 20 54 43 4c 5f 4f 4b 29 20 7b 0a 09 09   == TCL_OK) {...
6c30: 54 63 6c 5f 4f 62 6a 20 2a 6f 62 6a 50 74 72 20  Tcl_Obj *objPtr 
6c40: 3d 0a 09 09 09 54 63 6c 5f 4e 65 77 53 74 72 69  =....Tcl_NewStri
6c50: 6e 67 4f 62 6a 28 61 74 74 72 69 62 75 74 65 53  ngObj(attributeS
6c60: 74 72 69 6e 67 73 5b 69 6e 64 65 78 5d 2c 20 2d  trings[index], -
6c70: 31 29 3b 0a 0a 09 09 54 63 6c 5f 4c 69 73 74 4f  1);....Tcl_ListO
6c80: 62 6a 41 70 70 65 6e 64 45 6c 65 6d 65 6e 74 28  bjAppendElement(
6c90: 69 6e 74 65 72 70 2c 20 6c 69 73 74 50 74 72 2c  interp, listPtr,
6ca0: 20 6f 62 6a 50 74 72 29 3b 0a 09 09 54 63 6c 5f   objPtr);...Tcl_
6cb0: 4c 69 73 74 4f 62 6a 41 70 70 65 6e 64 45 6c 65  ListObjAppendEle
6cc0: 6d 65 6e 74 28 69 6e 74 65 72 70 2c 20 6c 69 73  ment(interp, lis
6cd0: 74 50 74 72 2c 20 6f 62 6a 50 74 72 41 74 74 72  tPtr, objPtrAttr
6ce0: 29 3b 0a 09 09 6e 62 41 74 74 73 2b 2b 3b 0a 09  );...nbAtts++;..
6cf0: 20 20 20 20 7d 0a 09 7d 0a 0a 09 69 66 20 28 69      }..}...if (i
6d00: 6e 64 65 78 20 3e 20 30 20 26 26 20 6e 62 41 74  ndex > 0 && nbAt
6d10: 74 73 20 3d 3d 20 30 29 20 7b 0a 09 20 20 20 20  ts == 0) {..    
6d20: 2f 2a 0a 09 20 20 20 20 20 2a 20 45 72 72 6f 72  /*..     * Error
6d30: 3a 20 6e 6f 20 76 61 6c 69 64 20 61 74 74 72 69  : no valid attri
6d40: 62 75 74 65 73 20 66 6f 75 6e 64 2e 0a 09 20 20  butes found...  
6d50: 20 20 20 2a 2f 0a 0a 09 20 20 20 20 54 63 6c 5f     */...    Tcl_
6d60: 44 65 63 72 52 65 66 43 6f 75 6e 74 28 6c 69 73  DecrRefCount(lis
6d70: 74 50 74 72 29 3b 0a 09 20 20 20 20 67 6f 74 6f  tPtr);..    goto
6d80: 20 65 6e 64 3b 0a 09 7d 0a 0a 20 20 20 20 09 54   end;..}..    .T
6d90: 63 6c 5f 53 65 74 4f 62 6a 52 65 73 75 6c 74 28  cl_SetObjResult(
6da0: 69 6e 74 65 72 70 2c 20 6c 69 73 74 50 74 72 29  interp, listPtr)
6db0: 3b 0a 20 20 20 20 7d 20 65 6c 73 65 20 69 66 20  ;.    } else if 
6dc0: 28 6f 62 6a 63 20 3d 3d 20 31 29 20 7b 0a 09 2f  (objc == 1) {../
6dd0: 2a 0a 09 20 2a 20 47 65 74 20 6f 6e 65 20 61 74  *.. * Get one at
6de0: 74 72 69 62 75 74 65 2e 0a 09 20 2a 2f 0a 0a 09  tribute... */...
6df0: 69 6e 74 20 69 6e 64 65 78 3b 0a 09 54 63 6c 5f  int index;..Tcl_
6e00: 4f 62 6a 20 2a 6f 62 6a 50 74 72 20 3d 20 4e 55  Obj *objPtr = NU
6e10: 4c 4c 3b 0a 0a 09 69 66 20 28 6e 75 6d 4f 62 6a  LL;...if (numObj
6e20: 53 74 72 69 6e 67 73 20 3d 3d 20 30 29 20 7b 0a  Strings == 0) {.
6e30: 09 20 20 20 20 54 63 6c 5f 41 70 70 65 6e 64 52  .    Tcl_AppendR
6e40: 65 73 75 6c 74 28 69 6e 74 65 72 70 2c 20 22 62  esult(interp, "b
6e50: 61 64 20 6f 70 74 69 6f 6e 20 5c 22 22 2c 20 54  ad option \"", T
6e60: 63 6c 47 65 74 53 74 72 69 6e 67 28 6f 62 6a 76  clGetString(objv
6e70: 5b 30 5d 29 2c 0a 09 09 20 20 20 20 22 5c 22 2c  [0]),...    "\",
6e80: 20 74 68 65 72 65 20 61 72 65 20 6e 6f 20 66 69   there are no fi
6e90: 6c 65 20 61 74 74 72 69 62 75 74 65 73 20 69 6e  le attributes in
6ea0: 20 74 68 69 73 20 66 69 6c 65 73 79 73 74 65 6d   this filesystem
6eb0: 2e 22 2c 0a 09 09 20 20 20 20 4e 55 4c 4c 29 3b  .",...    NULL);
6ec0: 0a 09 20 20 20 20 67 6f 74 6f 20 65 6e 64 3b 0a  ..    goto end;.
6ed0: 09 7d 0a 0a 09 69 66 20 28 54 63 6c 5f 47 65 74  .}...if (Tcl_Get
6ee0: 49 6e 64 65 78 46 72 6f 6d 4f 62 6a 28 69 6e 74  IndexFromObj(int
6ef0: 65 72 70 2c 20 6f 62 6a 76 5b 30 5d 2c 20 61 74  erp, objv[0], at
6f00: 74 72 69 62 75 74 65 53 74 72 69 6e 67 73 2c 0a  tributeStrings,.
6f10: 09 09 22 6f 70 74 69 6f 6e 22 2c 20 30 2c 20 26  .."option", 0, &
6f20: 69 6e 64 65 78 29 20 21 3d 20 54 43 4c 5f 4f 4b  index) != TCL_OK
6f30: 29 20 7b 0a 09 20 20 20 20 67 6f 74 6f 20 65 6e  ) {..    goto en
6f40: 64 3b 0a 09 7d 0a 09 69 66 20 28 64 69 64 41 6c  d;..}..if (didAl
6f50: 6c 6f 63 29 20 7b 0a 09 20 20 20 20 54 63 6c 46  loc) {..    TclF
6f60: 72 65 65 49 6e 74 52 65 70 28 6f 62 6a 76 5b 30  reeIntRep(objv[0
6f70: 5d 29 3b 0a 09 20 20 20 20 6f 62 6a 76 5b 30 5d  ]);..    objv[0]
6f80: 2d 3e 74 79 70 65 50 74 72 20 3d 20 4e 55 4c 4c  ->typePtr = NULL
6f90: 3b 0a 09 7d 0a 09 69 66 20 28 54 63 6c 5f 46 53  ;..}..if (Tcl_FS
6fa0: 46 69 6c 65 41 74 74 72 73 47 65 74 28 69 6e 74  FileAttrsGet(int
6fb0: 65 72 70 2c 20 69 6e 64 65 78 2c 20 66 69 6c 65  erp, index, file
6fc0: 50 74 72 2c 0a 09 09 26 6f 62 6a 50 74 72 29 20  Ptr,...&objPtr) 
6fd0: 21 3d 20 54 43 4c 5f 4f 4b 29 20 7b 0a 09 20 20  != TCL_OK) {..  
6fe0: 20 20 67 6f 74 6f 20 65 6e 64 3b 0a 09 7d 0a 09    goto end;..}..
6ff0: 54 63 6c 5f 53 65 74 4f 62 6a 52 65 73 75 6c 74  Tcl_SetObjResult
7000: 28 69 6e 74 65 72 70 2c 20 6f 62 6a 50 74 72 29  (interp, objPtr)
7010: 3b 0a 20 20 20 20 7d 20 65 6c 73 65 20 7b 0a 09  ;.    } else {..
7020: 2f 2a 0a 09 20 2a 20 53 65 74 20 6f 70 74 69 6f  /*.. * Set optio
7030: 6e 2f 76 61 6c 75 65 20 70 61 69 72 73 2e 0a 09  n/value pairs...
7040: 20 2a 2f 0a 0a 09 69 6e 74 20 69 2c 20 69 6e 64   */...int i, ind
7050: 65 78 3b 0a 0a 09 69 66 20 28 6e 75 6d 4f 62 6a  ex;...if (numObj
7060: 53 74 72 69 6e 67 73 20 3d 3d 20 30 29 20 7b 0a  Strings == 0) {.
7070: 09 20 20 20 20 54 63 6c 5f 41 70 70 65 6e 64 52  .    Tcl_AppendR
7080: 65 73 75 6c 74 28 69 6e 74 65 72 70 2c 20 22 62  esult(interp, "b
7090: 61 64 20 6f 70 74 69 6f 6e 20 5c 22 22 2c 20 54  ad option \"", T
70a0: 63 6c 47 65 74 53 74 72 69 6e 67 28 6f 62 6a 76  clGetString(objv
70b0: 5b 30 5d 29 2c 0a 09 09 20 20 20 20 22 5c 22 2c  [0]),...    "\",
70c0: 20 74 68 65 72 65 20 61 72 65 20 6e 6f 20 66 69   there are no fi
70d0: 6c 65 20 61 74 74 72 69 62 75 74 65 73 20 69 6e  le attributes in
70e0: 20 74 68 69 73 20 66 69 6c 65 73 79 73 74 65 6d   this filesystem
70f0: 2e 22 2c 0a 09 09 20 20 20 20 4e 55 4c 4c 29 3b  .",...    NULL);
7100: 0a 09 20 20 20 20 67 6f 74 6f 20 65 6e 64 3b 0a  ..    goto end;.
7110: 09 7d 0a 0a 20 20 20 20 09 66 6f 72 20 28 69 20  .}..    .for (i 
7120: 3d 20 30 3b 20 69 20 3c 20 6f 62 6a 63 20 3b 20  = 0; i < objc ; 
7130: 69 20 2b 3d 20 32 29 20 7b 0a 20 20 20 20 09 20  i += 2) {.    . 
7140: 20 20 20 69 66 20 28 54 63 6c 5f 47 65 74 49 6e     if (Tcl_GetIn
7150: 64 65 78 46 72 6f 6d 4f 62 6a 28 69 6e 74 65 72  dexFromObj(inter
7160: 70 2c 20 6f 62 6a 76 5b 69 5d 2c 20 61 74 74 72  p, objv[i], attr
7170: 69 62 75 74 65 53 74 72 69 6e 67 73 2c 0a 09 09  ibuteStrings,...
7180: 20 20 20 20 22 6f 70 74 69 6f 6e 22 2c 20 30 2c      "option", 0,
7190: 20 26 69 6e 64 65 78 29 20 21 3d 20 54 43 4c 5f   &index) != TCL_
71a0: 4f 4b 29 20 7b 0a 09 09 67 6f 74 6f 20 65 6e 64  OK) {...goto end
71b0: 3b 0a 20 20 20 20 09 20 20 20 20 7d 0a 09 20 20  ;.    .    }..  
71c0: 20 20 69 66 20 28 64 69 64 41 6c 6c 6f 63 29 20    if (didAlloc) 
71d0: 7b 0a 09 09 54 63 6c 46 72 65 65 49 6e 74 52 65  {...TclFreeIntRe
71e0: 70 28 6f 62 6a 76 5b 69 5d 29 3b 0a 09 09 6f 62  p(objv[i]);...ob
71f0: 6a 76 5b 69 5d 2d 3e 74 79 70 65 50 74 72 20 3d  jv[i]->typePtr =
7200: 20 4e 55 4c 4c 3b 0a 09 20 20 20 20 7d 0a 09 20   NULL;..    }.. 
7210: 20 20 20 69 66 20 28 69 20 2b 20 31 20 3d 3d 20     if (i + 1 == 
7220: 6f 62 6a 63 29 20 7b 0a 09 09 54 63 6c 5f 41 70  objc) {...Tcl_Ap
7230: 70 65 6e 64 52 65 73 75 6c 74 28 69 6e 74 65 72  pendResult(inter
7240: 70 2c 20 22 76 61 6c 75 65 20 66 6f 72 20 5c 22  p, "value for \"
7250: 22 2c 0a 09 09 09 54 63 6c 47 65 74 53 74 72 69  ",....TclGetStri
7260: 6e 67 28 6f 62 6a 76 5b 69 5d 29 2c 20 22 5c 22  ng(objv[i]), "\"
7270: 20 6d 69 73 73 69 6e 67 22 2c 20 4e 55 4c 4c 29   missing", NULL)
7280: 3b 0a 09 09 67 6f 74 6f 20 65 6e 64 3b 0a 09 20  ;...goto end;.. 
7290: 20 20 20 7d 0a 20 20 20 20 09 20 20 20 20 69 66     }.    .    if
72a0: 20 28 54 63 6c 5f 46 53 46 69 6c 65 41 74 74 72   (Tcl_FSFileAttr
72b0: 73 53 65 74 28 69 6e 74 65 72 70 2c 20 69 6e 64  sSet(interp, ind
72c0: 65 78 2c 20 66 69 6c 65 50 74 72 2c 0a 20 20 20  ex, filePtr,.   
72d0: 20 09 20 20 20 20 09 20 20 20 20 6f 62 6a 76 5b   .    .    objv[
72e0: 69 20 2b 20 31 5d 29 20 21 3d 20 54 43 4c 5f 4f  i + 1]) != TCL_O
72f0: 4b 29 20 7b 0a 09 09 67 6f 74 6f 20 65 6e 64 3b  K) {...goto end;
7300: 0a 20 20 20 20 09 20 20 20 20 7d 0a 20 20 20 20  .    .    }.    
7310: 09 7d 0a 20 20 20 20 7d 0a 20 20 20 20 72 65 73  .}.    }.    res
7320: 75 6c 74 20 3d 20 54 43 4c 5f 4f 4b 3b 0a 0a 20  ult = TCL_OK;.. 
7330: 20 65 6e 64 3a 0a 20 20 20 20 69 66 20 28 64 69   end:.    if (di
7340: 64 41 6c 6c 6f 63 29 20 7b 0a 09 2f 2a 0a 09 20  dAlloc) {../*.. 
7350: 2a 20 46 72 65 65 20 75 70 20 74 68 65 20 61 72  * Free up the ar
7360: 72 61 79 20 77 65 20 61 6c 6c 6f 63 61 74 65 64  ray we allocated
7370: 2e 0a 09 20 2a 2f 0a 0a 09 54 63 6c 53 74 61 63  ... */...TclStac
7380: 6b 46 72 65 65 28 69 6e 74 65 72 70 2c 20 28 76  kFree(interp, (v
7390: 6f 69 64 20 2a 29 61 74 74 72 69 62 75 74 65 53  oid *)attributeS
73a0: 74 72 69 6e 67 73 29 3b 0a 20 20 20 20 7d 0a 0a  trings);.    }..
73b0: 20 20 20 20 69 66 20 28 6f 62 6a 53 74 72 69 6e      if (objStrin
73c0: 67 73 20 21 3d 20 4e 55 4c 4c 29 20 7b 0a 09 2f  gs != NULL) {../
73d0: 2a 0a 09 20 2a 20 57 65 20 64 6f 6e 27 74 20 6e  *.. * We don't n
73e0: 65 65 64 20 74 68 69 73 20 6f 62 6a 65 63 74 20  eed this object 
73f0: 74 68 61 74 20 77 61 73 20 70 61 73 73 65 64 20  that was passed 
7400: 74 6f 20 75 73 20 61 6e 79 20 6d 6f 72 65 2e 0a  to us any more..
7410: 09 20 2a 2f 0a 0a 09 54 63 6c 5f 44 65 63 72 52  . */...Tcl_DecrR
7420: 65 66 43 6f 75 6e 74 28 6f 62 6a 53 74 72 69 6e  efCount(objStrin
7430: 67 73 29 3b 0a 20 20 20 20 7d 0a 20 20 20 20 72  gs);.    }.    r
7440: 65 74 75 72 6e 20 72 65 73 75 6c 74 3b 0a 7d 0a  eturn result;.}.
7450: 0c 0a 2f 2a 0a 20 2a 20 4c 6f 63 61 6c 20 56 61  ../*. * Local Va
7460: 72 69 61 62 6c 65 73 3a 0a 20 2a 20 6d 6f 64 65  riables:. * mode
7470: 3a 20 63 0a 20 2a 20 63 2d 62 61 73 69 63 2d 6f  : c. * c-basic-o
7480: 66 66 73 65 74 3a 20 34 0a 20 2a 20 66 69 6c 6c  ffset: 4. * fill
7490: 2d 63 6f 6c 75 6d 6e 3a 20 37 38 0a 20 2a 20 45  -column: 78. * E
74a0: 6e 64 3a 0a 20 2a 2f 0a                          nd:. */.