Complete logs and merge JEDECheck into Checkpoint

This commit is contained in:
BernardoGiordano 2019-07-26 21:55:22 +02:00
parent 2204d24fd9
commit d7901d177d
11 changed files with 102 additions and 54 deletions

View file

@ -45,6 +45,7 @@
#ifndef SPI_HPP
#define SPI_HPP
#include "logger.hpp"
#include <3ds.h>
#include <stdio.h>
#include <string.h>

View file

@ -91,9 +91,13 @@ void CheatManager::save(const std::string& key, const std::vector<std::string>&
}
}
FILE* f = fopen(("/cheats/" + key + ".txt").c_str(), "w");
const std::string outPath = "/cheats/" + key + ".txt";
FILE* f = fopen(outPath.c_str(), "w");
if (f != NULL) {
fwrite(cheatFile.c_str(), 1, cheatFile.length(), f);
fclose(f);
}
else {
Logger::getInstance().log(Logger::ERROR, "Failed to write " + outPath + " with errno %d.", errno);
}
}

View file

@ -48,6 +48,8 @@ void io::copyFile(FS_Archive srcArch, FS_Archive dstArch, const std::u16string&
size = input.size() > BUFFER_SIZE ? BUFFER_SIZE : input.size();
}
else {
Logger::getInstance().log(Logger::ERROR,
"Failed to open source file " + StringUtils::UTF16toUTF8(srcPath) + " during copy with result 0x%08lX. Skipping...", input.result());
return;
}
@ -61,6 +63,11 @@ void io::copyFile(FS_Archive srcArch, FS_Archive dstArch, const std::u16string&
} while (!input.eof());
delete[] buf;
}
else {
Logger::getInstance().log(Logger::ERROR,
"Failed to open destination file " + StringUtils::UTF16toUTF8(dstPath) + " during copy with result 0x%08lX. Skipping...",
output.result());
}
input.close();
output.close();
@ -152,6 +159,8 @@ std::tuple<bool, Result, std::string> io::backup(size_t index, size_t cellIndex)
Title title;
getTitle(title, index);
Logger::getInstance().log(Logger::INFO, "Started backup of %s. Title id: 0x%08lX.", title.shortDescription().c_str(), title.lowId());
if (title.cardType() == CARD_CTR) {
FS_Archive archive;
if (mode == MODE_SAVE) {
@ -186,6 +195,7 @@ std::tuple<bool, Result, std::string> io::backup(size_t index, size_t cellIndex)
res = FSUSER_DeleteDirectoryRecursively(Archive::sdmc(), fsMakePath(PATH_UTF16, dstPath.data()));
if (R_FAILED(res)) {
FSUSER_CloseArchive(archive);
Logger::getInstance().log(Logger::ERROR, "Failed to delete the existing backup directory recursively with result 0x%08lX.", res);
return std::make_tuple(false, res, "Failed to delete the existing backup\ndirectory recursively.");
}
}
@ -193,6 +203,7 @@ std::tuple<bool, Result, std::string> io::backup(size_t index, size_t cellIndex)
res = io::createDirectory(Archive::sdmc(), dstPath);
if (R_FAILED(res)) {
FSUSER_CloseArchive(archive);
Logger::getInstance().log(Logger::ERROR, "Failed to create destination directory.");
return std::make_tuple(false, res, "Failed to create destination directory.");
}
@ -203,12 +214,14 @@ std::tuple<bool, Result, std::string> io::backup(size_t index, size_t cellIndex)
std::string message = mode == MODE_SAVE ? "Failed to backup save." : "Failed to backup extdata.";
FSUSER_CloseArchive(archive);
FSUSER_DeleteDirectoryRecursively(Archive::sdmc(), fsMakePath(PATH_UTF16, dstPath.data()));
Logger::getInstance().log(Logger::ERROR, message + " Result 0x%08lX.", res);
return std::make_tuple(false, res, message);
}
refreshDirectories(title.id());
}
else {
Logger::getInstance().log(Logger::ERROR, "Failed to open save archive with result 0x%08lX.", res);
return std::make_tuple(false, res, "Failed to open save archive.");
}
@ -242,12 +255,14 @@ std::tuple<bool, Result, std::string> io::backup(size_t index, size_t cellIndex)
if (!isNewFolder || io::directoryExists(Archive::sdmc(), dstPath)) {
res = FSUSER_DeleteDirectoryRecursively(Archive::sdmc(), fsMakePath(PATH_UTF16, dstPath.data()));
if (R_FAILED(res)) {
Logger::getInstance().log(Logger::ERROR, "Failed to delete the existing backup directory recursively with result 0x%08lX.", res);
return std::make_tuple(false, res, "Failed to delete the existing\nbackup directory recursively.");
}
}
res = io::createDirectory(Archive::sdmc(), dstPath);
if (R_FAILED(res)) {
Logger::getInstance().log(Logger::ERROR, "Failed to create destination directory with result 0x%08lX.", res);
return std::make_tuple(false, res, "Failed to create destination directory.");
}
@ -265,6 +280,8 @@ std::tuple<bool, Result, std::string> io::backup(size_t index, size_t cellIndex)
if (R_FAILED(res)) {
delete[] saveFile;
FSUSER_DeleteDirectoryRecursively(Archive::sdmc(), fsMakePath(PATH_UTF16, dstPath.data()));
Logger::getInstance().log(
Logger::ERROR, "Failed to delete directory recursively after failing to write save to the sd card with result 0x%08lX.", res);
return std::make_tuple(false, res, "Failed to backup save.");
}
@ -276,6 +293,8 @@ std::tuple<bool, Result, std::string> io::backup(size_t index, size_t cellIndex)
delete[] saveFile;
stream.close();
FSUSER_DeleteDirectoryRecursively(Archive::sdmc(), fsMakePath(PATH_UTF16, dstPath.data()));
Logger::getInstance().log(
Logger::ERROR, "Failed to delete directory recursively after failing to write save to the sd card with result 0x%08lX.", res);
return std::make_tuple(false, res, "Failed to backup save.");
}
@ -284,6 +303,7 @@ std::tuple<bool, Result, std::string> io::backup(size_t index, size_t cellIndex)
refreshDirectories(title.id());
}
Logger::getInstance().log(Logger::INFO, "Backup succeeded.");
return std::make_tuple(true, 0, "Progress correctly saved to disk.");
}
@ -295,6 +315,8 @@ std::tuple<bool, Result, std::string> io::restore(size_t index, size_t cellIndex
Title title;
getTitle(title, index);
Logger::getInstance().log(Logger::INFO, "Started restore of %s. Title id: 0x%08lX.", title.shortDescription().c_str(), title.lowId());
if (title.cardType() == CARD_CTR) {
FS_Archive archive;
if (mode == MODE_SAVE) {
@ -320,6 +342,7 @@ std::tuple<bool, Result, std::string> io::restore(size_t index, size_t cellIndex
if (R_FAILED(res)) {
std::string message = mode == MODE_SAVE ? "Failed to restore save." : "Failed to restore extdata.";
FSUSER_CloseArchive(archive);
Logger::getInstance().log(Logger::ERROR, message + ". Result 0x%08lX.", res);
return std::make_tuple(false, res, message);
}
@ -327,6 +350,7 @@ std::tuple<bool, Result, std::string> io::restore(size_t index, size_t cellIndex
res = FSUSER_ControlArchive(archive, ARCHIVE_ACTION_COMMIT_SAVE_DATA, NULL, 0, NULL, 0);
if (R_FAILED(res)) {
FSUSER_CloseArchive(archive);
Logger::getInstance().log(Logger::ERROR, "Failed to commit save data with result 0x%08lX.", res);
return std::make_tuple(false, res, "Failed to commit save data.");
}
@ -335,11 +359,13 @@ std::tuple<bool, Result, std::string> io::restore(size_t index, size_t cellIndex
res = FSUSER_ControlSecureSave(SECURESAVE_ACTION_DELETE, &secureValue, 8, &out, 1);
if (R_FAILED(res)) {
FSUSER_CloseArchive(archive);
Logger::getInstance().log(Logger::ERROR, "Failed to fix secure value with result 0x%08lX.", res);
return std::make_tuple(false, res, "Failed to fix secure value.");
}
}
}
else {
Logger::getInstance().log(Logger::ERROR, "Failed to open save archive with result 0x%08lX.", res);
return std::make_tuple(false, res, "Failed to open save archive.");
}
@ -364,6 +390,7 @@ std::tuple<bool, Result, std::string> io::restore(size_t index, size_t cellIndex
if (R_FAILED(res)) {
delete[] saveFile;
Logger::getInstance().log(Logger::ERROR, "Failed to read save file backup with result 0x%08lX.", res);
return std::make_tuple(false, res, "Failed to read save file backup.");
}
@ -376,12 +403,14 @@ std::tuple<bool, Result, std::string> io::restore(size_t index, size_t cellIndex
if (R_FAILED(res)) {
delete[] saveFile;
Logger::getInstance().log(Logger::ERROR, "Failed to restore save with result 0x%08lX.", res);
return std::make_tuple(false, res, "Failed to restore save.");
}
delete[] saveFile;
}
Logger::getInstance().log(Logger::INFO, "Restore succeeded.");
return std::make_tuple(true, 0, nameFromCell + "\nhas been restored successfully.");
}
@ -389,7 +418,6 @@ void io::deleteBackupFolder(const std::u16string& path)
{
Result res = FSUSER_DeleteDirectoryRecursively(Archive::sdmc(), fsMakePath(PATH_UTF16, path.data()));
if (R_FAILED(res)) {
// TODO: log this
// return std::make_tuple(false, res, "Failed to delete backup folder.");
Logger::getInstance().log(Logger::INFO, "Failed to delete backup folder with result 0x%08lX.", res);
}
}

View file

@ -44,6 +44,8 @@
#include "spi.hpp"
static std::vector<u32> knownJEDECs = {0x204012, 0x621600, 0x204013, 0x621100, 0x204014, 0x202017, 0x204017, 0x208013};
u8* fill_buf = NULL;
Result SPIWriteRead(CardType type, void* cmd, u32 cmdSize, void* answer, u32 answerSize, void* data, u32 dataSize)
@ -404,9 +406,20 @@ Result SPIGetCardType(CardType* type, int infrared)
u32 maxTries = (infrared == -1) ? 2 : 1; // note: infrared = -1 fails 1/3 of the time
while (tries < maxTries) {
res = SPIReadJEDECIDAndStatusReg(t, &jedec, &sr); // dummy
// fprintf(stderr, "JEDEC: 0x%016lX\n", jedec);
// fprintf(stderr, "SPIReadJEDECIDAndStatusReg: %016lX\n", res);
// fprintf(stderr, "CardType (While inside maxTries loop): %016lX\n", t);
if (R_SUCCEEDED(res)) {
Logger::getInstance().log(Logger::INFO, "Found JEDEC: 0x%016lX", jedec);
Logger::getInstance().log(Logger::INFO, "CardType (While inside maxTries loop): %016lX", t);
if (std::find(knownJEDECs.begin(), knownJEDECs.end(), jedec) != knownJEDECs.end()) {
Logger::getInstance().log(Logger::INFO, "Found a jedec equal to one in the ordered list. Type: %016lX", *type);
}
else {
Logger::getInstance().log(Logger::INFO, "JEDEC ID not documented yet!");
}
}
else {
Logger::getInstance().log(Logger::WARN, "Unable to retrieve JEDEC id with result 0x%08lX.", res);
}
if (res)
return res;
@ -426,10 +439,10 @@ Result SPIGetCardType(CardType* type, int infrared)
t = FLASH_INFRARED_DUMMY;
}
// fprintf(stderr, "CardType (after the maxTries loop): %016lX\n", t);
Logger::getInstance().log(Logger::INFO, "CardType (after the maxTries loop): %016lX", t);
if (t == EEPROM_512B) {
// fprintf(stderr, "Type is EEPROM_512B: %d\n", t);
Logger::getInstance().log(Logger::INFO, "Type is EEPROM_512B: %d", t);
*type = t;
return 0;
}
@ -451,7 +464,7 @@ Result SPIGetCardType(CardType* type, int infrared)
}
*type = t;
// fprintf(stderr, "Type: %d\n", t);
Logger::getInstance().log(Logger::INFO, "Type: %d", t);
return 0;
}
else if (t == FLASH_INFRARED_DUMMY) {
@ -466,7 +479,7 @@ Result SPIGetCardType(CardType* type, int infrared)
else {
if (infrared == 1) {
*type = NO_CHIP; // did anything go wrong?
// fprintf(stderr, "infrared is 1, *type = NO_CHIP\n");
Logger::getInstance().log(Logger::INFO, "infrared is 1, *type = NO_CHIP");
}
if (jedec == 0x204017) {
*type = FLASH_8MB;
@ -480,12 +493,11 @@ Result SPIGetCardType(CardType* type, int infrared)
for (int i = 0; i < 6; ++i) {
if (jedec == jedecOrderedList[i]) {
*type = (CardType)((int)FLASH_256KB_1 + i);
// fprintf(stderr, "Found a jedec equal to one in the ordered list. Type: %016lX", *type);
return 0;
}
}
// fprintf(stderr, "*type = NO_CHIP\n");
Logger::getInstance().log(Logger::INFO, "*type = NO_CHIP");
*type = NO_CHIP;
return 0;
}

View file

@ -86,6 +86,7 @@ bool Title::load(u64 _id, FS_MediaType _media, FS_CardType _card)
smdh = loadSMDH(lowId(), highId(), mMedia);
}
if (smdh == NULL) {
Logger::getInstance().log(Logger::ERROR, "Failed to load title 0x%lX due to smdh == NULL", mId);
return false;
}
@ -107,8 +108,7 @@ bool Title::load(u64 _id, FS_MediaType _media, FS_CardType _card)
Result res = io::createDirectory(Archive::sdmc(), mSavePath);
if (R_FAILED(res)) {
loadTitle = false;
// TODO: log this
// Gui::showError(res, "Failed to create backup directory.");
Logger::getInstance().log(Logger::ERROR, "Failed to create backup directory with result 0x%08lX.", res);
}
}
}
@ -119,8 +119,7 @@ bool Title::load(u64 _id, FS_MediaType _media, FS_CardType _card)
Result res = io::createDirectory(Archive::sdmc(), mExtdataPath);
if (R_FAILED(res)) {
loadTitle = false;
// TODO: log this
// Gui::showError(res, "Failed to create backup directory.");
Logger::getInstance().log(Logger::ERROR, "Failed to create backup directory with result 0x%08lX.", res);
}
}
}
@ -136,6 +135,7 @@ bool Title::load(u64 _id, FS_MediaType _media, FS_CardType _card)
Result res = FSUSER_GetLegacyRomHeader(mMedia, 0LL, headerData);
if (R_FAILED(res)) {
delete[] headerData;
Logger::getInstance().log(Logger::ERROR, "Failed get legacy rom header with result 0x%08lX.", res);
return false;
}
@ -150,6 +150,7 @@ bool Title::load(u64 _id, FS_MediaType _media, FS_CardType _card)
res = SPIGetCardType(&mCardType, (_gameCode[0] == 'I') ? 1 : 0);
if (R_FAILED(res)) {
delete[] headerData;
Logger::getInstance().log(Logger::ERROR, "Failed get SPI Card Type with result 0x%08lX.", res);
return false;
}
@ -170,8 +171,7 @@ bool Title::load(u64 _id, FS_MediaType _media, FS_CardType _card)
res = io::createDirectory(Archive::sdmc(), mSavePath);
if (R_FAILED(res)) {
loadTitle = false;
// TODO: log this
// Gui::showError(res, "Failed to create backup directory.");
Logger::getInstance().log(Logger::ERROR, "Failed to create backup with result 0x%08lX.", res);
}
}
@ -282,8 +282,7 @@ void Title::refreshDirectories(void)
mFullSavePaths.insert(mFullSavePaths.begin(), StringUtils::UTF8toUTF16("New..."));
}
else {
// fprintf(stderr, "Title 0x%016llX, %s\n", id(), shortDescription().c_str());
// LOG THIS Gui::showError(savelist.error(), "Couldn't retrieve the directory list\nfor the title " + shortDescription());
Logger::getInstance().log(Logger::ERROR, "Couldn't retrieve the save directory list for the title " + shortDescription());
}
// save backups from configuration
@ -319,8 +318,7 @@ void Title::refreshDirectories(void)
mFullExtdataPaths.insert(mFullExtdataPaths.begin(), StringUtils::UTF8toUTF16("New..."));
}
else {
// fprintf(stderr, "Title 0x%016llX, %s\n", id(), shortDescription().c_str());
// LOG THIS Gui::showError(extlist.error(), "Couldn't retrieve the extdata list\nfor the title " + shortDescription());
Logger::getInstance().log(Logger::ERROR, "Couldn't retrieve the extdata directory list for the title " + shortDescription());
}
// extdata backups from configuration

