Subversion Repositories DevTools

Rev

Rev 5709 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5709 Rev 6133
Line 20... Line 20...
20
#                 Intended to replace all similar lumps of code
20
#                 Intended to replace all similar lumps of code
21
#                 within JATS
21
#                 within JATS
22
#
22
#
23
#                 Intended to make life simple
23
#                 Intended to make life simple
24
#
24
#
25
#                 It has  alot of callbacks and config, but the body
25
#                 It has a lot of callbacks and config, but the body
26
#                 of the work is similar
26
#                 of the work is similar
27
#
27
#
28
# Examples:
28
# Examples:
29
#               CopyDir ( 'aaa', 'bbb' );
29
#               CopyDir ( 'aaa', 'bbb' );
30
#               Simply copy the aaa dir-tree to 'bbb'
30
#               Simply copy the aaa dir-tree to 'bbb'
Line 41... Line 41...
41
#                             'IgnoreDirs' => ['.svn'],
41
#                             'IgnoreDirs' => ['.svn'],
42
#                             });
42
#                             });
43
#
43
#
44
#              Complex copy of the 'aaa' tree to 'bbb'
44
#              Complex copy of the 'aaa' tree to 'bbb'
45
#               Do my own error processing
45
#               Do my own error processing
46
#               Do my own loggind
46
#               Do my own logging
47
#               Examine each file/dir being processed
47
#               Examine each file/dir being processed
48
#               Do my own copy ( Expert)
48
#               Do my own copy ( Expert)
49
#               Notify me if an existing file is present
49
#               Notify me if an existing file is present
50
#               Do not copy files called a2 and build.pl
50
#               Do not copy files called a2 and build.pl
51
#               Do not copy the .svn subdir
51
#               Do not copy the .svn subdir
Line 92... Line 92...
92
#                   $dst_dir                - Dest dir
92
#                   $dst_dir                - Dest dir
93
#                   $opt                    - An Array or Hash Ref of options
93
#                   $opt                    - An Array or Hash Ref of options
94
#                    Flags that affect operation
94
#                    Flags that affect operation
95
#                       DeleteFirst     - True: Delete target directory first
95
#                       DeleteFirst     - True: Delete target directory first
96
#                       NoSubDirs       - True: Only source directory files
96
#                       NoSubDirs       - True: Only source directory files
-
 
97
#                       NoRecurse       - True: Only scan the root directory. 
-
 
98
#                                               User can 'Examine' dirs
-
 
99
#                       SkipTLF         - True: Skip Files in the specified dir -
-
 
100
#                                               Only consider subdirs
97
#                       Flatten         - True: Flatten output dir
101
#                       Flatten         - True: Flatten output dir
98
#                       Log             - True: Log activity
102
#                       Log             - True: Log activity
99
#                       EmptyDirs       - True: Create empty dirs
103
#                       EmptyDirs       - True: Create empty dirs
100
#                       IgnoreDots      - True: Ignore files and dirs starting with .
104
#                       IgnoreDots      - True: Ignore files and dirs starting with .
101
#                       NoOverwrite     - True: Do not replace file in target
105
#                       NoOverwrite     - True: Do not replace file in target
102
#                       DuplicateLinks  - True: Duplicate, don't copy links
106
#                       DuplicateLinks  - True: Duplicate, don't copy links
103
#                       SymlinkFiles    - True: Create symlinks if possible
107
#                       SymlinkFiles    - True: Create symlinks if possible
104
#                       ReadOnlyFiles   - True: Make files Read Only
108
#                       ReadOnlyFiles   - True: Make files Read Only
105
#                       KeepSrcTail     - True: Keeps the tail of the source dir
109
#                       KeepSrcTail     - True: Keeps the tail of the source dir
-
 
110
#                                               Prepends the last directory of the src_dir
-
 
111
#                                               to the $dst_dir
106
#                     User callback functions
112
#                     User callback functions
107
#                       Expert          - Function to do the work
113
#                       Expert          - Function to do the work
108
#                       Examine         - Function to examine each entry
114
#                       Examine         - Function to examine each entry
109
#                                         If True, then proceed
115
#                                         If True, then proceed
110
#                       Exists          - Function called if target file exists
116
#                       Exists          - Function called if target file exists
Line 118... Line 124...
118
#                       IgnoreDirsRE    - An array of subdirs to ignore (RE)
124
#                       IgnoreDirsRE    - An array of subdirs to ignore (RE)
119
#                       Match           - An array of files to match
125
#                       Match           - An array of files to match
120
#                       MatchRE         - An array of file to match (RE)
126
#                       MatchRE         - An array of file to match (RE)
121
#                       MatchDirs       - An array of top level dirs to match
127
#                       MatchDirs       - An array of top level dirs to match
122
#                       MatchDirsRE     - An array of top level dirs to match (RE)
128
#                       MatchDirsRE     - An array of top level dirs to match (RE)
123
#                       SkipTLF         - Skip Files in the specified dir -
-
 
124
#                                         only consider subdirs
-
 
125
#                     Misc
129
#                     Misc
126
#                       Stats           - A ref to a hash of stats
130
#                       Stats           - A ref to a hash of stats
127
#                       FileList        - Ref to array of target files
131
#                       FileList        - Ref to array of target files
-
 
