diff options
| author | fukachan <fukachan> | 2002-05-24 06:36:02 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2002-05-24 06:36:02 +0000 |
| commit | 0a027af7d7cab057c128b5f5377c7f3eeac67bec (patch) | |
| tree | ab3af3460cfe31d4169e389582957014b1da71fc | |
| parent | 077b8027a8d299201cf0074bac73faf2581bfec0 (diff) | |
| download | fml8-0a027af7d7cab057c128b5f5377c7f3eeac67bec.tar.gz fml8-0a027af7d7cab057c128b5f5377c7f3eeac67bec.tar.bz2 fml8-0a027af7d7cab057c128b5f5377c7f3eeac67bec.zip | |
implement convert_file(srcfile, dstfile, params)
| -rw-r--r-- | fml/lib/FML/Config/Convert.pm | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/fml/lib/FML/Config/Convert.pm b/fml/lib/FML/Config/Convert.pm index bf58f630..3c6e870d 100644 --- a/fml/lib/FML/Config/Convert.pm +++ b/fml/lib/FML/Config/Convert.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: Convert.pm,v 1.5 2002/02/24 08:25:40 fukachan Exp $ +# $FML: Convert.pm,v 1.6 2002/03/20 03:19:24 fukachan Exp $ # @@ -74,6 +74,36 @@ sub convert } +# Descriptions: conversion filter. +# Arguments: STR($src) STR($dst) HASH_REF($config) +# Side Effects: print out to file $out +# Return Value: none +sub convert_file +{ + my ($src, $dst, $config) = @_; + + use FileHandle; + my $in = new FileHandle $src; + my $out = new FileHandle "> $dst.$$"; + + if (defined $in && defined $out) { + chmod 0644, "$dst.$$"; + + eval q{ convert($in, $out, $config);}; + croak($@) if $@; + + $out->close(); + $in->close(); + + rename("$dst.$$", $dst) || croak("fail to rename $dst"); + } + else { + croak("fail to open $src") unless defined $in; + croak("fail to open $dst") unless defined $out; + } +} + + # Descriptions: replace __variable__ with real value in $config # Arguments: STR($buf) HASH_REF($config) # Side Effects: buffer replacement |
