diff options
| author | fukachan <fukachan> | 2004-04-10 12:41:28 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2004-04-10 12:41:28 +0000 |
| commit | efa7d18afb61a948ad494594fcc5c144665c2d36 (patch) | |
| tree | 4f64d2a497904056ed99228a53ea569e9c2b4087 /fml/lib | |
| parent | 915b2becde14285016786fd3fb39b98471faf1d6 (diff) | |
| download | fml8-efa7d18afb61a948ad494594fcc5c144665c2d36.tar.gz fml8-efa7d18afb61a948ad494594fcc5c144665c2d36.tar.bz2 fml8-efa7d18afb61a948ad494594fcc5c144665c2d36.zip | |
implement copy() and append() methods $curproc provides to remove
File::Utils class.
Diffstat (limited to 'fml/lib')
| -rw-r--r-- | fml/lib/FML/Article/Spool.pm | 5 | ||||
| -rw-r--r-- | fml/lib/FML/MTA/Control/Postfix.pm | 12 | ||||
| -rw-r--r-- | fml/lib/FML/MTA/Control/Procmail.pm | 6 | ||||
| -rw-r--r-- | fml/lib/FML/MTA/Control/Sendmail.pm | 5 | ||||
| -rw-r--r-- | fml/lib/FML/Process/Utils.pm | 49 |
5 files changed, 58 insertions, 19 deletions
diff --git a/fml/lib/FML/Article/Spool.pm b/fml/lib/FML/Article/Spool.pm index 8ae01bdd..8e618875 100644 --- a/fml/lib/FML/Article/Spool.pm +++ b/fml/lib/FML/Article/Spool.pm @@ -3,7 +3,7 @@ # Copyright (C) 2003,2004 Ken'ichi Fukamachi # All rights reserved. # -# $FML: Spool.pm,v 1.6 2004/02/01 15:54:45 fukachan Exp $ +# $FML: Spool.pm,v 1.7 2004/02/15 09:27:42 fukachan Exp $ # package FML::Article::Spool; @@ -141,8 +141,7 @@ sub convert link($source, $filepath); } else { - use File::Utils qw(copy); - copy($source, $filepath); + $curproc->copy($source, $filepath); } } else { diff --git a/fml/lib/FML/MTA/Control/Postfix.pm b/fml/lib/FML/MTA/Control/Postfix.pm index 093f660a..ddc0affc 100644 --- a/fml/lib/FML/MTA/Control/Postfix.pm +++ b/fml/lib/FML/MTA/Control/Postfix.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Postfix.pm,v 1.2 2004/01/22 15:01:02 fukachan Exp $ +# $FML: Postfix.pm,v 1.3 2004/01/23 09:17:37 fukachan Exp $ # package FML::MTA::Control::Postfix; @@ -53,10 +53,7 @@ sub postfix_install_alias $self->_install($src, $dst, $xparams); $curproc->ui_message("updating $alias"); - - # XXX-TODO: we should prepare methods such as $curproc->util->append() ? - use File::Utils qw(append); - append($dst, $alias); + $curproc->append($dst, $alias); unlink $dst; } @@ -397,9 +394,8 @@ sub postfix_install_virtual_map } $self->_install($src, $dst, $params); - - use File::Utils qw(append); - append($dst, $virtual); + + $curproc->append($dst, $virtual); unlink $dst; } diff --git a/fml/lib/FML/MTA/Control/Procmail.pm b/fml/lib/FML/MTA/Control/Procmail.pm index 39873ae2..c1af1886 100644 --- a/fml/lib/FML/MTA/Control/Procmail.pm +++ b/fml/lib/FML/MTA/Control/Procmail.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Procmail.pm,v 1.2 2004/01/22 15:00:37 fukachan Exp $ +# $FML: Procmail.pm,v 1.3 2004/01/23 09:17:37 fukachan Exp $ # package FML::MTA::Control::Procmail; @@ -49,9 +49,7 @@ sub procmail_install_alias $self->_install($src, $dst, $params); $curproc->ui_message("updating $alias\n"); - - use File::Utils qw(append); - append($dst, $alias); + $curproc->append($dst, $alias); unlink $dst; } diff --git a/fml/lib/FML/MTA/Control/Sendmail.pm b/fml/lib/FML/MTA/Control/Sendmail.pm index 514259b4..869c37e5 100644 --- a/fml/lib/FML/MTA/Control/Sendmail.pm +++ b/fml/lib/FML/MTA/Control/Sendmail.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Sendmail.pm,v 1.2 2004/01/22 15:01:02 fukachan Exp $ +# $FML: Sendmail.pm,v 1.3 2004/01/23 09:17:37 fukachan Exp $ # package FML::MTA::Control::Sendmail; @@ -177,8 +177,7 @@ sub sendmail_install_virtual_map $self->_install($src, $dst, $params); - use File::Utils qw(append); - append($dst, $virtual); + $curproc->append($dst, $virtual); unlink $dst; } diff --git a/fml/lib/FML/Process/Utils.pm b/fml/lib/FML/Process/Utils.pm index 89224c50..9c72826e 100644 --- a/fml/lib/FML/Process/Utils.pm +++ b/fml/lib/FML/Process/Utils.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Utils.pm,v 1.110 2004/03/23 06:34:17 fukachan Exp $ +# $FML: Utils.pm,v 1.111 2004/04/02 11:51:32 fukachan Exp $ # package FML::Process::Utils; @@ -435,6 +435,53 @@ sub touch } +# XXX-TODO: $curproc->copy() is strage. + +# Descriptions: copy $dst to $src in atomic way. +# Arguments: OBJ($curproc) STR($src) STR($dst) +# Side Effects: $dst file created. +# Return Value: none +sub copy +{ + my ($curproc, $src, $dst) = @_; + + use IO::Adapter::AtomicFile; + my $obj = new IO::Adapter::AtomicFile; + $obj->new->copy($src, $dst); +} + + +# XXX-TODO: $curproc->append() is strage. + +# Descriptions: append content within $src file into $dst file. +# Arguments: OBJ($curproc) STR($src) STR($dst) +# Side Effects: $dst file created or updated. +# Return Value: none +sub append +{ + my ($curproc, $src, $dst) = @_; + + use FileHandle; + my $rh = new FileHandle $src; + my $wh = new FileHandle ">> $dst"; + if (defined($rh) && defined($wh)) { + $wh->autoflush(1); + + my $buf = ''; + while ($buf = <$rh>) { + print $wh $buf; + } + + $wh->close(); + $rh->close(); + } + else { + croak("fail to open $src") unless defined $rh; + croak("fail to open $dst") unless defined $wh; + } +} + + # XXX-TODO: $curproc->cat() is strage. # Descriptions: concantenate files to STDOUT. |
