src/Storage/FileStorage.php
public static function preparePath($basePath, $path)
    {
        $basePath = rtrim($basePath, '/');
        $path = ltrim($path, '/');
        $fullPath = $basePath . '/' . $path;

        if (file_exists($fullPath)) {
            if (!is_dir($fullPath)) {
                throw new \RuntimeException("Cannot create a directory, regular file already exists: {$path}.");
            }
            if (!is_writable($fullPath)) {
                throw new \RuntimeException("Directory is not writable: {$path}.");
            }
        } else {
            $res=@mkdir($fullPath, 0770, true);
            if (!$res) {
                throw new \RuntimeException("Unable to create a directory: {$path}.");
            }
        }
    }
public static function preparePath($basePath, $path)
    {
        $basePath = rtrim($basePath, '/');
        $path = ltrim($path, '/');
        $fullPath = $basePath . '/' . $path;

        if (file_exists($fullPath)) {
            if (!is_dir($fullPath)) {
                throw new \RuntimeException("Cannot create a directory, regular file already exists: {$path}.");
            }
            if (!is_writable($fullPath)) {
                throw new \RuntimeException("Directory is not writable: {$path}.");
            }
        } else {
            $res=@mkdir($fullPath, 0770, true);
            if (!$res) {
                throw new \RuntimeException("Unable to create a directory: {$path}.");
            }
        }
    }
Prepares path

Check if $path relative to $basePath exists and is writable.
Attempts to create it if it does not exist. Warning is supressed
in case of mkdir failure.

@param string $basePath
@param string $path