Merge pull request #1873 from lioncash/const

loaders: Make GetFileType() a const qualified member function
This commit is contained in:
bunnei 2018-12-07 18:15:30 -05:00 committed by GitHub
commit f85134021f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 25 additions and 19 deletions

View File

@ -33,7 +33,7 @@ public:
*/ */
static FileType IdentifyType(const FileSys::VirtualFile& file); static FileType IdentifyType(const FileSys::VirtualFile& file);
FileType GetFileType() override { FileType GetFileType() const override {
return IdentifyType(file); return IdentifyType(file);
} }

View File

@ -22,7 +22,7 @@ public:
*/ */
static FileType IdentifyType(const FileSys::VirtualFile& file); static FileType IdentifyType(const FileSys::VirtualFile& file);
FileType GetFileType() override { FileType GetFileType() const override {
return IdentifyType(file); return IdentifyType(file);
} }

View File

@ -131,7 +131,7 @@ public:
* Returns the type of this file * Returns the type of this file
* @return FileType corresponding to the loaded file * @return FileType corresponding to the loaded file
*/ */
virtual FileType GetFileType() = 0; virtual FileType GetFileType() const = 0;
/** /**
* Load the application and return the created Process instance * Load the application and return the created Process instance

View File

@ -37,7 +37,7 @@ FileType AppLoader_NAX::IdentifyType(const FileSys::VirtualFile& file) {
return IdentifyTypeImpl(nax); return IdentifyTypeImpl(nax);
} }
FileType AppLoader_NAX::GetFileType() { FileType AppLoader_NAX::GetFileType() const {
return IdentifyTypeImpl(*nax); return IdentifyTypeImpl(*nax);
} }

View File

@ -31,7 +31,7 @@ public:
*/ */
static FileType IdentifyType(const FileSys::VirtualFile& file); static FileType IdentifyType(const FileSys::VirtualFile& file);
FileType GetFileType() override; FileType GetFileType() const override;
ResultStatus Load(Kernel::Process& process) override; ResultStatus Load(Kernel::Process& process) override;

View File

@ -29,7 +29,7 @@ public:
*/ */
static FileType IdentifyType(const FileSys::VirtualFile& file); static FileType IdentifyType(const FileSys::VirtualFile& file);
FileType GetFileType() override { FileType GetFileType() const override {
return IdentifyType(file); return IdentifyType(file);
} }

View File

@ -33,7 +33,7 @@ public:
*/ */
static FileType IdentifyType(const FileSys::VirtualFile& file); static FileType IdentifyType(const FileSys::VirtualFile& file);
FileType GetFileType() override { FileType GetFileType() const override {
return IdentifyType(file); return IdentifyType(file);
} }

View File

@ -37,7 +37,7 @@ public:
*/ */
static FileType IdentifyType(const FileSys::VirtualFile& file); static FileType IdentifyType(const FileSys::VirtualFile& file);
FileType GetFileType() override { FileType GetFileType() const override {
return IdentifyType(file); return IdentifyType(file);
} }

View File

@ -31,7 +31,7 @@ public:
*/ */
static FileType IdentifyType(const FileSys::VirtualFile& file); static FileType IdentifyType(const FileSys::VirtualFile& file);
FileType GetFileType() override { FileType GetFileType() const override {
return IdentifyType(file); return IdentifyType(file);
} }

View File

@ -31,7 +31,7 @@ public:
*/ */
static FileType IdentifyType(const FileSys::VirtualFile& file); static FileType IdentifyType(const FileSys::VirtualFile& file);
FileType GetFileType() override { FileType GetFileType() const override {
return IdentifyType(file); return IdentifyType(file);
} }

View File

@ -99,12 +99,14 @@ QList<QStandardItem*> MakeGameListEntry(const std::string& path, const std::stri
compatibility = it->second.first; compatibility = it->second.first;
} }
const auto file_type = loader.GetFileType();
const auto file_type_string = QString::fromStdString(Loader::GetFileTypeString(file_type));
QList<QStandardItem*> list{ QList<QStandardItem*> list{
new GameListItemPath( new GameListItemPath(FormatGameName(path), icon, QString::fromStdString(name),
FormatGameName(path), icon, QString::fromStdString(name), file_type_string, program_id),
QString::fromStdString(Loader::GetFileTypeString(loader.GetFileType())), program_id),
new GameListItemCompat(compatibility), new GameListItemCompat(compatibility),
new GameListItem(QString::fromStdString(Loader::GetFileTypeString(loader.GetFileType()))), new GameListItem(file_type_string),
new GameListItemSize(FileUtil::GetSize(path)), new GameListItemSize(FileUtil::GetSize(path)),
}; };
@ -196,12 +198,16 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign
const bool is_dir = FileUtil::IsDirectory(physical_name); const bool is_dir = FileUtil::IsDirectory(physical_name);
if (!is_dir && if (!is_dir &&
(HasSupportedFileExtension(physical_name) || IsExtractedNCAMain(physical_name))) { (HasSupportedFileExtension(physical_name) || IsExtractedNCAMain(physical_name))) {
std::unique_ptr<Loader::AppLoader> loader = auto loader = Loader::GetLoader(vfs->OpenFile(physical_name, FileSys::Mode::Read));
Loader::GetLoader(vfs->OpenFile(physical_name, FileSys::Mode::Read)); if (!loader) {
if (!loader || ((loader->GetFileType() == Loader::FileType::Unknown ||
loader->GetFileType() == Loader::FileType::Error) &&
!UISettings::values.show_unknown))
return true; return true;
}
const auto file_type = loader->GetFileType();
if ((file_type == Loader::FileType::Unknown || file_type == Loader::FileType::Error) &&
!UISettings::values.show_unknown) {
return true;
}
std::vector<u8> icon; std::vector<u8> icon;
const auto res1 = loader->ReadIcon(icon); const auto res1 = loader->ReadIcon(icon);