diff options
| author | fukachan <fukachan> | 2003-01-29 13:27:32 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2003-01-29 13:27:32 +0000 |
| commit | c943f11f0003ebc30da882d055d54498cbccffed (patch) | |
| tree | 8e4453042c944c714a1975a2cdf9f6b71c6ce64a /fml/lib/FML/Process | |
| parent | a2e0351e9e77b964d75d97adbdbf5d79e7a19988 (diff) | |
| download | fml8-c943f11f0003ebc30da882d055d54498cbccffed.tar.gz fml8-c943f11f0003ebc30da882d055d54498cbccffed.tar.bz2 fml8-c943f11f0003ebc30da882d055d54498cbccffed.zip | |
implement cat() method for convenience
Diffstat (limited to 'fml/lib/FML/Process')
| -rw-r--r-- | fml/lib/FML/Process/Utils.pm | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/fml/lib/FML/Process/Utils.pm b/fml/lib/FML/Process/Utils.pm index 8d50a951..9c74821c 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.54 2003/01/25 09:13:35 fukachan Exp $ +# $FML: Utils.pm,v 1.55 2003/01/26 03:14:18 fukachan Exp $ # package FML::Process::Utils; @@ -366,6 +366,43 @@ sub _mkpath_str } +# XXX-TODO: $curproc->cat() is strage. + +# Descriptions: concantenate files to STDOUT +# Arguments: OBJ($curproc) ARRAY_REF($files) HANDLE($out) +# Side Effects: none +# Return Value: none +sub cat +{ + my ($curproc, $files, $out) = @_; + $out ||= \*STDOUT; + + for my $file (@$files) { + _cat($file, $out); + } +} + + +# Descriptions: cat file to STDOUT +# Arguments: STR($file) HANDLE($out) +# Side Effects: none +# Return Value: none +sub _cat +{ + my ($file, $out) = @_; + + use FileHandle; + my $fh = new FileHandle $file; + if (defined $fh) { + my $buf = ''; + while (sysread($fh, $buf, 4096)) { + syswrite($out, $buf); + } + $fh->close(); + } +} + + =head1 METHODS for convenience =head2 fml_version() |
