summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorOliver Tappe2008-01-11 13:21:30 +0100
committerOliver Tappe2008-01-11 13:21:30 +0100
commit89773c294389297cee33ae3e8a66a0d4c528b69e (patch)
tree556168bbace2f7b87862e9aec9ab7b4343ace19f /lib
parent* oops, remove debug output :-/ (diff)
downloadcore-89773c294389297cee33ae3e8a66a0d4c528b69e.tar.gz
core-89773c294389297cee33ae3e8a66a0d4c528b69e.tar.xz
core-89773c294389297cee33ae3e8a66a0d4c528b69e.zip
* fixed encoding problem of PXE-config file output
git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1463 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'lib')
-rw-r--r--lib/OpenSLX/Utils.pm24
1 files changed, 20 insertions, 4 deletions
diff --git a/lib/OpenSLX/Utils.pm b/lib/OpenSLX/Utils.pm
index fbfd8d4c..f3a13e48 100644
--- a/lib/OpenSLX/Utils.pm
+++ b/lib/OpenSLX/Utils.pm
@@ -100,13 +100,17 @@ sub slurpFile
my $fileName = shift || confess 'need to pass in fileName!';
my $flags = shift || {};
- checkParams($flags, { 'failIfMissing' => '?' });
+ checkParams($flags, {
+ 'failIfMissing' => '?',
+ 'io-layer' => '?',
+ });
my $failIfMissing
= exists $flags->{failIfMissing} ? $flags->{failIfMissing} : 1;
+ my $ioLayer = $flags->{'io-layer'} || 'utf8';
local $/;
my $fh;
- if (!open($fh, '<', $fileName)) {
+ if (!open($fh, "<:$ioLayer", $fileName)) {
return '' unless $failIfMissing;
croak _tr("could not open file '%s' for reading! (%s)", $fileName, $!);
}
@@ -120,9 +124,15 @@ sub spitFile
{
my $fileName = shift || croak 'need to pass in a fileName!';
my $content = shift;
+ my $flags = shift || {};
+
+ checkParams($flags, {
+ 'io-layer' => '?',
+ });
+ my $ioLayer = $flags->{'io-layer'} || 'utf8';
my $fh;
- open($fh, '>', $fileName)
+ open($fh, ">:$ioLayer", $fileName)
or croak _tr("unable to create file '%s' (%s)\n", $fileName, $!);
print $fh $content
or croak _tr("unable to print to file '%s' (%s)\n", $fileName, $!);
@@ -135,9 +145,15 @@ sub appendFile
{
my $fileName = shift || croak 'need to pass in a fileName!';
my $content = shift;
+ my $flags = shift || {};
+
+ checkParams($flags, {
+ 'io-layer' => '?',
+ });
+ my $ioLayer = $flags->{'io-layer'} || 'utf8';
my $fh;
- open($fh, '>>', $fileName)
+ open($fh, ">>:$ioLayer", $fileName)
or croak _tr("unable to create file '%s' (%s)\n", $fileName, $!);
print $fh $content
or croak _tr("unable to print to file '%s' (%s)\n", $fileName, $!);