View file

@ -56,7 +56,7 @@ Result servicesInit(void)
Handle hbldrHandle;
if (R_FAILED(res = svcConnectToPort(&hbldrHandle, "hb:ldr"))) {
Logger::getInstance().log(Logger::ERROR, "Error during startup with result %llX. Rosalina not found on this system.", res);
Logger::getInstance().log(Logger::ERROR, "Error during startup with result 0x%08lX. Rosalina not found on this system.", res);
return consoleDisplayError("Rosalina not found on this system.\nAn updated CFW is required to launch Checkpoint.", res);
}
@ -73,7 +73,7 @@ Result servicesInit(void)
ATEXIT(pxiDevExit);
if (R_FAILED(res = Archive::init())) {
Logger::getInstance().log(Logger::ERROR, "Archive::init failed with result %llX.", res);
Logger::getInstance().log(Logger::ERROR, "Archive::init failed with result 0x%08lX", res);
return consoleDisplayError("Archive::init failed.", res);
}
ATEXIT(Archive::exit);
@ -91,8 +91,6 @@ Result servicesInit(void)
// consoleDebugInit(debugDevice_SVC);
// while (aptMainLoop() && !(hidKeysDown() & KEY_START)) { hidScanInput(); }
Configuration::getInstance();
Logger::getInstance().log(Logger::INFO, "Checkpoint loading finished!");
return 0;

