##---------------------------------------------------------------------------##
## $Id: mhfile.pl,v 2.6 2002/05/14 00:04:40 ehood Exp $
## Earl Hood mhonarc@mhonarc.org
## File routines for MHonArc
##---------------------------------------------------------------------------##
## MHonArc -- Internet mail-to-HTML converter
## Copyright (C) 1997-1999 Earl Hood, mhonarc@mhonarc.org
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
##---------------------------------------------------------------------------##
##---------------------------------------------------------------------------##
my($gz) = $file =~ /\.gz$/i;
return $handle if open($handle, "$GzipExe -cd $file |");
die qq/ERROR: Failed to exec "$GzipExe -cd $file |": $!\n/;
return $handle if open($handle, $file);
return $handle if open($handle, "$GzipExe -cd $file.gz |");
die qq/ERROR: Failed to exec "$GzipExe -cd $file.gz |": $!\n/;
die qq/ERROR: Failed to open "$file": $!\n/;
$file .= ".gz" unless $file =~ /\.gz$/;
return $handle if open($handle, "| $GzipExe > $file");
die qq{ERROR
: Failed to
exec "| $GzipExe > $file": $!\n};
return $handle if open($handle, "> $file");
die qq{ERROR
: Failed to create
"$file": $!\n};
(-e
$_[0]) || (-e
"$_[0].gz");
my($src, $dst) = ($_[0], $_[1]);
my($gz) = $src =~ /\.gz$/i;
if ($gz || (-e
"$src.gz")) {
$src .= ".gz" unless $gz;
$dst .= ".gz" unless $dst =~ /\.gz$/i;
my($src, $dst) = ($_[0], $_[1]);
my($gz) = $src =~ /\.gz$/i;
if ($gz || (-e
"$src.gz")) {
$src .= ".gz" unless $gz;
$dst .= ".gz" unless $dst =~ /\.gz$/i;
if (!rename($src, $dst)) {
die qq/ERROR: Unable to rename "$src" to "$dst": $!\n/;
utime($atime, $mtime, $_, "$_.gz");
##---------------------------------------------------------------------------##
if (!opendir(DIR
, $file)) {
warn qq{Warning
: Unable to
open "$file"\n};
my @files = grep(!/^(\.|\..)$/i, readdir(DIR
));
&dir_remove
($file . $mhonarc::DIRSEP
. $_);
warn qq{Warning
: Unable to remove
"$file": $!\n};
warn qq{Warning
: Unable to
delete "$file": $!\n};
##---------------------------------------------------------------------------##