1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
#! @im_path_perl@
################################################################
###
### impack
###
### Copyright (C) 1997 Internet Message Group
###
### This Perl5 library conforms
### GNU GENERAL PUBLIC LICENSE Version 2.
###
###
### Author: Internet Message Group <img@mew.org>
### Created: Apr 23, 1997
### Revised: @im_revised@
###
my $VERSION = "impack @im_version@";
$Prog = 'impack';
##
## Require packages
##
use IM::Config;
use IM::Folder;
use IM::File;
use IM::Util;
use integer;
use strict;
use vars qw($Prog $EXPLANATION @OptConfig
$opt_src $opt_noharm $opt_verbose $opt_debug $opt_help);
##
## Environments
##
$EXPLANATION = "
$Prog :: Internet Message Pack
$VERSION
usage: $Prog [options] [+folder]
";
@OptConfig =(
'src;F;;' => "Set source folder.",
'noharm;b;;' => "No packing. Show what will happen.",
'verbose;b;;' => 'With verbose messages.',
'debug;d;;' => "With debug message.",
'help;b;;' => "Show this message.",
);
##
## Profile and option processing
##
init_opt(\@OptConfig);
read_cfg();
read_opt(\@ARGV); # help?
help($EXPLANATION) && exit $EXIT_SUCCESS if $opt_help;
debug_option($opt_debug) if $opt_debug;
##
## Main
##
impack($opt_src);
exit $EXIT_SUCCESS;
##################################################
##
## Work horse
##
sub impack ($) {
my $folder = shift;
my $msg = 1;
my $dst;
chk_folder_existance($folder); # not return in case false.
my @paths = get_impath($folder, 'all');
print "packing messages in $opt_src ... " unless $opt_noharm;
flush('STDOUT') unless $opt_noharm;
foreach (@paths) {
$dst = $_;
$dst =~ s|[^/]+$|$msg++|e;
if ($_ ne $dst){
im_rename($_, $dst) || die $@; # XXX
}
}
print "done\n" unless $opt_noharm;
touch_folder($folder) unless $opt_noharm;
}
### Local Variables:
### mode: perl
### End:
|