first check-in of feisty meow codebase. many things broken still due to recent
[feisty_meow.git] / scripts / files / zapdirs.pl
1 #!/usr/bin/perl
2
3 ###############################################################################
4 #                                                                             #
5 #  Name   : zapdirs                                                           #
6 #  Author : Chris Koeritz                                                     #
7 #  Rights : Copyright (C) 1996-$now by Author                                 #
8 #                                                                             #
9 #  Purpose:                                                                   #
10 #                                                                             #
11 #    Removes a list of directories that are expected to be empty.  This       #
12 #  cleans out any filenames that are considered unimportant first.            #
13 #                                                                             #
14 ###############################################################################
15 #  This program is free software; you can redistribute it and/or modify it    #
16 #  under the terms of the GNU General Public License as published by the Free #
17 #  Software Foundation; either version 2 of the License or (at your option)   #
18 #  any later version.  See: "http://www.gruntose.com/Info/GNU/GPL.html" for a #
19 #  version of the License.  Please send any updates to "fred@gruntose.com".   #
20 ###############################################################################
21
22 require "zap_the_dir.pl";
23
24 #hmmm: move this to a useful location in a perl library.
25 if ($OS eq "UNIX") {
26   $FIND_ENDING = "';'";
27   $DEV_NULL = "> /dev/null"
28 } elsif ( ($OS eq "DOS") || ($OS eq "Windows_95")
29     || ($OS eq "Windows_98") || ($OS eq "Windows_NT") ) {
30   $FIND_ENDING = "';'";
31   $DEV_NULL = "> nul"
32 } else {
33   die "The Operating System variable (OS) is not set.\n";
34 }
35
36 local(@to_zap) = ();  # the array to zap out.
37
38 if ($#ARGV < 0) {
39   # no parms; give a default list.
40   @to_zap = (".");
41 } else {
42   @to_zap = &glob_list(@ARGV);
43   if ($#to_zap < 0) {
44     local($plural) = "";
45     if ($#ARGV > 0) { $plural = "s"; }
46     print "The directory name$plural \"@ARGV\" cannot be found.\n";
47     exit 0;
48   }
49 }
50
51 #print "zap list is:\n@to_zap\n";
52
53 &recursively_zap_dirs(@to_zap);
54
55 exit 0;
56