Merge pull request #1873 from lioncash/const

loaders: Make GetFileType() a const qualified member function
merge-requests/60/head
bunnei 2018-12-07 18:15:30 +07: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

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

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

@ -131,7 +131,7 @@ public:
* Returns the type of this 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

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

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

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

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

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

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

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

@ -99,12 +99,14 @@ QList<QStandardItem*> MakeGameListEntry(const std::string& path, const std::stri
compatibility = it->second.first;
}
const auto file_type = loader.GetFileType();
const auto file_type_string = QString::fromStdString(Loader::GetFileTypeString(file_type));
QList<QStandardItem*> list{
new GameListItemPath(
FormatGameName(path), icon, QString::fromStdString(name),
QString::fromStdString(Loader::GetFileTypeString(loader.GetFileType())), program_id),
new GameListItemPath(FormatGameName(path), icon, QString::fromStdString(name),
file_type_string, program_id),
new GameListItemCompat(compatibility),
new GameListItem(QString::fromStdString(Loader::GetFileTypeString(loader.GetFileType()))),
new GameListItem(file_type_string),
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);
if (!is_dir &&
(HasSupportedFileExtension(physical_name) || IsExtractedNCAMain(physical_name))) {
std::unique_ptr<Loader::AppLoader> loader =
Loader::GetLoader(vfs->OpenFile(physical_name, FileSys::Mode::Read));
if (!loader || ((loader->GetFileType() == Loader::FileType::Unknown ||
loader->GetFileType() == Loader::FileType::Error) &&
!UISettings::values.show_unknown))
auto loader = Loader::GetLoader(vfs->OpenFile(physical_name, FileSys::Mode::Read));
if (!loader) {
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;
const auto res1 = loader->ReadIcon(icon);