public function ensureDirectoryExists($directory, $create = false)
    {
        if (!is_dir($directory)) {
            if (!$create) {
                throw new StorageException(StorageException::DIRECTORY_DOES_NOT_EXIST, [$directory]);
            }
            $this->createDirectory($directory);
        }
    }