Example #1
0
 /**
  * @param string|null $pathPrefix
  * @param int|null    $mode
  */
 public function __construct($pathPrefix = null, $mode = null)
 {
     parent::__construct($pathPrefix);
     if (null === $mode) {
         $mode = 0777;
     }
     $this->_mode = (int) $mode;
 }
Example #2
0
 /**
  * @param string $pathPrefix
  */
 public function deleteByPrefix($pathPrefix)
 {
     $pathList = $this->_adapter->listByPrefix($pathPrefix);
     foreach ($pathList['files'] as $pathFile) {
         $this->delete($pathFile);
     }
     foreach ($pathList['dirs'] as $pathDir) {
         $this->delete($pathDir);
     }
     foreach ($this->_secondaryList as $secondary) {
         $secondary->deleteByPrefix($pathPrefix);
     }
 }
Example #3
0
 protected function _getAbsolutePath($pathRelative)
 {
     $path = parent::_getAbsolutePath($pathRelative);
     return ltrim($path, '/');
 }
Example #4
0
 /**
  * @param CM_File                    $file
  * @param CM_File_Filesystem_Adapter $adapterSource
  * @param CM_File_Filesystem_Adapter $adapterDestination
  * @throws CM_Exception
  */
 protected function _copyToFileStreaming(CM_File $file, CM_File_Filesystem_Adapter $adapterSource, CM_File_Filesystem_Adapter $adapterDestination)
 {
     /** @var CM_File_Filesystem_Adapter_StreamInterface $adapterSource */
     /** @var CM_File_Filesystem_Adapter_StreamInterface $adapterDestination */
     $streamSource = $adapterSource->getStreamRead($this->getPath());
     $adapterDestination->writeStream($file->getPath(), $streamSource);
     $sizeDestination = $file->getSize();
     $sizeSource = $this->getSize();
     if ($sizeSource !== $sizeDestination) {
         throw new CM_Exception('Copy failed', null, ['Source' => $this->getPath(), 'Destination' => $file->getPath(), 'Original size' => $sizeSource, 'Bytes copied' => $sizeDestination, 'Source adapter' => get_class($adapterSource), 'Destination adapter' => get_class($adapterDestination)]);
     }
     if (is_resource($streamSource) && !@fclose($streamSource)) {
         throw new CM_Exception('Could not close stream for path', null, ['path' => $this->getPath(), 'Source adapter' => get_class($adapterSource)]);
     }
 }