From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Todd Rinaldo <toddr@cpan.org>
Date: Mon, 2 Apr 2018 12:33:31 -0500
Subject: [PATCH] Address deprecated warnings in Directory::Queue
---
modules/Directory-Queue/Directory-Queue/Makefile.PL | 1 +
.../Directory-Queue/lib/Directory/Queue.pm | 21 ++++++---------------
2 files changed, 7 insertions(+), 15 deletions(-)
diff --git a/Makefile.PL b/Makefile.PL
index 5f96bacfe..bc1a19366 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -23,6 +23,7 @@ my(%param, $emv, $name);
'No::Worries' => '1.1',
'POSIX' => 0,
'Time::HiRes' => 0,
+ 'File::Slurper' => 0,
},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz' },
clean => { FILES => 'Directory-Queue-*' },
diff --git a/lib/Directory/Queue.pm b/lib/Directory/Queue.pm
index ebc6546e6..d120a779e 100644
--- a/lib/Directory/Queue.pm
+++ b/lib/Directory/Queue.pm
@@ -20,6 +20,7 @@ our $REVISION = sprintf("%d.%02d", q$Revision: 1.50 $ =~ /(\d+)\.(\d+)/);
# used modules
#
+use File::Slurper qw(write_text write_binary);
use No::Worries::Die qw(dief);
use No::Worries::Export qw(export_control);
use No::Worries::Stat qw(ST_DEV ST_INO ST_NLINK ST_SIZE ST_MTIME);
@@ -208,7 +209,7 @@ sub _file_read_utf8 ($) {
$data = "";
$done = -1;
while ($done) {
- $done = sysread($fh, $data, SYSBUFSIZE, length($data));
+ $done = read($fh, $data, SYSBUFSIZE, length($data));
dief("cannot sysread(%s): %s", $path, $!) unless defined($done);
}
close($fh) or dief("cannot close(%s): %s", $path, $!);
@@ -252,25 +253,15 @@ sub _file_create ($$;$) {
sub _file_write ($$$$) {
my($path, $utf8, $umask, $dataref) = @_;
- my($fh, $length, $offset, $done);
+ my($fh);
$fh = _file_create($path, $umask, "strict");
+ close($fh) or dief("cannot close(%s): %s", $path, $!);
if ($utf8) {
- binmode($fh, ":encoding(utf8)")
- or dief("cannot binmode(%s, :encoding(utf8)): %s", $path, $!);
+ write_text($path, ${$dataref});
} else {
- binmode($fh)
- or dief("cannot binmode(%s): %s", $path, $!);
- }
- $length = length(${ $dataref });
- $offset = 0;
- while ($length) {
- $done = syswrite($fh, ${ $dataref }, SYSBUFSIZE, $offset);
- dief("cannot syswrite(%s): %s", $path, $!) unless defined($done);
- $length -= $done;
- $offset += $done;
+ write_binary($path, ${$dataref});
}
- close($fh) or dief("cannot close(%s): %s", $path, $!);
}
#