2021-10-15 15:41:16 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Copyright (C) 2021 Maschell
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
****************************************************************************/
|
2022-07-26 08:16:27 +02:00
|
|
|
#include "WUDDumperState.h"
|
|
|
|
#include <WUD/content/WiiUDiscContentsHeader.h>
|
2021-10-15 15:41:16 +02:00
|
|
|
#include <common/common.h>
|
|
|
|
#include <fs/FSUtils.h>
|
2022-07-26 08:16:27 +02:00
|
|
|
#include <malloc.h>
|
2022-07-26 09:24:06 +02:00
|
|
|
#include <mocha/fsa.h>
|
|
|
|
#include <mocha/mocha.h>
|
2021-10-15 15:41:16 +02:00
|
|
|
#include <utils/StringTools.h>
|
2022-07-26 08:16:27 +02:00
|
|
|
#include <utils/WiiUScreen.h>
|
2021-10-15 15:41:16 +02:00
|
|
|
#include <utils/utils.h>
|
|
|
|
|
2021-10-16 13:03:32 +02:00
|
|
|
WUDDumperState::WUDDumperState(WUDDumperState::eDumpTargetFormat pTargetFormat, eDumpTarget pTargetDevice)
|
2022-07-26 08:16:27 +02:00
|
|
|
: targetFormat(pTargetFormat), targetDevice(pTargetDevice) {
|
2021-10-15 15:41:16 +02:00
|
|
|
this->sectorBufSize = READ_SECTOR_SIZE * READ_NUM_SECTORS;
|
2022-07-26 08:16:27 +02:00
|
|
|
this->state = STATE_OPEN_ODD1;
|
2022-07-26 09:24:06 +02:00
|
|
|
gBlockHomeButton = true;
|
2022-07-27 19:00:56 +02:00
|
|
|
this->dumpStartDate = OSGetTime();
|
2021-10-15 15:41:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
WUDDumperState::~WUDDumperState() {
|
|
|
|
if (this->oddFd >= 0) {
|
2022-07-26 09:24:06 +02:00
|
|
|
FSAEx_RawClose(__wut_devoptab_fs_client, oddFd);
|
2021-10-15 15:41:16 +02:00
|
|
|
}
|
|
|
|
free(sectorBuf);
|
|
|
|
free(emptySector);
|
2022-07-26 09:24:06 +02:00
|
|
|
gBlockHomeButton = false;
|
2021-10-15 15:41:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ApplicationState::eSubState WUDDumperState::update(Input *input) {
|
|
|
|
if (this->state == STATE_ERROR) {
|
|
|
|
if (entrySelected(input)) {
|
|
|
|
return ApplicationState::SUBSTATE_RETURN;
|
|
|
|
}
|
|
|
|
return ApplicationState::SUBSTATE_RUNNING;
|
|
|
|
}
|
|
|
|
if (this->state == STATE_OPEN_ODD1) {
|
|
|
|
if (this->currentSector > 0) {
|
2022-07-26 09:24:06 +02:00
|
|
|
auto ret = FSAEx_RawOpen(__wut_devoptab_fs_client, "/dev/odd01", &(this->oddFd));
|
2021-10-15 15:41:16 +02:00
|
|
|
if (ret >= 0) {
|
|
|
|
// continue!
|
|
|
|
this->state = STATE_DUMP_DISC;
|
|
|
|
} else {
|
|
|
|
this->oddFd = -1;
|
|
|
|
this->state = STATE_WAIT_USER_ERROR_CONFIRM;
|
|
|
|
}
|
|
|
|
return ApplicationState::SUBSTATE_RUNNING;
|
|
|
|
}
|
|
|
|
if (this->retryCount-- <= 0) {
|
|
|
|
this->state = STATE_PLEASE_INSERT_DISC;
|
|
|
|
return ApplicationState::SUBSTATE_RUNNING;
|
|
|
|
}
|
2022-07-26 09:24:06 +02:00
|
|
|
auto ret = FSAEx_RawOpen(__wut_devoptab_fs_client, "/dev/odd01", &(this->oddFd));
|
2021-10-15 15:41:16 +02:00
|
|
|
if (ret >= 0) {
|
|
|
|
if (this->sectorBuf == nullptr) {
|
|
|
|
this->sectorBuf = (void *) memalign(0x100, this->sectorBufSize);
|
|
|
|
if (this->sectorBuf == nullptr) {
|
|
|
|
DEBUG_FUNCTION_LINE("ERROR_MALLOC_FAILED");
|
|
|
|
this->setError(ERROR_MALLOC_FAILED);
|
|
|
|
return ApplicationState::SUBSTATE_RUNNING;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DEBUG_FUNCTION_LINE("Opened /dev/odd01 %d", this->oddFd);
|
|
|
|
this->state = STATE_READ_DISC_INFO;
|
|
|
|
}
|
|
|
|
} else if (this->state == STATE_PLEASE_INSERT_DISC) {
|
|
|
|
if (entrySelected(input)) {
|
2021-10-16 14:11:28 +02:00
|
|
|
return SUBSTATE_RETURN;
|
2021-10-15 15:41:16 +02:00
|
|
|
}
|
|
|
|
} else if (this->state == STATE_READ_DISC_INFO) {
|
2022-07-26 09:24:06 +02:00
|
|
|
if (FSAEx_RawRead(__wut_devoptab_fs_client, this->sectorBuf, READ_SECTOR_SIZE, 1, 0, this->oddFd) >= 0) {
|
2021-10-15 15:41:16 +02:00
|
|
|
this->discId[10] = '\0';
|
|
|
|
memcpy(this->discId.data(), sectorBuf, 10);
|
|
|
|
this->state = STATE_READ_DISC_INFO_DONE;
|
|
|
|
return ApplicationState::SUBSTATE_RUNNING;
|
|
|
|
}
|
|
|
|
|
|
|
|
this->setError(ERROR_READ_FIRST_SECTOR);
|
|
|
|
return ApplicationState::SUBSTATE_RUNNING;
|
|
|
|
} else if (this->state == STATE_READ_DISC_INFO_DONE) {
|
|
|
|
this->state = STATE_DUMP_DISC_KEY;
|
|
|
|
} else if (this->state == STATE_DUMP_DISC_KEY) {
|
|
|
|
// Read the WiiUDiscContentsHeader to determine if we need disckey and if it's the correct one.
|
2022-07-26 09:24:06 +02:00
|
|
|
auto res = FSAEx_RawRead(__wut_devoptab_fs_client, this->sectorBuf, READ_SECTOR_SIZE, 1, 3, this->oddFd);
|
|
|
|
WUDDiscKey discKey;
|
2021-10-15 15:41:16 +02:00
|
|
|
bool hasDiscKey = false;
|
|
|
|
if (res >= 0) {
|
|
|
|
if (((uint32_t *) this->sectorBuf)[0] != WiiUDiscContentsHeader::MAGIC) {
|
2022-07-26 09:24:06 +02:00
|
|
|
auto discKeyRes = Mocha_ODMGetDiscKey(&discKey);
|
|
|
|
if (discKeyRes == MOCHA_RESULT_SUCCESS) {
|
2021-10-15 15:41:16 +02:00
|
|
|
hasDiscKey = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hasDiscKey) {
|
2022-07-27 19:00:56 +02:00
|
|
|
if (!FSUtils::CreateSubfolder(string_format("%swudump/%s", getPathForDevice(targetDevice).c_str(), getPathNameForDisc().c_str()).c_str())) {
|
2021-10-15 15:41:16 +02:00
|
|
|
setError(ERROR_WRITE_FAILED);
|
|
|
|
return SUBSTATE_RUNNING;
|
|
|
|
}
|
2022-07-27 19:00:56 +02:00
|
|
|
if (!FSUtils::saveBufferToFile(string_format("%swudump/%s/game.key", getPathForDevice(targetDevice).c_str(), getPathNameForDisc().c_str()).c_str(), discKey.key, 16)) {
|
2021-10-15 15:41:16 +02:00
|
|
|
setError(ERROR_WRITE_FAILED);
|
|
|
|
return SUBSTATE_RUNNING;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this->state = STATE_DUMP_DISC_START;
|
|
|
|
} else if (this->state == STATE_DUMP_DISC_START) {
|
2022-07-27 19:00:56 +02:00
|
|
|
if (!FSUtils::CreateSubfolder(string_format("%swudump/%s", getPathForDevice(targetDevice).c_str(), getPathNameForDisc().c_str()).c_str())) {
|
2021-10-15 15:41:16 +02:00
|
|
|
setError(ERROR_WRITE_FAILED);
|
|
|
|
return ApplicationState::SUBSTATE_RUNNING;
|
|
|
|
}
|
2021-10-16 13:03:32 +02:00
|
|
|
if (targetFormat == DUMP_AS_WUX) {
|
2022-07-27 19:00:56 +02:00
|
|
|
this->fileHandle = std::make_unique<WUXFileWriter>(string_format("%swudump/%s/game.wux", getPathForDevice(targetDevice).c_str(), getPathNameForDisc().c_str()).c_str(), READ_SECTOR_SIZE * WRITE_BUFFER_NUM_SECTORS,
|
2021-10-16 17:43:51 +02:00
|
|
|
SECTOR_SIZE, targetDevice == TARGET_SD);
|
2021-10-15 15:41:16 +02:00
|
|
|
} else {
|
2022-07-27 19:00:56 +02:00
|
|
|
this->fileHandle = std::make_unique<WUDFileWriter>(string_format("%swudump/%s/game.wud", getPathForDevice(targetDevice).c_str(), getPathNameForDisc().c_str()).c_str(), READ_SECTOR_SIZE * WRITE_BUFFER_NUM_SECTORS,
|
2021-10-16 17:43:51 +02:00
|
|
|
SECTOR_SIZE, targetDevice == TARGET_SD);
|
2021-10-15 15:41:16 +02:00
|
|
|
}
|
|
|
|
if (!this->fileHandle->isOpen()) {
|
|
|
|
DEBUG_FUNCTION_LINE("Failed to open file");
|
|
|
|
this->setError(ERROR_FILE_OPEN_FAILED);
|
|
|
|
return ApplicationState::SUBSTATE_RUNNING;
|
|
|
|
}
|
|
|
|
|
|
|
|
this->startTime = OSGetTime();
|
|
|
|
|
2022-07-26 08:16:27 +02:00
|
|
|
this->state = STATE_DUMP_DISC;
|
2021-10-15 15:41:16 +02:00
|
|
|
this->totalSectorCount = (WUD_FILE_SIZE / SECTOR_SIZE);
|
2022-07-26 08:16:27 +02:00
|
|
|
this->currentSector = 0;
|
|
|
|
this->writtenSectors = 0;
|
|
|
|
this->retryCount = 10;
|
2021-10-15 15:41:16 +02:00
|
|
|
} else if (this->state == STATE_DUMP_DISC) {
|
2022-07-26 09:24:06 +02:00
|
|
|
if (buttonPressed(input, Input::BUTTON_B)) {
|
|
|
|
this->state = STATE_ABORT_CONFIRMATION;
|
|
|
|
return ApplicationState::SUBSTATE_RUNNING;
|
|
|
|
}
|
|
|
|
|
2021-10-15 15:41:16 +02:00
|
|
|
size_t numSectors = this->currentSector + READ_NUM_SECTORS > this->totalSectorCount ? this->totalSectorCount - this->currentSector : READ_NUM_SECTORS;
|
2022-07-26 09:24:06 +02:00
|
|
|
if ((this->readResult = FSAEx_RawRead(__wut_devoptab_fs_client, sectorBuf, READ_SECTOR_SIZE, numSectors, this->currentSector, this->oddFd)) >= 0) {
|
2021-10-15 15:41:16 +02:00
|
|
|
auto curWrittenSectors = fileHandle->writeSector((const uint8_t *) this->sectorBuf, numSectors);
|
|
|
|
if (curWrittenSectors < 0) {
|
|
|
|
this->setError(ERROR_WRITE_FAILED);
|
|
|
|
return ApplicationState::SUBSTATE_RUNNING;
|
|
|
|
}
|
|
|
|
currentSector += numSectors;
|
|
|
|
this->writtenSectors += curWrittenSectors;
|
|
|
|
|
|
|
|
this->retryCount = 10;
|
|
|
|
if (this->currentSector >= this->totalSectorCount) {
|
|
|
|
this->state = STATE_DUMP_DISC_DONE;
|
|
|
|
if (this->fileHandle->isOpen()) {
|
|
|
|
if (!this->fileHandle->flush()) {
|
|
|
|
DEBUG_FUNCTION_LINE("Flush failed");
|
|
|
|
this->setError(ERROR_WRITE_FAILED);
|
|
|
|
return ApplicationState::SUBSTATE_RUNNING;
|
|
|
|
}
|
2021-10-16 13:03:32 +02:00
|
|
|
this->fileHandle->finalize();
|
2021-10-15 15:41:16 +02:00
|
|
|
this->fileHandle->close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this->state = STATE_WAIT_USER_ERROR_CONFIRM;
|
|
|
|
if (this->oddFd >= 0) {
|
2022-07-26 09:24:06 +02:00
|
|
|
FSAEx_RawClose(__wut_devoptab_fs_client, this->oddFd);
|
2021-10-15 15:41:16 +02:00
|
|
|
this->oddFd = -1;
|
|
|
|
}
|
|
|
|
return ApplicationState::SUBSTATE_RUNNING;
|
|
|
|
}
|
2022-07-26 09:24:06 +02:00
|
|
|
} else if (this->state == STATE_ABORT_CONFIRMATION) {
|
|
|
|
|
|
|
|
if (buttonPressed(input, Input::BUTTON_B)) {
|
|
|
|
this->state = STATE_DUMP_DISC;
|
|
|
|
return ApplicationState::SUBSTATE_RUNNING;
|
|
|
|
}
|
|
|
|
proccessMenuNavigationX(input, 2);
|
|
|
|
if (buttonPressed(input, Input::BUTTON_A)) {
|
|
|
|
if (selectedOptionX == 0) {
|
|
|
|
this->state = STATE_DUMP_DISC;
|
|
|
|
return ApplicationState::SUBSTATE_RUNNING;
|
|
|
|
} else {
|
|
|
|
return ApplicationState::SUBSTATE_RETURN;
|
|
|
|
}
|
|
|
|
}
|
2021-10-15 15:41:16 +02:00
|
|
|
} else if (this->state == STATE_WAIT_USER_ERROR_CONFIRM) {
|
|
|
|
if (this->autoSkipOnError) {
|
|
|
|
if (this->oddFd >= 0) {
|
2022-07-26 09:24:06 +02:00
|
|
|
FSAEx_RawClose(__wut_devoptab_fs_client, this->oddFd);
|
2021-10-15 15:41:16 +02:00
|
|
|
this->oddFd = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (this->autoSkipOnError || (input->data.buttons_d & Input::BUTTON_A)) {
|
|
|
|
// this->log.fwrite("Skipped sector %d : 0x%ll016X-0x%ll016X, filled with 0's\n", this->currentSector, this->currentSector * READ_SECTOR_SIZE, (this->currentSector + 1) * READ_SECTOR_SIZE);
|
|
|
|
this->state = STATE_OPEN_ODD1;
|
|
|
|
this->skippedSectors.push_back(this->currentSector);
|
|
|
|
// We can't use seek because we may have cached values.
|
|
|
|
|
|
|
|
if (this->emptySector == nullptr) {
|
|
|
|
this->emptySector = memalign(0x100, READ_SECTOR_SIZE);
|
|
|
|
if (this->emptySector == nullptr) {
|
|
|
|
this->setError(ERROR_MALLOC_FAILED);
|
|
|
|
return ApplicationState::SUBSTATE_RUNNING;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
auto curWrittenSectors = fileHandle->writeSector((uint8_t *) emptySector, 1);
|
|
|
|
if (curWrittenSectors < 0) {
|
|
|
|
this->setError(ERROR_WRITE_FAILED);
|
|
|
|
return ApplicationState::SUBSTATE_RUNNING;
|
|
|
|
}
|
|
|
|
|
|
|
|
this->currentSector += 1;
|
|
|
|
this->writtenSectors += curWrittenSectors;
|
|
|
|
this->readResult = 0;
|
2022-07-26 09:24:06 +02:00
|
|
|
} else if (buttonPressed(input, Input::BUTTON_B)) {
|
2022-07-26 08:16:27 +02:00
|
|
|
this->state = STATE_OPEN_ODD1;
|
2021-10-15 15:41:16 +02:00
|
|
|
this->readResult = 0;
|
2022-07-26 09:24:06 +02:00
|
|
|
} else if (buttonPressed(input, Input::BUTTON_Y)) {
|
2021-10-15 15:41:16 +02:00
|
|
|
this->autoSkipOnError = true;
|
|
|
|
}
|
|
|
|
} else if (this->state == STATE_DUMP_DISC_DONE) {
|
|
|
|
WiiUScreen::drawLinef("Dumping done! Press A to continue");
|
|
|
|
if (entrySelected(input)) {
|
2021-10-16 14:11:28 +02:00
|
|
|
return SUBSTATE_RETURN;
|
2021-10-15 15:41:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return ApplicationState::SUBSTATE_RUNNING;
|
|
|
|
}
|
|
|
|
return ApplicationState::SUBSTATE_RUNNING;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WUDDumperState::render() {
|
|
|
|
WiiUScreen::clearScreen();
|
|
|
|
ApplicationState::printHeader();
|
|
|
|
if (this->state == STATE_ERROR) {
|
|
|
|
WiiUScreen::drawLine();
|
|
|
|
WiiUScreen::drawLinef("Error: %s", ErrorMessage().c_str());
|
|
|
|
WiiUScreen::drawLinef("Description: %s", ErrorDescription().c_str());
|
|
|
|
WiiUScreen::drawLine();
|
|
|
|
WiiUScreen::drawLine("Press A to return.");
|
|
|
|
} else if (this->state == STATE_OPEN_ODD1) {
|
|
|
|
WiiUScreen::drawLine("Open /dev/odd01");
|
|
|
|
} else if (this->state == STATE_PLEASE_INSERT_DISC) {
|
|
|
|
WiiUScreen::drawLine("Please insert a Wii U disc and try again.\n\nPress A to return");
|
2021-10-16 13:03:32 +02:00
|
|
|
} else if (this->state == STATE_DUMP_DISC_KEY) {
|
|
|
|
WiiUScreen::drawLine("Read disc key");
|
2021-10-15 15:41:16 +02:00
|
|
|
} else if (this->state == STATE_READ_DISC_INFO) {
|
|
|
|
WiiUScreen::drawLine("Read disc information");
|
|
|
|
} else if (this->state == STATE_READ_DISC_INFO_DONE) {
|
2022-07-27 19:00:56 +02:00
|
|
|
WiiUScreen::drawLinef("Dumping: %s", getPathNameForDisc().c_str());
|
2021-10-15 15:41:16 +02:00
|
|
|
} else if (this->state == STATE_DUMP_DISC_START || this->state == STATE_DUMP_DISC || this->state == STATE_WAIT_USER_ERROR_CONFIRM) {
|
2022-07-27 19:00:56 +02:00
|
|
|
WiiUScreen::drawLinef("Dumping: %s", getPathNameForDisc().c_str());
|
2021-10-15 15:41:16 +02:00
|
|
|
|
|
|
|
float percent = this->currentSector / (WUD_FILE_SIZE / READ_SECTOR_SIZE * 1.0f) * 100.0f;
|
|
|
|
WiiUScreen::drawLinef("Progress: %0.2f MiB / %5.2f MiB (%2.1f %%)", this->currentSector * (READ_SECTOR_SIZE / 1024.0f / 1024.0f), WUD_FILE_SIZE / 1024.0f / 1024.0f, percent);
|
2021-10-16 13:03:32 +02:00
|
|
|
if (targetFormat == DUMP_AS_WUX) {
|
2021-10-15 15:41:16 +02:00
|
|
|
WiiUScreen::drawLinef("Written %0.2f MiB. Compression ratio 1:%0.2f", writtenSectors * (READ_SECTOR_SIZE / 1024.0f / 1024.0f),
|
|
|
|
1.0f / (writtenSectors / (float) this->currentSector));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this->readResult < 0 || this->oddFd < 0) {
|
|
|
|
WiiUScreen::drawLine();
|
|
|
|
|
|
|
|
if (this->oddFd < 0) {
|
|
|
|
WiiUScreen::drawLine("Failed to open disc, try again.");
|
|
|
|
} else {
|
|
|
|
WiiUScreen::drawLinef("Error: Failed to read sector - Error %d", this->readResult);
|
|
|
|
}
|
|
|
|
WiiUScreen::drawLine();
|
|
|
|
WiiUScreen::drawLine("Press A to skip this sector (will be replaced by 0's)");
|
|
|
|
WiiUScreen::drawLine("Press B to try again");
|
|
|
|
} else {
|
2022-07-26 08:16:27 +02:00
|
|
|
OSTime curTime = OSGetTime();
|
|
|
|
float remaining = (WUD_FILE_SIZE - (READ_SECTOR_SIZE * this->currentSector)) / 1024.0f / 1024.0f;
|
|
|
|
float curSpeed = READ_SECTOR_SIZE * ((this->currentSector / 1000.0f) / OSTicksToMilliseconds(curTime - startTime));
|
2021-10-15 15:41:16 +02:00
|
|
|
int32_t remainingSec = remaining / curSpeed;
|
2022-07-26 08:16:27 +02:00
|
|
|
int32_t minutes = (remainingSec / 60) % 60;
|
|
|
|
int32_t seconds = remainingSec % 60;
|
|
|
|
int32_t hours = remainingSec / 3600;
|
2021-10-15 15:41:16 +02:00
|
|
|
|
|
|
|
WiiUScreen::drawLinef("Speed: %.2f MiB/s ETA: %02dh %02dm %02ds", curSpeed, remaining, hours, minutes, seconds);
|
|
|
|
}
|
|
|
|
|
|
|
|
WiiUScreen::drawLine();
|
|
|
|
if (!this->skippedSectors.empty()) {
|
|
|
|
WiiUScreen::drawLinef("Skipped dumping %d sectors", this->skippedSectors.size());
|
2022-07-26 09:24:06 +02:00
|
|
|
WiiUScreen::drawLine();
|
2021-10-15 15:41:16 +02:00
|
|
|
}
|
2022-07-26 09:24:06 +02:00
|
|
|
WiiUScreen::drawLinef("Press B to abort");
|
2021-10-15 15:41:16 +02:00
|
|
|
} else if (this->state == STATE_DUMP_DISC_DONE) {
|
|
|
|
WiiUScreen::drawLinef("Dumping done! Press A to continue");
|
2022-07-26 09:24:06 +02:00
|
|
|
} else if (this->state == STATE_ABORT_CONFIRMATION) {
|
|
|
|
WiiUScreen::drawLinef("Do you really want to abort the disc dumping?");
|
|
|
|
WiiUScreen::drawLinef("");
|
|
|
|
if (selectedOptionX == 0) {
|
|
|
|
WiiUScreen::drawLinef("> Continue dumping Abort dumping");
|
|
|
|
} else {
|
|
|
|
WiiUScreen::drawLinef(" Continue dumping > Abort dumping");
|
|
|
|
}
|
2021-10-15 15:41:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ApplicationState::printFooter();
|
|
|
|
WiiUScreen::flipBuffers();
|
|
|
|
}
|
|
|
|
|
|
|
|
void WUDDumperState::setError(WUDDumperState::eErrorState err) {
|
2022-07-26 08:16:27 +02:00
|
|
|
this->state = STATE_ERROR;
|
2021-10-15 15:41:16 +02:00
|
|
|
this->errorState = err;
|
|
|
|
//OSEnableHomeButtonMenu(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string WUDDumperState::ErrorMessage() const {
|
|
|
|
if (this->errorState == ERROR_READ_FIRST_SECTOR) {
|
|
|
|
return "ERROR_READ_FIRST_SECTOR";
|
|
|
|
} else if (this->errorState == ERROR_FILE_OPEN_FAILED) {
|
|
|
|
return "ERROR_FILE_OPEN_FAILED";
|
|
|
|
} else if (this->errorState == ERROR_MALLOC_FAILED) {
|
|
|
|
return "ERROR_MALLOC_FAILED";
|
|
|
|
} else if (this->errorState == ERROR_NO_DISC_ID) {
|
|
|
|
return "ERROR_NO_DISC_ID";
|
|
|
|
} else if (this->errorState == ERROR_WRITE_FAILED) {
|
|
|
|
return "ERROR_WRITE_FAILED";
|
|
|
|
}
|
|
|
|
return "UNKNOWN_ERROR";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string WUDDumperState::ErrorDescription() const {
|
|
|
|
if (this->errorState == ERROR_READ_FIRST_SECTOR) {
|
|
|
|
return "Failed to read first sector.";
|
|
|
|
} else if (this->errorState == ERROR_MALLOC_FAILED) {
|
|
|
|
return "Failed to allocate data.";
|
|
|
|
} else if (this->errorState == ERROR_FILE_OPEN_FAILED) {
|
|
|
|
return "Failed to create file";
|
|
|
|
} else if (this->errorState == ERROR_NO_DISC_ID) {
|
|
|
|
return "Failed to get the disc id";
|
|
|
|
} else if (this->errorState == ERROR_WRITE_FAILED) {
|
|
|
|
return "Failed to write the file. \nMake sure to have enough space on the storage";
|
|
|
|
}
|
|
|
|
return "UNKNOWN_ERROR";
|
|
|
|
}
|
2021-10-16 13:03:32 +02:00
|
|
|
|
|
|
|
std::string WUDDumperState::getPathForDevice(eDumpTarget target) const {
|
|
|
|
if (target == TARGET_NTFS) {
|
|
|
|
return "ntfs0:/";
|
|
|
|
}
|
|
|
|
return "fs:/vol/external01/";
|
|
|
|
}
|
2022-07-27 19:00:56 +02:00
|
|
|
|
|
|
|
std::string WUDDumperState::getPathNameForDisc() {
|
|
|
|
if (this->discId[0] == '\0') {
|
|
|
|
OSCalendarTime tm;
|
|
|
|
OSTicksToCalendarTime(this->dumpStartDate, &tm);
|
|
|
|
return string_format("DISC-%04d-%02d-%02d-%02d-%02d-%02d",
|
|
|
|
tm.tm_year, tm.tm_mon + 1, tm.tm_mday,
|
|
|
|
tm.tm_hour, tm.tm_min, tm.tm_sec);
|
|
|
|
}
|
|
|
|
return std::string((char *) &discId[0]);
|
|
|
|
}
|