Search code examples
perlziparchive

Suppress error: Can't chmod() in Archive::Zip


I am trying to extract some files using Archive::Zip. Everything is working fine. The files are being extracted with no issues. Here is the parth of the code:

my $zip = Archive::Zip->new($file);
foreach my $member ($zip->members) {
    next if $member->isDirectory;
    (my $extractName = $member->fileName) =~ s{.*/}{};
    $member->extractToFileNamed($unixPath{'Rdrive'}.$extractName);
}

I am getting the following warning when running the script:

error: Can't chmod() /test/test.txt: Operation not permitted

I was trying to find a way to suppress this message in Archive::Zip, but was not able to find any way to do it. I am not able to change the permissions of the server. What would be the best way to suppress this message?

Thank you, -Andrey


Solution

  • $member->unixFileAttributes(0644); does not seem to work because the files are being extracted on the network drive. I solved the problem by using:

    Archive::Zip::setErrorHandler( \&zipErrorHandler );