diff options
Diffstat (limited to 'ikiwiki')
-rwxr-xr-x | ikiwiki | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -193,24 +193,27 @@ sub srcfile ($) { #{{{ error("internal error: $file cannot be found"); } #}}} -sub readfile ($) { #{{{ +sub readfile ($;$) { #{{{ my $file=shift; + my $binary=shift; if (-l $file) { error("cannot read a symlink ($file)"); } local $/=undef; - open (IN, "$file") || error("failed to read $file: $!"); + open (IN, $file) || error("failed to read $file: $!"); + binmode(IN) if $binary; my $ret=<IN>; close IN; return $ret; } #}}} -sub writefile ($$$) { #{{{ +sub writefile ($$$;$) { #{{{ my $file=shift; # can include subdirs my $destdir=shift; # directory to put file in my $content=shift; + my $binary=shift; my $test=$file; while (length $test) { @@ -232,6 +235,7 @@ sub writefile ($$$) { #{{{ } open (OUT, ">$destdir/$file") || error("failed to write $destdir/$file: $!"); + binmode(OUT) if $binary; print OUT $content; close OUT; } #}}} |