Пример #1
0
 /**
  * Open backup file (write or read mode)
  *
  * @param bool $write
  * @return Mage_Backup_Model_Backup
  * @throws Mage_Backup_Exception_NotEnoughPermissions
  */
 public function open($write = false)
 {
     if (is_null($this->getPath())) {
         Mage::exception('Mage_Backup', $this->_helper->__('Backup file path was not specified.'));
     }
     if ($write && $this->_filesystem->isFile($this->_getFilePath())) {
         $this->_filesystem->delete($this->_getFilePath());
     }
     if (!$write && !$this->_filesystem->isFile($this->_getFilePath())) {
         Mage::exception('Mage_Backup', $this->_helper->__('Backup file "%s" does not exist.', $this->getFileName()));
     }
     $mode = $write ? 'wb' . self::COMPRESS_RATE : 'rb';
     try {
         $compressStream = 'compress.zlib://';
         $workingDirectory = $this->_filesystem->getWorkingDirectory();
         $this->_stream = $this->_filesystem->createAndOpenStream($compressStream . $this->_getFilePath(), $mode, $compressStream . $workingDirectory);
     } catch (Magento_Filesystem_Exception $e) {
         throw new Mage_Backup_Exception_NotEnoughPermissions($this->_helper->__('Backup file "%s" cannot be read from or written to.', $this->getFileName()));
     }
     return $this;
 }
Пример #2
0
 public function testSetWorkingDirectory()
 {
     $filesystem = new Magento_Filesystem($this->_getDefaultAdapterMock());
     $filesystem->setWorkingDirectory('/tmp');
     $this->assertEquals('/tmp', $filesystem->getWorkingDirectory());
 }