132
#                       NoSubDirList    - Ref to array of TLD subdirs skipped
-
 
133
#                                         Implies NoSubDirs
128
#                       UserData        - Item passed through to call backs
134
#                       UserData        - Item passed through to call backs
129
#                                         for the users own purposes.
135
#                                         for the users own purposes.
130
#
136
#
131
#                   File and dir match/ignore operations come in two flavours
137
#                   File and dir match/ignore operations come in two flavours
132
#                   Simple : Use of simple wildcards: ?,* and [...] constructs
138
#                   Simple : Use of simple wildcards: ?,* and [...] constructs
Line 168... Line 174...
168
    #
174
    #
169
    $dst_dir .= '/' . StripDir($src_dir)
175
    $dst_dir .= '/' . StripDir($src_dir)
170
        if ( $opt->{'KeepSrcTail'} );
176
        if ( $opt->{'KeepSrcTail'} );
171
 
177
 
172
    #
178
    #
-
 
179
    #   NoSubDirList implies NoSubDirs 
-
 
180
    #
-
 
181
    $opt->{'NoSubDirs'} = 1
-
 
182
        if (defined $opt->{'NoSubDirList'});
-
 
183
 
-
 
184
    #
173
    #   Insert some default options
185
    #   Insert some default options
174
    #
186
    #
175
    $opt->{'SrcDir'} = $src_dir;
187
    $opt->{'SrcDir'} = $src_dir;
176
    $opt->{'DstDir'} = $dst_dir;
188
    $opt->{'DstDir'} = $dst_dir;
177
 
189
 
Line 576... Line 588...
576
            elsif ( -d _ )
588
            elsif ( -d _ )
577
            {
589
            {
578
                #
590
                #
579
                #   Only process the top-level directory
591
                #   Only process the top-level directory
580
                #
592
                #
581
                next if ( $opt->{'NoSubDirs'} );
593
                if ( $opt->{'NoSubDirs'} )
-
 
594
                {
-
 
595
                    if (defined $opt->{'NoSubDirList'})
-
 
596
                    {
-
 
597
                        push @{$opt->{'NoSubDirList'}}, $file;
-
 
598
                    }
-
 
599
                    next;
-
 
600
                }
582
 
601
 
583
                #
602
                #
584
                #   Match against wanted items
603
                #   Match against wanted items
585
                #
604
                #
586
                $opt->{'Stats'}{'examinedDirs'}++;
605
                $opt->{'Stats'}{'examinedDirs'}++;
Line 589... Line 608...
589
                #
608
                #
590
                #   Add to the list of future dirs to process
609
                #   Add to the list of future dirs to process
591
                #   Place on end to ensure depth first
610
                #   Place on end to ensure depth first
592
                #   Algorithm requires dirname has a trailing /
611
                #   Algorithm requires dirname has a trailing /
593
                #
612
                #
594
                push @dirs, $relname . '/';
613
                push (@dirs, $relname . '/') unless ( $opt->{'NoRecurse'} ) ;
595
 
614
 
596
                #
615
                #
597
                #   Create flat output dir - no more processing
616
                #   Create flat output dir - no more processing
598
                #
617
                #
599
                next if ( $opt->{'Flatten'} );
618
                next if ( $opt->{'Flatten'} );
Line 1088... Line 1107...
1088
 
1107
 
1089
my %ValidArgs = (
1108
my %ValidArgs = (
1090
    'DeleteFirst'     => Scalar,
1109
    'DeleteFirst'     => Scalar,
1091
    'DuplicateLinks'  => Scalar,
1110
    'DuplicateLinks'  => Scalar,
1092
    'NoSubDirs'       => Scalar | Match,
1111
    'NoSubDirs'       => Scalar | Match,
-
 
1112
    'NoRecurse'       => Scalar,
1093
    'Flatten'         => Scalar,
1113
    'Flatten'         => Scalar,
1094
    'Logger'          => CodeRef,
1114
    'Logger'          => CodeRef,
1095
    'EmptyDirs'       => Scalar,
1115
    'EmptyDirs'       => Scalar,
1096
    'IgnoreDots'      => Scalar | Match,
1116
    'IgnoreDots'      => Scalar | Match,
1097
    'Expert'          => CodeRef,
1117
    'Expert'          => CodeRef,
Line 1112... Line 1132...
1112
    'UserData'        => 0,
1132
    'UserData'        => 0,
1113
    'SymlinkFiles'    => Scalar,
1133
    'SymlinkFiles'    => Scalar,
1114
    'ReadOnlyFiles'   => Scalar,
1134
    'ReadOnlyFiles'   => Scalar,
1115
    'KeepSrcTail'     => Scalar,
1135
    'KeepSrcTail'     => Scalar,
1116
    'FileList'        => ArrayRef,
1136
    'FileList'        => ArrayRef,
-
 
1137
    'NoSubDirList'    => ArrayRef,
1117
    'SkipTLF'         => Scalar,
1138
    'SkipTLF'         => Scalar,
1118
);
1139
);
1119
 
1140
 
1120
 
1141
 
1121
#-------------------------------------------------------------------------------
1142
#-------------------------------------------------------------------------------