Services/AM: Return InstallStatus for InstallCIA

This commit is contained in:
shinyquagsire23
2017-11-19 21:56:02 -07:00
parent 553ca2bfe0
commit 253954930f
3 changed files with 20 additions and 9 deletions

View File

@@ -283,12 +283,13 @@ bool CIAFile::Close() const {
void CIAFile::Flush() const {}
bool InstallCIA(const std::string& path, std::function<ProgressCallback>&& update_callback) {
InstallStatus InstallCIA(const std::string& path,
std::function<ProgressCallback>&& 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<ProgressCallback>&& updat
FileUtil::IOFile file(path, "rb");
if (!file.IsOpen())
return false;
return InstallStatus::ErrorFailedToOpenFile;
std::array<u8, 0x10000> buffer;
size_t total_bytes_read = 0;
@@ -312,18 +313,18 @@ bool InstallCIA(const std::string& path, std::function<ProgressCallback>&& 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) {