diff options
Diffstat (limited to 'src/core/loader')
-rw-r--r-- | src/core/loader/loader.cpp | 14 | ||||
-rw-r--r-- | src/core/loader/loader.h | 4 | ||||
-rw-r--r-- | src/core/loader/nca.cpp | 14 | ||||
-rw-r--r-- | src/core/loader/nca.h | 17 | ||||
-rw-r--r-- | src/core/loader/xci.cpp | 14 | ||||
-rw-r--r-- | src/core/loader/xci.h | 12 |
6 files changed, 30 insertions, 45 deletions
diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp index b143f043c..70ef5d240 100644 --- a/src/core/loader/loader.cpp +++ b/src/core/loader/loader.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include <memory> +#include <ostream> #include <string> #include "common/logging/log.h" #include "common/string_util.h" @@ -40,6 +41,8 @@ FileType IdentifyFile(FileSys::VirtualFile file) { FileType GuessFromFilename(const std::string& name) { if (name == "main") return FileType::DeconstructedRomDirectory; + if (name == "00") + return FileType::NCA; const std::string extension = Common::ToLower(std::string(FileUtil::GetExtensionFromFilename(name))); @@ -119,14 +122,9 @@ constexpr std::array<const char*, 36> RESULT_MESSAGES{ "There is no control data available.", }; -std::string GetMessageForResultStatus(ResultStatus status) { - return GetMessageForResultStatus(static_cast<u16>(status)); -} - -std::string GetMessageForResultStatus(u16 status) { - if (status >= 36) - return ""; - return RESULT_MESSAGES[status]; +std::ostream& operator<<(std::ostream& os, ResultStatus status) { + os << RESULT_MESSAGES.at(static_cast<size_t>(status)); + return os; } /** diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h index 6dffe451a..b74cfbf8a 100644 --- a/src/core/loader/loader.h +++ b/src/core/loader/loader.h @@ -5,6 +5,7 @@ #pragma once #include <algorithm> +#include <iosfwd> #include <memory> #include <string> #include <utility> @@ -94,8 +95,7 @@ enum class ResultStatus : u16 { ErrorNoControl, }; -std::string GetMessageForResultStatus(ResultStatus status); -std::string GetMessageForResultStatus(u16 status); +std::ostream& operator<<(std::ostream& os, ResultStatus status); /// Interface for loading an application class AppLoader : NonCopyable { diff --git a/src/core/loader/nca.cpp b/src/core/loader/nca.cpp index 8498cc94b..9d50c7d42 100644 --- a/src/core/loader/nca.cpp +++ b/src/core/loader/nca.cpp @@ -3,28 +3,22 @@ // Refer to the license.txt file included. #include <utility> -#include <vector> #include "common/file_util.h" #include "common/logging/log.h" -#include "common/string_util.h" -#include "common/swap.h" -#include "core/core.h" #include "core/file_sys/content_archive.h" -#include "core/file_sys/program_metadata.h" -#include "core/gdbstub/gdbstub.h" #include "core/hle/kernel/process.h" -#include "core/hle/kernel/resource_limit.h" #include "core/hle/service/filesystem/filesystem.h" +#include "core/loader/deconstructed_rom_directory.h" #include "core/loader/nca.h" -#include "core/loader/nso.h" -#include "core/memory.h" namespace Loader { AppLoader_NCA::AppLoader_NCA(FileSys::VirtualFile file_) : AppLoader(std::move(file_)), nca(std::make_unique<FileSys::NCA>(file)) {} +AppLoader_NCA::~AppLoader_NCA() = default; + FileType AppLoader_NCA::IdentifyType(const FileSys::VirtualFile& file) { FileSys::NCA nca(file); @@ -83,6 +77,4 @@ ResultStatus AppLoader_NCA::ReadProgramId(u64& out_program_id) { return ResultStatus::Success; } -AppLoader_NCA::~AppLoader_NCA() = default; - } // namespace Loader diff --git a/src/core/loader/nca.h b/src/core/loader/nca.h index 7f7d8ea0b..326f84857 100644 --- a/src/core/loader/nca.h +++ b/src/core/loader/nca.h @@ -4,20 +4,24 @@ #pragma once -#include <string> #include "common/common_types.h" -#include "core/file_sys/content_archive.h" -#include "core/file_sys/program_metadata.h" +#include "core/file_sys/vfs.h" #include "core/hle/kernel/object.h" #include "core/loader/loader.h" -#include "deconstructed_rom_directory.h" + +namespace FileSys { +class NCA; +} namespace Loader { +class AppLoader_DeconstructedRomDirectory; + /// Loads an NCA file class AppLoader_NCA final : public AppLoader { public: explicit AppLoader_NCA(FileSys::VirtualFile file); + ~AppLoader_NCA() override; /** * Returns the type of the file @@ -35,12 +39,7 @@ public: ResultStatus ReadRomFS(FileSys::VirtualFile& dir) override; ResultStatus ReadProgramId(u64& out_program_id) override; - ~AppLoader_NCA(); - private: - FileSys::ProgramMetadata metadata; - - FileSys::NCAHeader header; std::unique_ptr<FileSys::NCA> nca; std::unique_ptr<AppLoader_DeconstructedRomDirectory> directory_loader; }; diff --git a/src/core/loader/xci.cpp b/src/core/loader/xci.cpp index 5d67fb186..4c4979545 100644 --- a/src/core/loader/xci.cpp +++ b/src/core/loader/xci.cpp @@ -4,22 +4,14 @@ #include <vector> -#include "common/file_util.h" -#include "common/logging/log.h" -#include "common/string_util.h" -#include "common/swap.h" -#include "core/core.h" +#include "common/common_types.h" +#include "core/file_sys/card_image.h" #include "core/file_sys/content_archive.h" #include "core/file_sys/control_metadata.h" -#include "core/file_sys/program_metadata.h" #include "core/file_sys/romfs.h" -#include "core/gdbstub/gdbstub.h" #include "core/hle/kernel/process.h" -#include "core/hle/kernel/resource_limit.h" -#include "core/hle/service/filesystem/filesystem.h" -#include "core/loader/nso.h" +#include "core/loader/nca.h" #include "core/loader/xci.h" -#include "core/memory.h" namespace Loader { diff --git a/src/core/loader/xci.h b/src/core/loader/xci.h index 973833050..cc4287e17 100644 --- a/src/core/loader/xci.h +++ b/src/core/loader/xci.h @@ -6,12 +6,18 @@ #include <memory> #include "common/common_types.h" -#include "core/file_sys/card_image.h" +#include "core/file_sys/vfs.h" #include "core/loader/loader.h" -#include "core/loader/nca.h" + +namespace FileSys { +class NACP; +class XCI; +} // namespace FileSys namespace Loader { +class AppLoader_NCA; + /// Loads an XCI file class AppLoader_XCI final : public AppLoader { public: @@ -37,8 +43,6 @@ public: ResultStatus ReadTitle(std::string& title) override; private: - FileSys::ProgramMetadata metadata; - std::unique_ptr<FileSys::XCI> xci; std::unique_ptr<AppLoader_NCA> nca_loader; |