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