Skip to content

Commit

Permalink
ar: 2-argument FileHandle->new
Browse files Browse the repository at this point in the history
  • Loading branch information
mknos authored Jan 3, 2024
1 parent ccd99ac commit 7bf8773
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions bin/ar
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ sub extractMember {
oct($attr->[4]), int($attr->[1]));
}

my $out = FileHandle->new(">$name") or die "$name: $!\n";
my $out = FileHandle->new($name, 'w') or die "$name: $!\n";
binmode($out);
$out->print($attr->[6]);
$out->close();
Expand All @@ -241,7 +241,7 @@ sub extractMember {
# [ undef, $modt, $uid, $gid, $mode, $sz, $data ]
sub readFile {
my ($file) = @_;
my $in = FileHandle->new("< $file") or die "$file: $!\n";
my $in = FileHandle->new($file, 'r') or die "$file: $!\n";
binmode($in);

# read the data in one swell foop
Expand All @@ -268,7 +268,7 @@ sub readAr {
# names in order in file
my @Names = ( undef );

my $arfh = FileHandle->new("< $archive") or die "$0: $archive: $!\n";
my $arfh = FileHandle->new($archive, 'r') or die "$0: $archive: $!\n";
binmode($arfh);

# read magic
Expand Down Expand Up @@ -332,11 +332,11 @@ sub writeAr {

my $arfh;
if (!defined($append)) {
$arfh = FileHandle->new("> $archive") or die "$0: $archive: $!\n";
$arfh = FileHandle->new($archive, 'w') or die "$0: $archive: $!\n";
$arfh->print("!<arch>\n");
}
else {
$arfh = FileHandle->new(">> $archive") or die "$0: $archive: $!\n";
$arfh = FileHandle->new($archive, 'a') or die "$0: $archive: $!\n";
}

# loop through each member of the archive and write to filehandle
Expand Down

0 comments on commit 7bf8773

Please sign in to comment.