Creates a Memory adapter from a Flysystem filesystem.

@param FilesystemInterface $filesystem The Flysystem filesystem.

@return self A new memory adapter.
546796
public static function createFromFilesystem(FilesystemInterface $filesystem)
    {
        $filesystem->addPlugin(new ListWith());

        $adapter = new static();
        $config = new Config();

        foreach ($filesystem->listWith(['timestamp', 'visibility'], '', true) as $meta) {
            if ($meta['type'] === 'dir') {
                $adapter->createDir($meta['path'], $config);
                continue;
            }

            $adapter->write($meta['path'], (string) $filesystem->read($meta['path']), $config);
            $adapter->setVisibility($meta['path'], $meta['visibility']);
            $adapter->setTimestamp($meta['path'], $meta['timestamp']);
        }

        return $adapter;
    }
603525
protected function createFlysystem(AdapterInterface $adapter, array $config)
    {
        if (class_exists('League\Flysystem\EventableFilesystem\EventableFilesystem')) {
            $fsClass = \League\Flysystem\EventableFilesystem\EventableFilesystem::class;
        } else {
            $fsClass = \League\Flysystem\Filesystem::class;
        }

        if (class_exists('League\Flysystem\Cached\CachedAdapter')) {
            $adapter = $this->decorateWithCachedAdapter($adapter, Arr::get($config, 'cache', []));
        }

        $config = Arr::only($config, ['visibility']);

        return new $fsClass($adapter, count($config) > 0 ? $config : null);
    }
920623
public function rebuild($fileName, $context, FilesystemAdapter $filesystemAdapter)
    {
        // Open original file
        $originalImage = $filesystemAdapter->get('/' . $context . '/' . $fileName);
        $originalImage = $this->openImageHandler->loadImage($originalImage);
        $extension = $this->findExtension($fileName);

        // Rebuild sizes
        $this->deleteSizes($fileName, $context, $filesystemAdapter);
        $this->fileManager->setFileSystemAdapter($filesystemAdapter);
        $this->processSizes($originalImage, $fileName, $context, $extension, $filesystemAdapter);

        return true;
    }
128246
public function writeFile(FilesystemInterface $filesystem, $file, $path)
    {
        $stream = @fopen($file, 'r');
        if ($stream === false) {
            return false;
        }

        $success = false;
        $tempPath = $path . '.temp';
        $this->deletePath($filesystem, $tempPath);
        if ($filesystem->writeStream($tempPath, $stream)) {
            $this->deletePath($filesystem, $path);
            $success = $filesystem->rename($tempPath, $path);
        }
        $this->deletePath($filesystem, $tempPath);
        is_resource($stream) && fclose($stream);

        return $success;
    }
836771
public function getFilesystem($filesystemName)
    {
        if (!array_key_exists($filesystemName, $this->filesystemMap)) {
            throw new NoSuchFilesystemException($filesystemName);
        }

        return $this->filesystemMap[$filesystemName];
    }
568461
public function setPublicFilesystem(Filesystem $filesystem)
    {
        if (!$filesystem->getAdapter() instanceof PublicAdapter) {
            throw new InvalidArgumentException("Configured adapter must implement PublicAdapter");
        }
        $this->publicFilesystem = $filesystem;
        return $this;
    }
1356017
protected function createParentDirectory(Filesystem $filesystem, $directory)
    {
        if (! $filesystem->isDirectory($directory)) {
            $filesystem->makeDirectory($directory, 0755, true);
        }
    }
