Subject: | No binmode on open set => fails on Win32 |
Date: | Sun, 17 Apr 2011 17:55:24 +0200 |
To: | bug-File-KeePass [...] rt.cpan.org |
From: | Sebastian Schmidt <yath [...] yath.de> |
Hi,
File::KeePass does not set the binmode on the opened file handles; this
causes saves to fail because of Windows text translation.
Sebastian
Patch:
diff -ur File-KeePass-0.03.old/lib/File/KeePass.pm File-KeePass-0.03/lib/File/KeePass.pm
--- File-KeePass-0.03.old/lib/File/KeePass.pm 2011-04-17 17:51:37.000000000 +0200
+++ File-KeePass-0.03/lib/File/KeePass.pm 2011-04-17 17:54:38.000000000 +0200
@@ -44,6 +44,7 @@
my $pass = shift || croak "Missing pass\n";
open(my $fh, '<', $file) || croak "Couldn't open $file: $!\n";
+ binmode($fh) || croak "Unable to set $file to binary: $!\n";
my $size = -s $file;
read($fh, my $buffer, $size);
close $fh;
@@ -60,6 +61,7 @@
my $bak = "$file.bak";
my $tmp = "$file.new.".int(time());
open(my $fh, '>', $tmp) || croak "Couldn't open $tmp: $!\n";
+ binmode($fh) || croak "Unable to set $file to binary: $!\n";
print $fh $buf;
close $fh;
if (-s $tmp ne length($buf)) {