View file

@ -101,7 +101,7 @@ void CheatManager::save(const std::string& key, const std::vector<std::string>&
}
std::string outPath = rootfolder + "/" + buildid + ".txt";
FILE* f = fopen(outPath.c_str(), "w");
FILE* f = fopen(outPath.c_str(), "w");
if (f != NULL) {
fwrite(cheatFile.c_str(), 1, cheatFile.length(), f);
fclose(f);

View file

@ -51,8 +51,9 @@ static void handle_save(struct mg_connection* nc, struct http_message* hm)
fwrite(hm->body.p, 1, hm->body.len, f);
fclose(f);
Logger::getInstance().log(Logger::INFO, "Configurations have been updated.");
} else {
Logger::getInstance().log(Logger::ERROR, "Failed to write to configuration file.");
}
else {
Logger::getInstance().log(Logger::ERROR, "Failed to write to configuration file with errno %d.", errno);
}
Configuration::getInstance().load();
Configuration::getInstance().parse();

View file

@ -36,12 +36,12 @@ void io::copyFile(const std::string& srcPath, const std::string& dstPath)
{
FILE* src = fopen(srcPath.c_str(), "rb");
if (src == NULL) {
Logger::getInstance().log(Logger::ERROR, "Failed to open source file " + srcPath + " during copy. Skipping...");
Logger::getInstance().log(Logger::ERROR, "Failed to open source file " + srcPath + " during copy with errno %d. Skipping...", errno);
return;
}
FILE* dst = fopen(dstPath.c_str(), "wb");
if (dst == NULL) {
Logger::getInstance().log(Logger::ERROR, "Failed to open destination file " + dstPath + " during copy. Skipping...");
Logger::getInstance().log(Logger::ERROR, "Failed to open destination file " + dstPath + " during copy with errno %d. Skipping...", errno);
fclose(src);
return;
}
@ -146,7 +146,8 @@ std::tuple<bool, Result, std::string> io::backup(size_t index, u128 uid, size_t
Title title;
getTitle(title, uid, index);
Logger::getInstance().log(Logger::INFO, "Started backup of %s. Title id: 0x%016lX; User id: 0x%lX%lX.", title.name().c_str(), title.id(), (u64)(title.userId() >> 8), (u64)(title.userId()));
Logger::getInstance().log(Logger::INFO, "Started backup of %s. Title id: 0x%016lX; User id: 0x%lX%lX.", title.name().c_str(), title.id(),
(u64)(title.userId() >> 8), (u64)(title.userId()));
FsFileSystem fileSystem;
res = FileSystem::mount(&fileSystem, title.id(), title.userId());
@ -154,12 +155,14 @@ std::tuple<bool, Result, std::string> io::backup(size_t index, u128 uid, size_t
int rc = FileSystem::mount(fileSystem);
if (rc == -1) {
FileSystem::unmount();
Logger::getInstance().log(Logger::ERROR, "Failed to mount filesystem during backup. Title id: 0x%016lX; User id: 0x%lX%lX.", title.id(), (u64)(title.userId() >> 8), (u64)(title.userId()));
Logger::getInstance().log(Logger::ERROR, "Failed to mount filesystem during backup. Title id: 0x%016lX; User id: 0x%lX%lX.", title.id(),
(u64)(title.userId() >> 8), (u64)(title.userId()));
return std::make_tuple(false, -2, "Failed to mount save.");
}
}
else {
Logger::getInstance().log(Logger::ERROR, "Failed to mount filesystem during backup with result %X. Title id: 0x%016lX; User id: 0x%lX%lX.", res, title.id(), (u64)(title.userId() >> 8), (u64)(title.userId()));
Logger::getInstance().log(Logger::ERROR, "Failed to mount filesystem during backup with result 0x%08lX. Title id: 0x%016lX; User id: 0x%lX%lX.",
res, title.id(), (u64)(title.userId() >> 8), (u64)(title.userId()));
return std::make_tuple(false, res, "Failed to mount save.");
}
@ -202,7 +205,7 @@ std::tuple<bool, Result, std::string> io::backup(size_t index, u128 uid, size_t
int rc = io::deleteFolderRecursively((dstPath + "/").c_str());
if (rc != 0) {
FileSystem::unmount();
Logger::getInstance().log(Logger::ERROR, "Failed to recursively delete directory " + dstPath);
Logger::getInstance().log(Logger::ERROR, "Failed to recursively delete directory " + dstPath + " with result %d.", rc);
return std::make_tuple(false, (Result)rc, "Failed to delete the existing backup\ndirectory recursively.");
}
}
@ -212,7 +215,7 @@ std::tuple<bool, Result, std::string> io::backup(size_t index, u128 uid, size_t
if (R_FAILED(res)) {
FileSystem::unmount();
io::deleteFolderRecursively((dstPath + "/").c_str());
Logger::getInstance().log(Logger::ERROR, "Failed to copy directory " + dstPath + ". Skipping...");
Logger::getInstance().log(Logger::ERROR, "Failed to copy directory " + dstPath + " with result 0x%08lX. Skipping...", res);
return std::make_tuple(false, res, "Failed to backup save.");
}
@ -241,7 +244,8 @@ std::tuple<bool, Result, std::string> io::restore(size_t index, u128 uid, size_t
Title title;
getTitle(title, uid, index);
Logger::getInstance().log(Logger::INFO, "Started restore of %s. Title id: 0x%016lX; User id: 0x%lX%lX.", title.name().c_str(), title.id(), (u64)(title.userId() >> 8), (u64)(title.userId()));
Logger::getInstance().log(Logger::INFO, "Started restore of %s. Title id: 0x%016lX; User id: 0x%lX%lX.", title.name().c_str(), title.id(),
(u64)(title.userId() >> 8), (u64)(title.userId()));
FsFileSystem fileSystem;
res = title.systemSave() ? FileSystem::mount(&fileSystem, title.id()) : FileSystem::mount(&fileSystem, title.id(), title.userId());
@ -249,12 +253,14 @@ std::tuple<bool, Result, std::string> io::restore(size_t index, u128 uid, size_t
int rc = FileSystem::mount(fileSystem);
if (rc == -1) {
FileSystem::unmount();
Logger::getInstance().log(Logger::ERROR, "Failed to mount filesystem during restore. Title id: 0x%016lX; User id: 0x%lX%lX.", title.id(), (u64)(title.userId() >> 8), (u64)(title.userId()));
Logger::getInstance().log(Logger::ERROR, "Failed to mount filesystem during restore. Title id: 0x%016lX; User id: 0x%lX%lX.", title.id(),
(u64)(title.userId() >> 8), (u64)(title.userId()));
return std::make_tuple(false, -2, "Failed to mount save.");
}
}
else {
Logger::getInstance().log(Logger::ERROR, "Failed to mount filesystem during restore with result %X. Title id: 0x%016lX; User id: 0x%lX%lX.", res, title.id(), (u64)(title.userId() >> 8), (u64)(title.userId()));
Logger::getInstance().log(Logger::ERROR, "Failed to mount filesystem during restore with result 0x%08lX. Title id: 0x%016lX; User id: 0x%lX%lX.",
res, title.id(), (u64)(title.userId() >> 8), (u64)(title.userId()));
return std::make_tuple(false, res, "Failed to mount save.");
}
@ -264,20 +270,20 @@ std::tuple<bool, Result, std::string> io::restore(size_t index, u128 uid, size_t
res = io::deleteFolderRecursively(dstPath.c_str());
if (R_FAILED(res)) {
FileSystem::unmount();
Logger::getInstance().log(Logger::ERROR, "Failed to recursively delete directory " + dstPath);
Logger::getInstance().log(Logger::ERROR, "Failed to recursively delete directory " + dstPath + " with result 0x%08lX.", res);
return std::make_tuple(false, res, "Failed to delete save.");
}
res = io::copyDirectory(srcPath, dstPath);
if (R_FAILED(res)) {
FileSystem::unmount();
Logger::getInstance().log(Logger::ERROR, "Failed to copy directory " + srcPath + " to " + dstPath + ". Skipping...");
Logger::getInstance().log(Logger::ERROR, "Failed to copy directory " + srcPath + " to " + dstPath + " with result 0x%08lX. Skipping...", res);
return std::make_tuple(false, res, "Failed to restore save.");
}
res = fsdevCommitDevice("save");
if (R_FAILED(res)) {
Logger::getInstance().log(Logger::ERROR, "Failed to commit save with result %X.", res);
Logger::getInstance().log(Logger::ERROR, "Failed to commit save with result 0x%08lX.", res);
return std::make_tuple(false, res, "Failed to commit to save device.");
}
else {

View file

@ -116,7 +116,7 @@ std::tuple<bool, Result, std::string> recvFromPKSMBridge(size_t index, u128 uid,
int fd;
struct sockaddr_in servaddr;
if ((fd = socket(AF_INET, SOCK_STREAM, IPPROTO_IP)) < 0) {
Logger::getInstance().log(Logger::ERROR, "Socket creation failed.");
Logger::getInstance().log(Logger::ERROR, "Socket creation failed: %d.", fd);
return std::make_tuple(false, errno, "Socket creation failed.");
}
@ -127,12 +127,12 @@ std::tuple<bool, Result, std::string> recvFromPKSMBridge(size_t index, u128 uid,
if (bind(fd, (struct sockaddr*)&servaddr, sizeof(servaddr)) < 0) {
close(fd);
Logger::getInstance().log(Logger::ERROR, "Socket bind failed.");
Logger::getInstance().log(Logger::ERROR, "Socket bind failed with errno %d.", errno);
return std::make_tuple(false, errno, "Socket bind failed.");
}
if (listen(fd, 5) < 0) {
close(fd);
Logger::getInstance().log(Logger::ERROR, "Socket listen failed.");
Logger::getInstance().log(Logger::ERROR, "Socket listen failed with errno %d.", errno);
return std::make_tuple(false, errno, "Socket listen failed.");
}
@ -140,7 +140,7 @@ std::tuple<bool, Result, std::string> recvFromPKSMBridge(size_t index, u128 uid,
int addrlen = sizeof(servaddr);
if ((fdconn = accept(fd, (struct sockaddr*)&servaddr, (socklen_t*)&addrlen)) < 0) {
close(fd);
Logger::getInstance().log(Logger::ERROR, "Socket accept failed.");
Logger::getInstance().log(Logger::ERROR, "Socket accept failed: %d.", fdconn);
return std::make_tuple(false, errno, "Socket accept failed.");
}
@ -152,7 +152,7 @@ std::tuple<bool, Result, std::string> recvFromPKSMBridge(size_t index, u128 uid,
if (save == NULL) {
close(fd);
close(fdconn);
Logger::getInstance().log(Logger::ERROR, "Failed to open destination file.");
Logger::getInstance().log(Logger::ERROR, "Failed to open destination file with errno %d.", errno);
return std::make_tuple(false, errno, "Failed to open destination file.");
}

View file

@ -47,7 +47,7 @@ Result servicesInit(void)
// nxlinkStdio();
}
else {
Logger::getInstance().log(Logger::INFO, "Unable to initialize socket. Result code %X.", socinit);
Logger::getInstance().log(Logger::INFO, "Unable to initialize socket. Result code 0x%08lX.", socinit);
}
g_shouldExitNetworkLoop = R_FAILED(socinit);
@ -63,25 +63,25 @@ Result servicesInit(void)
io::createDirectory("sdmc:/switch/Checkpoint/cheats");
if (R_FAILED(res = plInitialize())) {
Logger::getInstance().log(Logger::ERROR, "plInitialize failed. Result code %X.", res);
Logger::getInstance().log(Logger::ERROR, "plInitialize failed. Result code 0x%08lX.", res);
return res;
}
ATEXIT(plExit);
if (R_FAILED(res = Account::init())) {
Logger::getInstance().log(Logger::ERROR, "Account::init failed. Result code %X.", res);
Logger::getInstance().log(Logger::ERROR, "Account::init failed. Result code 0x%08lX.", res);
return res;
}
ATEXIT(Account::exit);
if (R_FAILED(res = nsInitialize())) {
Logger::getInstance().log(Logger::ERROR, "nsInitialize failed. Result code %X.", res);
Logger::getInstance().log(Logger::ERROR, "nsInitialize failed. Result code 0x%08lX.", res);
return res;
}
ATEXIT(nsExit);
if (!SDLH_Init()) {
Logger::getInstance().log(Logger::ERROR, "SDLH_Init failed. Result code %X.", res);
Logger::getInstance().log(Logger::ERROR, "SDLH_Init failed. Result code 0x%08lX.", res);
return -1;
}
ATEXIT(freeIcons);
@ -91,7 +91,7 @@ Result servicesInit(void)
ATEXIT(hidsysExit);
}
else {
Logger::getInstance().log(Logger::INFO, "Notification led not available. Result code %X.", res);
Logger::getInstance().log(Logger::INFO, "Notification led not available. Result code 0x%08lX.", res);
}
Configuration::getInstance();
@ -103,7 +103,7 @@ Result servicesInit(void)
Logger::getInstance().log(Logger::INFO, "FTP Server successfully loaded.");
}
else {
Logger::getInstance().log(Logger::INFO, "FTP Server failed to load. Result code %X.", res);
Logger::getInstance().log(Logger::INFO, "FTP Server failed to load. Result code 0x%08lX.", res);
}
}