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) {
}
open (OUT, ">$destdir/$file") || error("failed to write $destdir/$file: $!");
+ binmode(OUT) if $binary;
print OUT $content;
close OUT;
} #}}}