mirror of
https://codeberg.org/h3xx/simplify_static_dir
synced 2024-08-14 23:57:24 +00:00
Unpack @_ first (PBP)
This commit is contained in:
parent
907a7113a8
commit
7dbbb5422a
8 changed files with 28 additions and 22 deletions
|
@ -30,7 +30,7 @@ our @EXPORT = qw/
|
|||
use constant SCRIPT => $ENV{SCRIPT} // abs_path dirname(__FILE__) . '/../simplify_static_dir-main.pl';
|
||||
|
||||
sub are_hardlinked {
|
||||
my $starter = shift;
|
||||
my ($starter, @files) = @_;
|
||||
|
||||
my $gen_ident = sub {
|
||||
my ($dev, $ino) = stat $_[0];
|
||||
|
@ -38,7 +38,7 @@ sub are_hardlinked {
|
|||
};
|
||||
|
||||
my $starter_ident = $gen_ident->($starter);
|
||||
foreach my $file (@_) {
|
||||
foreach my $file (@files) {
|
||||
if ($gen_ident->($file) ne $starter_ident) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -47,7 +47,8 @@ sub are_hardlinked {
|
|||
}
|
||||
|
||||
sub file_exists {
|
||||
foreach my $file (@_) {
|
||||
my @files = @_;
|
||||
foreach my $file (@files) {
|
||||
unless (-e $file) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -56,12 +57,13 @@ sub file_exists {
|
|||
}
|
||||
|
||||
sub filemtime {
|
||||
(stat shift)[9];
|
||||
my $file = shift;
|
||||
return (stat $file)[9];
|
||||
}
|
||||
|
||||
sub has_mtime {
|
||||
my $mtime = shift;
|
||||
foreach my $file (@_) {
|
||||
my ($mtime, @files) = @_;
|
||||
foreach my $file (@files) {
|
||||
if (filemtime($file) != $mtime) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -96,7 +98,8 @@ sub prep_tar {
|
|||
}
|
||||
|
||||
sub run_script_capture {
|
||||
my @cmd =(SCRIPT, @_);
|
||||
my @args = @_;
|
||||
my @cmd = (SCRIPT, @args);
|
||||
|
||||
use IPC::Open3 qw/ open3 /;
|
||||
my $stderr = File::Temp->new(
|
||||
|
@ -123,8 +126,9 @@ sub run_script_capture {
|
|||
}
|
||||
|
||||
sub run_script {
|
||||
print STDERR '+ ' . SCRIPT . " @_\n";
|
||||
system SCRIPT, @_;
|
||||
my @args = @_;
|
||||
print STDERR '+ ' . SCRIPT . " @args\n";
|
||||
return system SCRIPT, @args;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -17,8 +17,9 @@ my (undef, $stdout, $stderr) = run_script_capture('-f', $test_dir);
|
|||
ok "freed 1,048,576 bytes (1 MB)\n" eq $stderr, 'prints freed bytes with commas';
|
||||
|
||||
sub put_file {
|
||||
my @files = @_;
|
||||
my $bytes = 1048576; # 1 MB
|
||||
foreach my $file (@_) {
|
||||
foreach my $file (@files) {
|
||||
open my $fh, '>', $file
|
||||
or die "Failed to open file $file for writing: $!";
|
||||
for (my $bytes_written = 0; $bytes_written < $bytes; ++$bytes_written) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue