Sets the React Filesystem instance, or disables it.
@param \React\Filesystem\FilesystemInterface|null  $filesystem
@return void
770944
static function setFilesystem(?\React\Filesystem\FilesystemInterface $filesystem) {
        if($filesystem === null) {
            $filesystem = false;
        }
        
        self::$filesystem = $filesystem;
    }
169591
public function handle(Filesystem $filesystem)
    {
        $this->filesystem = $filesystem;

        $this->extensionDir = config('admin.extension_dir');

        InputExtensionDir:
        if (empty($this->extensionDir)) {
            $this->extensionDir = $this->ask('Please input a directory to store your extension:');
        }

        if (!file_exists($this->extensionDir)) {
            $this->makeDir();
        }

        $this->package = $this->argument('extension');

        InputExtensionName:
        if (!$this->validateExtensionName($this->package)) {
            $this->package = $this->ask("[$this->package] is not a valid package name, please input a name like (<vendor>/<name>)");
            goto InputExtensionName;
        }

        $this->makeDirs();
        $this->makeFiles();

        $this->info("The extension scaffolding generated successfully. \r\n");
        $this->showTree();
    }
625453
public static function configureAsRoot(): void
    {
        $filesystem = new Filesystem();
        $vendor_dir = Path::VENDOR_DIR . '/hostnet/phpcs-tool/src';
        if ($filesystem->exists($vendor_dir)) {
            return;
        }

        self::configure();

        $filesystem->mkdir($vendor_dir . '/Hostnet');
        $filesystem->symlink(__DIR__ . '/../../Sniffs', $vendor_dir . '/Hostnet/Sniffs');
        $filesystem->copy(__DIR__ . '/../../ruleset.xml', $vendor_dir . '/Hostnet/ruleset.xml');

        $filesystem->mkdir($vendor_dir . '/HostnetPaths');
        $filesystem->copy(__DIR__ . '/../../../HostnetPaths/ruleset.xml', $vendor_dir . '/HostnetPaths/ruleset.xml');
    }
713848
public function setMacrosCode($MacrosCode = null)
    {
        $this->macrosCode=$MacrosCode;
        $this->setHasMacros(!is_null($MacrosCode));
    }
326059
public function rename($from, $to)
	{
		// If native FTP support is enabled let's use it...
		if (FTP_NATIVE)
		{
			if (@ftp_rename($this->conn, $from, $to) === false)
			{
				throw new FilesystemException(__METHOD__ . 'Bad response.');
			}

			return true;
		}

		// Send rename from command to the server
		if (!$this->_putCmd('RNFR ' . $from, 350))
		{
			throw new FilesystemException(
				sprintf('%1$s: Bad response.  Server response: %2$s [Expected: 350].  From path sent: %3$s', __METHOD__, $this->response, $from)
			);
		}

		// Send rename to command to the server
		if (!$this->_putCmd('RNTO ' . $to, 250))
		{
			throw new FilesystemException(
				sprintf('%1$s: Bad response.  Server response: %2$s [Expected: 250].  To path sent: %3$s', __METHOD__, $this->response, $to)
			);
		}

		return true;
	}
962587
public function save(File $file, $filename = null)
    {
        if ($filename !== null) {
            $file->setFilename($filename);
        }

        $this->filesystem->write($file);
    }
1152304
public function setVisibility($path, $visibility)
    {
        $this->filesystem->setVisibility(
            $this->path($path),
            $visibility
        );
    }
332815
private function createTemplates(FileSystemInterface $fileSystem, array $templateOutputs): void
    {
        // before making any changes in the filesystem we have to check there is a good chance we can make it
        foreach ($templateOutputs as $templateOutput) {
            if ($fileSystem->exists($templateOutput->getOutputRootFolder()) === false) {
                $rootFolder = $templateOutput->getOutputRootFolder();
                throw new InvalidArgumentException("Folder `$rootFolder` do not exist.");
            }

            if ($fileSystem->exists($templateOutput->getOutputPath()) === true) {
                $filePath = $templateOutput->getOutputPath();
                throw new InvalidArgumentException("File `$filePath` already exists.");
            }

            $outFolder = $templateOutput->getOutputFolder();
            if ($fileSystem->exists($outFolder) === true) {
                // the folder already exist so we have to check it is writable
                if ($fileSystem->isWritable($outFolder) === false) {
                    throw new InvalidArgumentException("Folder `$outFolder` is not writable.");
                }
            } else {
                // it should be a root folder with not yet existing sub-folder so root should be writable
                $rootFolder = $templateOutput->getOutputRootFolder();
                if ($fileSystem->isWritable($rootFolder) === false) {
                    throw new InvalidArgumentException("Folder `$rootFolder` is not writable.");
                }
            }
        }

        foreach ($templateOutputs as $templateOutput) {
            if ($fileSystem->exists($templateOutput->getOutputFolder()) === false) {
                $fileSystem->createFolder($templateOutput->getOutputFolder());
            }
            $fileSystem->write($templateOutput->getOutputPath(), $templateOutput->getOutputContent());
        }
    }
