Beispiel #1
0
         }
     } else {
         $downloadedFileName = $moduleHelper->downloadFile();
     }
     $pathInfo = pathinfo($downloadedFileName);
     $dirName = dirname($downloadedFileName) . '/' . $pathInfo['filename'];
     // wiping out the directory assuming it has no directories (but even if it does, who cares?)
     if (file_exists($dirName)) {
         $files = Vikont_Pulliver_Helper_Data::getDirectoryListing($dirName);
         foreach ($files as $file => $dummy) {
             @unlink($file);
         }
     } else {
         mkdir($dirName, 0755, true);
     }
     $unzippingResult = Vikont_Pulliver_Helper_Data::unZip($downloadedFileName, $dirName);
     if (true !== $unzippingResult) {
         Vikont_Pulliver_Helper_Data::throwException(sprintf('Error unzipping file %s to %s, result: %d', $downloadedFileName, $dirName, $unzippingResult));
     }
     $files = Vikont_Pulliver_Helper_Data::getDirectoryListing($dirName);
     if (isset($files['PriceFile_system_errors.txt'])) {
         Vikont_Pulliver_Helper_Data::throwException(sprintf('Error getting remote inventory: %s', file_get_contents($dirName . '/PriceFile_system_errors.txt')));
     }
     $priceFileName = 'BasePriceFile.csv';
     if (isset($files[$priceFileName])) {
         $inventoryFileName = $dirName . '/' . $priceFileName;
     } else {
         Vikont_Pulliver_Helper_Data::throwException(sprintf('No %s file found in the downloaded archive %s at %s', $priceFileName, $downloadedFileName, $dirName));
     }
 } else {
     Vikont_Pulliver_Helper_Data::inform(sprintf('Skipped downloading and extracting, using local file %s', $inventoryFileName));