コード例 #1
0
ファイル: LinkPlugin.php プロジェクト: filicious/core
 /**
  * {@inheritdoc}
  */
 public function getFilePlugin(File $file)
 {
     if ($file->internalPathname()->localAdapter() instanceof LinkAwareAdapterInterface) {
         return new LinkFilePlugin($file);
     }
     return null;
 }
コード例 #2
0
ファイル: FilesystemIterator.php プロジェクト: filicious/core
 /**
  * @param \Filicious\File     $path
  * @param int|string|callable $_ List of flags, bitmask filters File::LIST_*, glob patterns or callables function($file) { return true|false; }
  */
 public function __construct(File $path, $_ = null)
 {
     $filters = func_get_args();
     foreach ($filters as $filter) {
         if (is_int($filter)) {
             if ($filter & static::CURRENT_AS_PATHNAME) {
                 $this->flags |= static::CURRENT_AS_PATHNAME;
             } else {
                 if ($filter & static::CURRENT_AS_BASENAME) {
                     $this->flags |= static::CURRENT_AS_BASENAME;
                 } else {
                     if ($filter & static::CURRENT_AS_FILE) {
                         $this->flags |= static::CURRENT_AS_FILE;
                     } else {
                         if ($filter & static::CURRENT_AS_SELF) {
                             $this->flags |= static::CURRENT_AS_SELF;
                         } else {
                             if ($filter & static::KEY_AS_PATHNAME) {
                                 $this->flags |= static::KEY_AS_PATHNAME;
                             } else {
                                 if ($filter & static::KEY_AS_FILENAME) {
                                     $this->flags |= static::KEY_AS_FILENAME;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     parent::__construct($path->internalPathname(), $filters);
 }
コード例 #3
0
ファイル: StreamWrapper.php プロジェクト: filicious/core
 /**
  * Change stream options
  *
  * @param string $path
  * @param int    $option
  * @param int    $var
  */
 public function stream_metadata($path, $option, $var)
 {
     $this->openFile($path);
     switch ($option) {
         case STREAM_META_TOUCH:
             $this->file->touch(isset($var[0]) ? $var[0] : null, isset($var[1]) ? $var[1] : null);
             return true;
         case STREAM_META_OWNER_NAME:
         case STREAM_META_OWNER:
             $this->file->setOwner($var);
             return true;
         case STREAM_META_GROUP_NAME:
         case STREAM_META_GROUP:
             $this->file->setGroup($var);
             return true;
         case STREAM_META_ACCESS:
             $this->file->setMode($var);
             return true;
     }
     return false;
 }
コード例 #4
0
ファイル: FTPFilesystem.php プロジェクト: filicious/ftp
 /**
  * Renames a file or directory
  *
  * @param File $destination
  *
  * @return bool
  */
 public function moveTo($file, File $destination)
 {
     if ($destination->getFilesystem() == $this) {
         // TODO: invalidate cache?
         return $this->ftpRename($file, $destination);
     } else {
         return Util::streamCopy($file, $destination) && $file->delete();
     }
 }
コード例 #5
0
 protected function addFile(File $file, $path, $stripBin = false)
 {
     $this->output->writeln(' <info>*</info> Add php file ' . $path);
     $content = $file->getContents();
     if ($stripBin) {
         $content = preg_replace('~^#!/usr/bin/env php\\s*~', '', $content);
         $content = str_replace('BundlerPackCommand', 'UpdateCommand', $content);
     }
     $this->phar->addFromString($path, $content);
 }
コード例 #6
0
ファイル: Util.php プロジェクト: filicious/core
 public static function streamCopy(File $source, File $target)
 {
     $sourceStream = $source->getStream();
     $sourceStream->open(new StreamMode('rb'));
     $targetStream = $target->getStream();
     $targetStream->open(new StreamMode('wb'));
     return (bool) stream_copy_to_stream($sourceStream->getRessource(), $targetStream->getRessource());
 }
コード例 #7
0
ファイル: PathnameIterator.php プロジェクト: filicious/core
 /**
  * Apply glob filters on current file.
  *
  * @param \Filicious\File $file
  *
  * @return bool
  */
 protected function applyGlobFilters(File $file)
 {
     foreach ($this->globs as $glob) {
         if (!fnmatch($glob, $file->getPathname())) {
             return false;
         }
     }
     return true;
 }