Don't check validity twice when creating DirectoryBlob

This commit is contained in:
JosJuice 2017-06-09 12:56:36 +02:00
parent a6bbf7e21b
commit 251828ccc0
3 changed files with 3 additions and 12 deletions

View File

@ -203,8 +203,8 @@ std::unique_ptr<BlobReader> CreateBlobReader(const std::string& filename)
case WBFS_MAGIC:
return WbfsFileReader::Create(std::move(file), filename);
default:
if (DirectoryBlobReader::IsValidDirectoryBlob(filename))
return DirectoryBlobReader::Create(filename);
if (auto directory_blob = DirectoryBlobReader::Create(filename))
return std::move(directory_blob);
return PlainFileReader::Create(std::move(file));
}

View File

@ -137,8 +137,7 @@ static bool PathEndsWith(const std::string& path, const std::string& suffix)
return true;
}
bool DirectoryBlobReader::IsValidDirectoryBlob(const std::string& dol_path,
std::string* root_directory)
static bool IsValidDirectoryBlob(const std::string& dol_path, std::string* root_directory)
{
if (!PathEndsWith(dol_path, "/sys/main.dol"))
return false;
@ -149,12 +148,6 @@ bool DirectoryBlobReader::IsValidDirectoryBlob(const std::string& dol_path,
return File::GetSize(*root_directory + "sys/boot.bin") >= 0x20;
}
bool DirectoryBlobReader::IsValidDirectoryBlob(const std::string& dol_path)
{
std::string root_directory;
return IsValidDirectoryBlob(dol_path, &root_directory);
}
std::unique_ptr<DirectoryBlobReader> DirectoryBlobReader::Create(const std::string& dol_path)
{
std::string root_directory;

View File

@ -55,8 +55,6 @@ private:
class DirectoryBlobReader : public BlobReader
{
public:
static bool IsValidDirectoryBlob(const std::string& dol_path, std::string* root_directory);
static bool IsValidDirectoryBlob(const std::string& dol_path);
static std::unique_ptr<DirectoryBlobReader> Create(const std::string& dol_path);
// We do not allow copying, because it might mess up the pointers inside DiscContents