1356017
protected function createParentDirectory(Filesystem $filesystem, $directory)
    {
        if (! $filesystem->isDirectory($directory)) {
            $filesystem->makeDirectory($directory, 0755, true);
        }
    }
1186406
protected static function init(): void
    {
        if (!static::$initialized) {
            $baseClass = Base::getInstance();
            static::$initialized = true;
            static::$newDirectoryMode = \octdec((string)$baseClass->Filesystem->newDirectoryMode);
            static::$newFileMode = \octdec((string)$baseClass->Filesystem->newFileMode);
            static::$writeLocks = (boolean)$baseClass->Filesystem->writeLocks;
            static::$hashFileDir = $baseClass->parsePath((string)$baseClass->Filesystem->hashFileDirectory);
            static::$hashFileDirDepth = (int)$baseClass->Filesystem->hashFileDirectoryDepth;
            static::$documentRoot = $baseClass->parsePath('%DOCUMENT_ROOT%').DIRECTORY_SEPARATOR;
        }
    }
329895
public static function emptyDirectory(string $directory): void
    {
        if (is_dir($directory)) {
            foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST) as $path) {
                if ($path->isFile()) {
                    if (!unlink($path->getPathname())) {
                        throw new FilesystemException("Unable to empty directory while emptying directory on path={$path->getPathname()}");
                    }
                } else {
                    if (!rmdir($path->getPathname())) {
                        throw new FilesystemException("Unable to empty directory while emptying directory on path={$path->getPathname()}");
                    }
                }
            }
        }
    }
194712
public function reinit()
	{
		// If native FTP support is enabled let's use it...
		if (FTP_NATIVE)
		{
			if (@ftp_site($this->conn, 'REIN') === false)
			{
				throw new FilesystemException(__METHOD__ . 'Bad response.');
			}

			return true;
		}

		// Send reinitialise command to the server
		if (!$this->_putCmd('REIN', 220))
		{
			throw new FilesystemException(sprintf('%1$s: Bad response.  Server response: %2$s [Expected: 220]', __METHOD__, $this->response));
		}

		return true;
	}
1175319
private static function initialize(string $storage): void
    {
        if (self::$path === null) {
            throw new \Exception('Path not set.');
        }
        if (self::lifetime(null, $storage) === 0) {
            throw new \Exception('Lifetime not set.');
        }
        Directory::make(self::$path . '/' . $storage);
    }
507014
public static function mkdir(string $path, $chmod = null): void
    {
        if (!is_dir($path)) {
            if ($chmod === null) {
                $chmod = Application::getConfig('application')->getArrayItem('filesystem', 'default_chmod', 0644);
            }

            if (!mkdir($path, $chmod, true)) {
                throw new FilesystemException("Can not create directory on path={$path}");
            }
        }
    }
290357
public function setWorkspace(Workspace $workspace = null)
    {
        if ($this->workspace !== $workspace) {
            $this->workspace = $workspace;
            $this->addOrUpdate();
        }
    }
1282073
public function handle(Filesystem $filesystem, AddonEnvironment $env)
    {
        // make addons/
        $addonsDirectory = $env->path();
        if (!$filesystem->exists($addonsDirectory)) {
            $filesystem->makeDirectory($addonsDirectory);
        }

        // copy app/config/addon.php
        $addonConfigSourceFile = __DIR__.'/../../config/addon.php';
        $addonConfigFile = $this->laravel['path.config'].'/addon.php';
        if (!$filesystem->exists($addonConfigFile)) {
            $filesystem->copy($addonConfigSourceFile, $addonConfigFile);

            $this->info('make config: '.$addonConfigFile);
        }

        // show lists
        $addons = $env->addons();
        foreach ($addons as $addon) {
            $this->dump($addon);
        }
    }
1149906
public function deletePath(FilesystemInterface $filesystem, $path)
    {
        $success = false;
        try {
            $success = $filesystem->delete($path);
        } catch (FileNotFoundException $e) {
            // TODO: log this?
        }

        return $success;
    }