/** * {@inheritdoc} */ public function getFilePlugin(File $file) { if ($file->internalPathname()->localAdapter() instanceof LinkAwareAdapterInterface) { return new LinkFilePlugin($file); } return null; }
/** * @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); }
/** * 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; }
/** * 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(); } }
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); }
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()); }
/** * 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; }