diff --git a/src/citra/citra.cpp b/src/citra/citra.cpp index a29f8275e..01a70ea39 100644 --- a/src/citra/citra.cpp +++ b/src/citra/citra.cpp @@ -98,7 +98,8 @@ int main(int argc, char** argv) { const auto cia_progress = [](size_t written, size_t total) { LOG_INFO(Frontend, "%02zu%%", (written * 100 / total)); }; - if (!Service::AM::InstallCIA(std::string(optarg), cia_progress)) + if (Service::AM::InstallCIA(std::string(optarg), cia_progress) != + Service::AM::InstallStatus::Success) errno = EINVAL; if (errno != 0) exit(1); diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index b03e06421..b677ef6b4 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -283,12 +283,13 @@ bool CIAFile::Close() const { void CIAFile::Flush() const {} -bool InstallCIA(const std::string& path, std::function&& update_callback) { +InstallStatus InstallCIA(const std::string& path, + std::function&& update_callback) { LOG_INFO(Service_AM, "Installing %s...", path.c_str()); if (!FileUtil::Exists(path)) { LOG_ERROR(Service_AM, "File %s does not exist!", path.c_str()); - return false; + return InstallStatus::ErrorFileNotFound; } FileSys::CIAContainer container; @@ -298,7 +299,7 @@ bool InstallCIA(const std::string& path, std::function&& updat FileUtil::IOFile file(path, "rb"); if (!file.IsOpen()) - return false; + return InstallStatus::ErrorFailedToOpenFile; std::array buffer; size_t total_bytes_read = 0; @@ -312,18 +313,18 @@ bool InstallCIA(const std::string& path, std::function&& updat if (result.Failed()) { LOG_ERROR(Service_AM, "CIA file installation aborted with error code %08x", result.Code()); - return false; + return InstallStatus::ErrorAborted; } total_bytes_read += bytes_read; } installFile.Close(); LOG_INFO(Service_AM, "Installed %s successfully.", path.c_str()); - return true; + return InstallStatus::Success; } LOG_ERROR(Service_AM, "CIA file %s is invalid!", path.c_str()); - return false; + return InstallStatus::ErrorInvalid; } Service::FS::MediaType GetTitleMediaType(u64 titleId) { diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index 7deb09113..d4d834172 100644 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h @@ -42,6 +42,15 @@ enum class CIAInstallState : u32 { ContentWritten, }; +enum class InstallStatus : u32 { + Success, + ErrorFailedToOpenFile, + ErrorFileNotFound, + ErrorAborted, + ErrorInvalid, + ErrorEncrypted, +}; + // Progress callback for InstallCIA, recieves bytes written and total bytes using ProgressCallback = void(size_t, size_t); @@ -83,8 +92,8 @@ private: * @param update_callback callback function called during filesystem write * @returns bool whether the install was successful */ -bool InstallCIA(const std::string& path, - std::function&& update_callback = nullptr); +InstallStatus InstallCIA(const std::string& path, + std::function&& update_callback = nullptr); /** * Get the mediatype for an installed title