summaryrefslogtreecommitdiff
path: root/ikiwiki
diff options
context:
space:
mode:
Diffstat (limited to 'ikiwiki')
-rwxr-xr-xikiwiki10
1 files changed, 7 insertions, 3 deletions
diff --git a/ikiwiki b/ikiwiki
index 97afa853f..6bf58017d 100755
--- a/ikiwiki
+++ b/ikiwiki
@@ -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;
} #}}}