@param Bag $fileSystem

@return string
355808
private function getFolderName(Bag $fileSystem)
    {
        if ($fileSystem->has('label')) {
            return $fileSystem->get('label');
        }

        return sprintf('%s://%s', $fileSystem->get('name'), $fileSystem->get('folder'));
    }
1359897
private function isWritable(Bag $fileSystem, $filePath)
    {
        /** @var \Bolt\Filesystem\FilesystemInterface $fs */
        $fs = $this->app['filesystem']->getFilesystem($fileSystem->get('name'));

        $filePath = $fileSystem->get('folder') . '/' . $filePath;

        try {
            $fs->put($filePath, 'ok');
            $contents = $fs->read($filePath);
            $fs->delete($filePath);
        } catch (\Exception $e) {
            return false;
        }

        return $contents;
    }
185617
protected function createPath(Filesystem $filesystem, $type)
    {
        $customPath = $this->option('path');

        $defaultPath = config("vue-generators.paths.{$type}s");

        $path = $customPath !== null ? $customPath : $defaultPath;

        $this->buildPathFromArray($path, $filesystem);

        return $path;
    }
72773
private static function canonicalize(string $base, string ...$dirs): string
    {
        $path = $base.'/'.implode('/', $dirs);
        $replace = ['#(/\.?/)#', '#/(?!\.\.)[^/]+/\.\./#'];

        do {
            $path = preg_replace($replace, '/', $path, -1, $n);
        } while ($n > 0);

        return $path;
    }
56340
protected function getFiles(FileBag $bag)
    {
        $files = [];
        $fileBag = $bag->all();
        $fileIterator = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($fileBag), \RecursiveIteratorIterator::SELF_FIRST);

        foreach ($fileIterator as $file) {
            if (is_array($file) || null === $file) {
                continue;
            }

            $files[] = $file;
        }

        return $files;
    }
664862
public function getFileSystem()
    {
        if (null == $this->fileSystem) {
            $this->setFileSystem(Helper::getFileSystem());
        }

        return $this->fileSystem;
    }
318749
public function disks($parse = true)
    {
        if ($this->host_os !== 'WINDOWS') {
            $result = shell_exec('df -h --output=source,fstype,size,used,avail,pcent,target -x tmpfs -x devtmpfs');
        } else {
            $result = '';
        }

        if ($parse) {
            if (empty($result)) {
                return [];
            }

            $lines = explode(PHP_EOL, trim($result));
            unset($lines[0]);

            $columns = [
                'Filesystem',
                'Type',
                'Size',
                'Used',
                'Avail',
                'Used (%)',
                'Mounted'
            ];

            $result = [];
            foreach ($lines as $row => $line) {
                $column = array_values(array_filter(explode(' ', $line), 'strlen'));
                foreach ($columns as $col => $key) {
                    $result[$row][$key] = @$column[$col];
                }
            }
            $result = array_values($result);
        }
        return $result;
    }
1283269
public function deleteOldWebtreesFiles(Filesystem $filesystem): array
    {
        $paths_to_delete = [];

        foreach (self::OLD_PATHS as $path) {
            if (!$this->deleteFileOrFolder($filesystem, $path)) {
                $paths_to_delete[] = $path;
            }
        }

        return $paths_to_delete;
    }
788998
public function mountFileSystems(array $fileSystems = []): self
    {
        foreach ($fileSystems as $prefix => $fileSystem) {
            $this->mountFileSystem($prefix, $fileSystem);
        }

        return $this;
    }
828461
protected function getFileSystem()
    {
        if (null === $this->filesystem) {
            /** @var FileSystemService $fileSystemService */
            $fileSystemService = $this->getServiceManager()->get(FileSystemService::SERVICE_ID);
            $this->filesystem = $fileSystemService->getFileSystem($this->getOption(self::OPTION_FILESYSTEM));
        }

        return $this->filesystem;
    }
714139
private function getSosaName(int $sosa): string
    {
        $path = '';

        while ($sosa > 1) {
            if ($sosa % 2 === 1) {
                $path = 'mot' . $path;
            } else {
                $path = 'fat' . $path;
            }
            $sosa = intdiv($sosa, 2);
        }

        return Functions::getRelationshipNameFromPath($path);
    }
102510
private function cacheDirectory(): string
    {
        $cacheDirectory = (string) $this->cacheDirectory;

        if ('' === $cacheDirectory && false === \is_writable($cacheDirectory))
        {
            $cacheDirectory = \sys_get_temp_dir();
        }

        return \rtrim($cacheDirectory, '/');
    }
1308467
public function mountFilesystem($prefix, FilesystemInterface $filesystem)
    {
        if ( ! is_string($prefix)) {
            throw new InvalidArgumentException(__METHOD__ . ' expects argument #1 to be a string.');
        }

        $this->filesystems[$prefix] = $filesystem;

        return $this;
    }
1061320
protected function getFilesystem($ident)
    {
        if (isset($this->filesystems[$ident])) {
            return $this->filesystems[$ident];
        }

        return null;
    }
131892
public function getFileSystem(string $prefix): FileSystem
    {
        if (! isset($this->fs[$prefix])) {
            throw new InvalidArgumentException(
                sprintf('The filesystem was not found: "%s"', $prefix)
            );
        }

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

        return $this->filesystemMap[$filesystemName];
    }
261931
public function getRealFileSize($fileSize)
    {
        //B goes at the end because it's always matched otherwise
        $validUnits = array('KB', 'MB', 'GB', 'TB');
        $value = str_replace(' ', '', $fileSize);

        $replacements = array('');
        $pattern = '/(\d+)/';
        $data = preg_grep($pattern, array($value));

        foreach ($validUnits as $unit) {
            if (strpos($fileSize, $unit)) {
                switch($unit) {
                    case 'B':
                        return $data[0] * pow(1024, 0);
                    case 'KB':
                        return $data[0] * pow(1024, 1);
                    case 'MB':
                        return $data[0] * pow(1024, 2);
                    case 'GB':
                        return $data[0] * pow(1024, 3);
                    case 'TB':
                        return $data[0] * pow(1024, 4);
                }
            }
        }

        return $fileSize;
    }