PHP Classes

The unzipAll Method - Error Checking

Recommend this page to a friend!

      dUnzip2  >  All threads  >  The unzipAll Method - Error Checking  >  (Un) Subscribe thread alerts  
Subject:The unzipAll Method - Error Checking
Summary:The unzipAll Method - Error Checking
Messages:1
Author:Chad Sikorra
Date:2012-01-13 04:04:37
 

  1. The unzipAll Method - Error Checking   Reply   Report abuse  
Picture of Chad Sikorra Chad Sikorra - 2012-01-13 04:04:37
Would it be possible to add error checking to the unzipAll method? It currently does both mkdir and chmod but makes the assumption that both worked. Something like the following diff...

if (!mkdir("$targetDir/$str")) {
$this->debugMsg(2, "Failed to create directory: $targertDir/$str");
return false;
}
if($applyChmod) {
if (!chmod("$targetDir/$str", $applyChmod)) {
$this->debugMsg(2, "Failed to apply permission ($applyChmod) to: $targertDir/$str");
return false;
}
}

And later on...


$unzip_result = $maintainStructure ?
$this->unzip($fileName, "$targetDir/$fileName", $applyChmod):
$this->unzip($fileName, "$targetDir/".basename($fileName), $applyChmod);

if ($unzip_result === false) {
$this->debugMsg(2, "Failed to unzip file from archive: $filename");
return false;
}

And at the end of the method return true.