351594
public function create($path)
	{
		// If native FTP support is enabled let's use it...
		if (FTP_NATIVE)
		{
			// Turn passive mode on
			if (@ftp_pasv($this->conn, true) === false)
			{
				throw new FilesystemException(__METHOD__ . ': Unable to use passive mode.');
			}

			$buffer = fopen('buffer://tmp', 'r');

			if (@ftp_fput($this->conn, $path, $buffer, FTP_ASCII) === false)
			{
				fclose($buffer);

				throw new FilesystemException(__METHOD__ . 'Bad response.');
			}

			fclose($buffer);

			return true;
		}

		// Start passive mode
		if (!$this->_passive())
		{
			throw new FilesystemException(__METHOD__ . ': Unable to use passive mode.');
		}

		if (!$this->_putCmd('STOR ' . $path, array(150, 125)))
		{
			@ fclose($this->dataconn);

			throw new FilesystemException(
				sprintf('%1$s: Bad response.  Server response: %2$s [Expected: 150 or 125].  Path sent: %3$s', __METHOD__, $this->response, $path)
			);
		}

		// To create a zero byte upload close the data port connection
		fclose($this->dataconn);

		if (!$this->_verifyResponse(226))
		{
			throw new FilesystemException(
				sprintf('%1$s: Transfer failed.  Server response: %2$s [Expected: 226].  Path sent: %3$s', __METHOD__, $this->response, $path)
			);
		}

		return true;
	}
1211047
protected function getFilesystem()
	{
		if (!isset($this->filesystem)) {
			$this->filesystem = new Filesystem($this->getAdapter());
		}
		return $this->filesystem;
	}
1223004
public function file($path, $createMissing = false)
    {
        if (! $this->adapter->isAbsolute($path)) {
            $path = $this->rootPath . $path;
        }
        if (! $createMissing && ! $this->isFile($path, true)) {
            throw new FilesystemException("Cannot find the file '{$path}'");
        }

        return new File($path, $this->adapter);
    }
1315493
public function _inject(Cli $cli, Filesystem $filesystem)
    {
        $this->cli        = $cli;
        $this->filesystem = $filesystem;
    }
809365
protected function createFileReader()
    {
        try {
            $this->createFlysystemAdapter();
        } catch (\Exception $e) {
            throw new ConfiguratorException(
                'Error: Unable to Initialize the Flysystem File reader with the arguments supplied',
                $code = 1,
                $previous = $e
            );
        }
        try {
            $this->fileReader = new Filesystem($this->flysystemAdapter);
        } catch (\Exception $e) {
            throw new ConfiguratorException(
                'Error: Unable to Initialize the Flysystem File reader with the arguments supplied',
                $code = 1,
                $previous = $e
            );
        }
    }
551650
public function set($domain, FilesystemInterface $filesystem)
    {
        if (!preg_match('/^[-_a-zA-Z0-9]+$/', $domain)) {
            throw new \InvalidArgumentException(sprintf(
                'The specified domain "%s" is not a valid domain.',
                $domain
            ));
        }

        $this->filesystems[$domain] = $filesystem;
    }
1363042
protected static function addPlugins(FilesystemInterface $filesystem)
    {
        foreach ([
            new EmptyDir(),
            new GetWithMetadata(),
            new ListFiles(),
            new ListPaths(),
            new ListWith(),
        ] as $plugin) {
            $plugin->setFilesystem($filesystem);
            $filesystem->addPlugin($plugin);
        }
        return $filesystem;
    }
71546
protected function buildMigrations(\FilesystemIterator $directory)
    {
        foreach ($directory as $fileInfo) {
            /* @var $fileInfo \SplFileInfo */
            if ($fileInfo->isDir()) {
                $subDirectory = new \FilesystemIterator($fileInfo->getRealPath());
                $this->buildFromSubDirectory($subDirectory);
            }
        }
        $this->sort();
    }
101753
private function getDefaultCacheAdapter()
    {
        return new FileSystemCacheAdapter(
            $this->config->getCachePath(),
            $this->config->getFileLock(),
            $this->config->getMinCacheFileSize()
        );
    }
1195711
protected function createLaravelAdapter(array $args=[])
    {
        if(!$this->app->bound('filedb.filesystem')) {
            return new FilesystemAdapter($this->createFlysystem($args));
        }

        $adapter = $this->app->make('filedb.filesystem');

        if ($adapter instanceof \Illuminate\Contracts\Filesystem\Filesystem) {
            return $adapter;
        }

        throw new TypeException("The binding behind filedb.filesystem implement Filesystem interface not " . Type::of($adapter));

    }