xref: /trunk/main/sysui/util/checksize.pl (revision 7e90fac2)
1:
2eval 'exec perl -wS $0 ${1+"$@"}'
3    if 0;
4#**************************************************************
5#
6#  Licensed to the Apache Software Foundation (ASF) under one
7#  or more contributor license agreements.  See the NOTICE file
8#  distributed with this work for additional information
9#  regarding copyright ownership.  The ASF licenses this file
10#  to you under the Apache License, Version 2.0 (the
11#  "License"); you may not use this file except in compliance
12#  with the License.  You may obtain a copy of the License at
13#
14#    http://www.apache.org/licenses/LICENSE-2.0
15#
16#  Unless required by applicable law or agreed to in writing,
17#  software distributed under the License is distributed on an
18#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19#  KIND, either express or implied.  See the License for the
20#  specific language governing permissions and limitations
21#  under the License.
22#
23#**************************************************************
24
25
26#
27#
28#
29
30my
31$is_debug=0;
32my $err = 0;
33my $path = "../" . $ENV{'INPATH'} . "/";
34
35#Path of the directory from which the recursion starts (must have ending '/').
36print "Checking:$path\n";
37# Initiate the recursion
38&RecurseDirs($path);
39if ($err > 0)
40{
41    print "Error: $err damaged files encountered\n";
42    exit(1); # stop dmake
43} else
44{
45    print "ok.\n";
46}
47exit;
48
49#### SUBROUTINES SECTION ####
50
51# Function that recurses through the directory tree calling FileFunction on all files
52sub RecurseDirs {
53    my ($path) = @_;
54    my $file;    #Variable for a file
55
56    opendir (DIRECTORY, $path) or
57        die "Error: Can't read $path\n";
58    my @all_files = grep (!/^\.\.?$/, readdir (DIRECTORY)); #Read all the files except for '.' and '..'
59    closedir (DIRECTORY);
60
61    foreach $file (@all_files) {
62        if (-d "$path$file/") {
63            &RecurseDirs("$path$file/");
64        } else {
65            &check($path, $file);
66        }
67    }
68}
69
70############################################################################
71sub check       #04.02.2005 13:40
72############################################################################
73 {
74    my $path = shift;
75    my $file = shift;
76    print "$path$file\n" if ((-e "$path$file") && $is_debug);
77    # don't check dpc,flag,rpmflag,sdf [obj for UNX] files, or etc subdirectory
78    return if ( ($file =~ /.+\.(dpc|\w*?flag)/) || ($file =~ /.+\.obj/ && $ENV{GUI} eq 'UNX') || ($path =~ /.+etc/) || ($path =~ /.+logs/) || ($path =~ /.+sdf/) );
79    if ( -z "$path$file" ) {
80        print "Error: $path$file 0 Bytes!\n";
81        $err++;
82    }
83 }
84