OSDN Git Service

Please enter the commit message for your changes. Lines starting
[eos/base.git] / util / src / TclTk / tcl8.6.12 / tools / installData.tcl
1 #!/bin/sh
2 #\
3 exec tclsh "$0" ${1+"$@"}
4
5 #----------------------------------------------------------------------
6 #
7 # installData.tcl --
8 #
9 #       This file installs a hierarchy of data found in the directory
10 #       specified by its first argument into the directory specified
11 #       by its second.
12 #
13 #----------------------------------------------------------------------
14 #
15 # Copyright (c) 2004 Kevin B. Kenny.  All rights reserved.
16 # See the file "license.terms" for information on usage and redistribution
17 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
18 #----------------------------------------------------------------------
19
20 proc copyDir {d1 d2} {
21
22     puts [format {%*sCreating %s} [expr {4 * [info level]}] {} \
23               [file tail $d2]]
24
25     file delete -force -- $d2
26     file mkdir $d2
27
28     foreach ftail [glob -directory $d1 -nocomplain -tails *] {
29         set f [file join $d1 $ftail]
30         if {[file isdirectory $f] && [string compare CVS $ftail]} {
31             copyDir $f [file join $d2 $ftail]
32         } elseif {[file isfile $f]} {
33             file copy -force $f [file join $d2 $ftail]
34             if {$::tcl_platform(platform) eq {unix}} {
35                 file attributes [file join $d2 $ftail] -permissions 0o644
36             } else {
37                 file attributes [file join $d2 $ftail] -readonly 1
38             }
39         }
40     }
41
42     if {$::tcl_platform(platform) eq {unix}} {
43         file attributes $d2 -permissions 0o755
44     } else {
45         file attributes $d2 -readonly 1
46     }
47
48 }
49
50 copyDir [file normalize [lindex $argv 0]] [file normalize [lindex $argv 1]]