mirror of
https://github.com/rvtr/ctr_Repair.git
synced 2025-10-31 13:51:08 -04:00
ファイル存在確認を分離
吸出し開始時にも無線設定ファイルの有無を確認するように git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@19 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
parent
7558677f1f
commit
a08546ff0f
@ -14,6 +14,7 @@
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "Controller.h"
|
||||
#include "FileChecker.h"
|
||||
#include "ConsoleBackup.h"
|
||||
#include "Exporter.h"
|
||||
#include "SimplePlayer.h"
|
||||
@ -37,6 +38,9 @@ typedef enum BackupState
|
||||
} BackupState;
|
||||
|
||||
|
||||
// APSettingの書式が無い警告サウンドを鳴らしたかどうか
|
||||
bool s_ExistAPSettingAnnotation = false;
|
||||
|
||||
BackupState s_BackupState = STARTUP;
|
||||
bool s_PlayedFinishedSound = false;
|
||||
bool s_PlayedFailSound = false;
|
||||
@ -64,26 +68,40 @@ void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep,
|
||||
// SDカードが挿入されているか?
|
||||
if (nn::fs::IsSdmcInserted())
|
||||
{
|
||||
// 書き込み中に抜かないように
|
||||
if (nextStep)
|
||||
// 無線設定ファイルがあるか?
|
||||
if (common::ExistsAPSetting())
|
||||
{
|
||||
// SDカードに書き込みできるか?
|
||||
if (nn::fs::IsSdmcWritable())
|
||||
// 書き込み中に抜かないように
|
||||
if (nextStep)
|
||||
{
|
||||
// シリアルナンバーを読み取れるか?
|
||||
if (!CanReadSerialNumber())
|
||||
// SDカードに書き込みできるか?
|
||||
if (nn::fs::IsSdmcWritable())
|
||||
{
|
||||
common::PlaySound(common::SOUND_ANNOTATION);
|
||||
COMMON_LOGGER("Can't Read Serial Number\n");
|
||||
// シリアルナンバーを読み取れるか?
|
||||
if (!CanReadSerialNumber())
|
||||
{
|
||||
common::PlaySound(common::SOUND_ANNOTATION);
|
||||
COMMON_LOGGER("Can't Read Serial Number\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
error = true;
|
||||
common::PlaySound(common::SOUND_ANNOTATION);
|
||||
COMMON_LOGGER("Can't Write SD Card!!\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
error = true;
|
||||
common::PlaySound(common::SOUND_ANNOTATION);
|
||||
COMMON_LOGGER("Can't Write SD Card!!\n");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
error = true;
|
||||
if (!s_ExistAPSettingAnnotation)
|
||||
{
|
||||
s_ExistAPSettingAnnotation = true;
|
||||
common::PlaySound(common::SOUND_ANNOTATION);
|
||||
}
|
||||
operationMessage.push_back(::std::string("APSetting.txt does not exist!"));
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -211,6 +229,7 @@ void OnSdEjected()
|
||||
}
|
||||
else
|
||||
{
|
||||
common::InitializeFileCheck();
|
||||
InitializeState();
|
||||
}
|
||||
}
|
||||
@ -220,6 +239,7 @@ void InitializeState()
|
||||
s_BackupState = STARTUP;
|
||||
s_PlayedFailSound = false;
|
||||
s_PlayedFinishedSound = false;
|
||||
s_ExistAPSettingAnnotation = false;
|
||||
}
|
||||
|
||||
} // namespace ConsoleBackup
|
||||
|
||||
@ -31,6 +31,7 @@ SOURCES[] =
|
||||
Exporter.cpp
|
||||
../common/DrawSystemState.cpp
|
||||
../common/FileTransfer.cpp
|
||||
../common/FileChecker.cpp
|
||||
../common/SdReaderWriter.cpp
|
||||
../common/HeapManager.cpp
|
||||
../common/SdLogger.cpp
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
#include <nn/ptm/CTR/ptm_ApiSysmenu.h>
|
||||
|
||||
#include "Controller.h"
|
||||
#include "FileChecker.h"
|
||||
#include "ConsoleRestore.h"
|
||||
#include "SimplePlayer.h"
|
||||
#include "CommonLogger.h"
|
||||
@ -83,6 +84,8 @@ bool NeedsAcAdater()
|
||||
|
||||
bool CheckAndReadAPSetting(::std::vector<std::string>& operationMessage)
|
||||
{
|
||||
using namespace common;
|
||||
|
||||
if (!ExistsAPSetting())
|
||||
{
|
||||
if(!s_ExistAPSettingAnnotation)
|
||||
@ -140,7 +143,7 @@ void PutAliveMessage(::std::vector<std::string>& operationMessage, const char* s
|
||||
|
||||
void ExecSyncMcuRtc()
|
||||
{
|
||||
if(!ExistsRtcSyncFinishedFile())
|
||||
if(!common::ExistsRtcSyncFinishedFile())
|
||||
{
|
||||
ImportMcuRtc();
|
||||
// 時計を無効化する
|
||||
@ -150,6 +153,8 @@ void ExecSyncMcuRtc()
|
||||
|
||||
void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep, bool& continueRestore)
|
||||
{
|
||||
using namespace common;
|
||||
|
||||
// 状態遷移Controller
|
||||
switch (s_RestoreState)
|
||||
{
|
||||
@ -212,7 +217,7 @@ void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep,
|
||||
if (nextStep && !nn::fs::IsSdmcWritable())
|
||||
{
|
||||
error = true;
|
||||
common::PlaySound(common::SOUND_ANNOTATION);
|
||||
PlaySound(SOUND_ANNOTATION);
|
||||
COMMON_LOGGER("Can't Write SD Card!!\n");
|
||||
}
|
||||
}
|
||||
@ -303,19 +308,19 @@ void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep,
|
||||
ExecSyncMcuRtc();
|
||||
|
||||
s_RestoreState = UPDATE_IN_PROGRESS;
|
||||
common::PlaySound(common::SOUND_CURSOR);
|
||||
PlaySound(SOUND_CURSOR);
|
||||
}
|
||||
else if(needsErase)
|
||||
{
|
||||
COMMON_LOGGER("Erase Trash\n");
|
||||
s_RestoreState = ERASE;
|
||||
common::PlaySound(common::SOUND_CURSOR);
|
||||
PlaySound(SOUND_CURSOR);
|
||||
}
|
||||
else
|
||||
{
|
||||
COMMON_LOGGER("Start Import Data\n");
|
||||
s_RestoreState = RESTORE_IN_PROGRESS;
|
||||
common::PlaySound(common::SOUND_CURSOR);
|
||||
PlaySound(SOUND_CURSOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -331,7 +336,7 @@ void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep,
|
||||
if (!s_SerialNumberAnnotation)
|
||||
{
|
||||
s_SerialNumberAnnotation = true;
|
||||
common::PlaySound(common::SOUND_ANNOTATION);
|
||||
PlaySound(SOUND_ANNOTATION);
|
||||
}
|
||||
|
||||
if (nextStep)
|
||||
@ -543,7 +548,7 @@ void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep,
|
||||
static bool init = true;
|
||||
if (init)
|
||||
{
|
||||
common::PlaySound(common::SOUND_OK);
|
||||
PlaySound(SOUND_OK);
|
||||
init = false;
|
||||
}
|
||||
}
|
||||
@ -555,7 +560,7 @@ void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep,
|
||||
operationMessage.push_back(::std::string("Failed."));
|
||||
if (!s_PlayedFailSound)
|
||||
{
|
||||
common::PlaySound(common::SOUND_NG);
|
||||
PlaySound(SOUND_NG);
|
||||
s_PlayedFailSound = true;
|
||||
}
|
||||
}
|
||||
@ -588,6 +593,7 @@ void OnSdEjected()
|
||||
else
|
||||
{
|
||||
InitializeState();
|
||||
ClearFileReadReslt();
|
||||
}
|
||||
}
|
||||
|
||||
@ -595,7 +601,7 @@ void InitializeState()
|
||||
{
|
||||
s_RestoreState = STARTUP;
|
||||
|
||||
InitializeFileCheck();
|
||||
common::InitializeFileCheck();
|
||||
|
||||
s_ExistAPSettingAnnotation = false;
|
||||
s_ReadSettingDone = false;
|
||||
|
||||
@ -63,12 +63,6 @@ TimeZone s_TimeZone;
|
||||
const size_t NTP_SERVER_NAME_LENGTH = 256;
|
||||
char s_NtpServerName[NTP_SERVER_NAME_LENGTH];
|
||||
|
||||
// ファイルの存在確認
|
||||
bool CheckFileExists(const wchar_t* path);
|
||||
|
||||
bool s_FileExistsChecked[EXISTS_MAX];
|
||||
bool s_FileExistsCheckeResult[EXISTS_MAX];
|
||||
|
||||
bool s_CheckedEqualsIVSFileandIVS = false;
|
||||
bool s_ReadSerialNumber = false;
|
||||
|
||||
@ -177,30 +171,6 @@ void ConvertTimeZoneString(const char* str)
|
||||
namespace
|
||||
{
|
||||
|
||||
bool CheckFileExists(const wchar_t* path)
|
||||
{
|
||||
nn::Result result;
|
||||
bool exist = false;
|
||||
result = common::SdMountManager::Mount();
|
||||
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
nn::fs::FileInputStream fis;
|
||||
|
||||
result = fis.TryInitialize(path);
|
||||
if(result.IsSuccess())
|
||||
{
|
||||
exist = true;
|
||||
}
|
||||
fis.Finalize();
|
||||
}
|
||||
|
||||
common::SdMountManager::Unmount();
|
||||
|
||||
|
||||
return exist;
|
||||
}
|
||||
|
||||
bool CreateEmptyFile(const wchar_t* path)
|
||||
{
|
||||
nn::Result result;
|
||||
@ -225,50 +195,6 @@ bool CreateEmptyFile(const wchar_t* path)
|
||||
return create;
|
||||
}
|
||||
|
||||
bool ExistsFile(FileExistsCheck index)
|
||||
{
|
||||
if(index > EXISTS_MAX)
|
||||
{
|
||||
NN_LOG("Invalid File index!!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(s_FileExistsChecked[index])
|
||||
{
|
||||
return s_FileExistsCheckeResult[index];
|
||||
}
|
||||
|
||||
s_FileExistsChecked[index] = true;
|
||||
s_FileExistsCheckeResult[index] = CheckFileExists(FILENAME_TABLE[index]);
|
||||
return s_FileExistsCheckeResult[index];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool ExistsUpdateCheckedFile()
|
||||
{
|
||||
return ExistsFile(EXISTS_UPDATE_FINISHED);
|
||||
}
|
||||
|
||||
bool ExistsSerialNumberFile()
|
||||
{
|
||||
return ExistsFile(EXISTS_SERIAL_NUMBER);
|
||||
}
|
||||
|
||||
bool ExistsIVSFile()
|
||||
{
|
||||
return ExistsFile(EXISTS_IVS);
|
||||
}
|
||||
|
||||
void InitializeFileCheck()
|
||||
{
|
||||
for(u32 i = 0; i < EXISTS_MAX; i++)
|
||||
{
|
||||
s_FileExistsChecked[i] = false;
|
||||
}
|
||||
|
||||
s_CheckedEqualsIVSFileandIVS = false;
|
||||
s_ReadSerialNumber = false;
|
||||
}
|
||||
|
||||
u8* ReadSerialNumber()
|
||||
@ -287,21 +213,6 @@ u8* ReadSerialNumber()
|
||||
s_ReadSerialNumber = true;
|
||||
return s_SerialNo;
|
||||
}
|
||||
bool ExistsWriteFinishedFile()
|
||||
{
|
||||
return ExistsFile(EXISTS_WRITE_FINISHED);
|
||||
}
|
||||
|
||||
bool ExistsAPSetting()
|
||||
{
|
||||
return ExistsFile(EXISTS_AP_SETTING);
|
||||
}
|
||||
|
||||
bool ExistsRtcSyncFinishedFile()
|
||||
{
|
||||
return ExistsFile(EXISTS_RTC_SYNC_FINISHED);
|
||||
}
|
||||
|
||||
bool EqualsIVSFileandIVS()
|
||||
{
|
||||
nn::Result result;
|
||||
@ -372,11 +283,6 @@ bool EqualsIVSFileandIVS()
|
||||
return retval;
|
||||
}
|
||||
|
||||
bool ExistsConsoleInitializedFile()
|
||||
{
|
||||
return ExistsFile(EXISTS_CONSOLE_INTIALIZED);
|
||||
}
|
||||
|
||||
void SetCountry(nn::cfg::CTR::CfgCountryCode countryCode)
|
||||
{
|
||||
using namespace nn::cfg::CTR;
|
||||
@ -1263,6 +1169,11 @@ void ImportTwlSoundData()
|
||||
ImportTwlData(common::TWL_SOUND);
|
||||
}
|
||||
|
||||
void ClearFileReadReslt()
|
||||
{
|
||||
s_CheckedEqualsIVSFileandIVS = false;
|
||||
s_ReadSerialNumber = false;
|
||||
}
|
||||
|
||||
void ImportData()
|
||||
{
|
||||
|
||||
@ -23,39 +23,8 @@
|
||||
namespace ConsoleRestore
|
||||
{
|
||||
|
||||
typedef enum FILE_EXISTS_CHECK
|
||||
{
|
||||
EXISTS_UPDATE_FINISHED,
|
||||
EXISTS_SERIAL_NUMBER,
|
||||
EXISTS_IVS,
|
||||
EXISTS_CONSOLE_INTIALIZED,
|
||||
EXISTS_WRITE_FINISHED,
|
||||
EXISTS_AP_SETTING,
|
||||
EXISTS_RTC_SYNC_FINISHED,
|
||||
EXISTS_MAX
|
||||
} FileExistsCheck;
|
||||
|
||||
const wchar_t* const FILENAME_TABLE[EXISTS_MAX] =
|
||||
{
|
||||
common::UPDATE_CHECK_PATHNAME,
|
||||
common::SERIAL_PATHNAME,
|
||||
common::IVS_PATHNAME,
|
||||
common::INITIALIZED_CHECK_PATHNAME,
|
||||
common::WRITE_FINISHED_PATHNAME,
|
||||
common::AP_SETTING_PATHNAME,
|
||||
common::RTC_SYNC_CHECK_PATHNAME
|
||||
};
|
||||
|
||||
bool ExistsUpdateCheckedFile();
|
||||
bool ExistsSerialNumberFile();
|
||||
bool ExistsIVSFile();
|
||||
bool EqualsIVSFileandIVS();
|
||||
bool ExistsConsoleInitializedFile();
|
||||
void InitializeFileCheck();
|
||||
u8* ReadSerialNumber();
|
||||
bool ExistsWriteFinishedFile();
|
||||
bool ExistsAPSetting();
|
||||
bool ExistsRtcSyncFinishedFile();
|
||||
|
||||
bool IsImportFinished();
|
||||
void ImportData();
|
||||
@ -96,6 +65,7 @@ void ImportMcuRtc();
|
||||
// TWL写真領域を初期化してから本体初期化を行う
|
||||
void InitializeFileSystem();
|
||||
|
||||
void ClearFileReadReslt();
|
||||
}
|
||||
|
||||
#endif /* IMPORTER_H_ */
|
||||
|
||||
@ -33,6 +33,7 @@ SOURCES[] =
|
||||
Ntpclient.cpp
|
||||
../common/DrawSystemState.cpp
|
||||
../common/FileTransfer.cpp
|
||||
../common/FileChecker.cpp
|
||||
../common/SdReaderWriter.cpp
|
||||
../common/HeapManager.cpp
|
||||
../common/SdLogger.cpp
|
||||
|
||||
113
trunk/ConsoleDataMigration/common/FileChecker.cpp
Normal file
113
trunk/ConsoleDataMigration/common/FileChecker.cpp
Normal file
@ -0,0 +1,113 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: FileChecker.cpp
|
||||
|
||||
Copyright 2009 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <nn.h>
|
||||
#include "FileChecker.h"
|
||||
#include "SdMountManager.h"
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
bool s_FileExistsChecked[EXISTS_MAX];
|
||||
bool s_FileExistsCheckeResult[EXISTS_MAX];
|
||||
|
||||
bool CheckFileExists(const wchar_t* path)
|
||||
{
|
||||
nn::Result result;
|
||||
bool exist = false;
|
||||
result = common::SdMountManager::Mount();
|
||||
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
nn::fs::FileInputStream fis;
|
||||
|
||||
result = fis.TryInitialize(path);
|
||||
if(result.IsSuccess())
|
||||
{
|
||||
exist = true;
|
||||
}
|
||||
fis.Finalize();
|
||||
}
|
||||
|
||||
common::SdMountManager::Unmount();
|
||||
|
||||
|
||||
return exist;
|
||||
}
|
||||
|
||||
bool ExistsFile(FileExistsCheck index)
|
||||
{
|
||||
if(index > EXISTS_MAX)
|
||||
{
|
||||
NN_LOG("Invalid File index!!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(s_FileExistsChecked[index])
|
||||
{
|
||||
return s_FileExistsCheckeResult[index];
|
||||
}
|
||||
|
||||
s_FileExistsChecked[index] = true;
|
||||
s_FileExistsCheckeResult[index] = CheckFileExists(FILENAME_TABLE[index]);
|
||||
return s_FileExistsCheckeResult[index];
|
||||
}
|
||||
|
||||
bool ExistsUpdateCheckedFile()
|
||||
{
|
||||
return ExistsFile(EXISTS_UPDATE_FINISHED);
|
||||
}
|
||||
|
||||
bool ExistsSerialNumberFile()
|
||||
{
|
||||
return ExistsFile(EXISTS_SERIAL_NUMBER);
|
||||
}
|
||||
|
||||
bool ExistsIVSFile()
|
||||
{
|
||||
return ExistsFile(EXISTS_IVS);
|
||||
}
|
||||
|
||||
bool ExistsConsoleInitializedFile()
|
||||
{
|
||||
return ExistsFile(EXISTS_CONSOLE_INTIALIZED);
|
||||
}
|
||||
|
||||
bool ExistsWriteFinishedFile()
|
||||
{
|
||||
return ExistsFile(EXISTS_WRITE_FINISHED);
|
||||
}
|
||||
|
||||
bool ExistsAPSetting()
|
||||
{
|
||||
return ExistsFile(EXISTS_AP_SETTING);
|
||||
}
|
||||
|
||||
bool ExistsRtcSyncFinishedFile()
|
||||
{
|
||||
return ExistsFile(EXISTS_RTC_SYNC_FINISHED);
|
||||
}
|
||||
|
||||
|
||||
void InitializeFileCheck()
|
||||
{
|
||||
for(u32 i = 0; i < EXISTS_MAX; i++)
|
||||
{
|
||||
s_FileExistsChecked[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
60
trunk/ConsoleDataMigration/common/FileChecker.h
Normal file
60
trunk/ConsoleDataMigration/common/FileChecker.h
Normal file
@ -0,0 +1,60 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: FileChecker.h
|
||||
|
||||
Copyright 2009 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef FILECHECKER_H_
|
||||
#define FILECHECKER_H_
|
||||
|
||||
#include "FileName.h"
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
typedef enum FILE_EXISTS_CHECK
|
||||
{
|
||||
EXISTS_UPDATE_FINISHED,
|
||||
EXISTS_SERIAL_NUMBER,
|
||||
EXISTS_IVS,
|
||||
EXISTS_CONSOLE_INTIALIZED,
|
||||
EXISTS_WRITE_FINISHED,
|
||||
EXISTS_AP_SETTING,
|
||||
EXISTS_RTC_SYNC_FINISHED,
|
||||
EXISTS_MAX
|
||||
} FileExistsCheck;
|
||||
|
||||
const wchar_t* const FILENAME_TABLE[EXISTS_MAX] =
|
||||
{
|
||||
common::UPDATE_CHECK_PATHNAME,
|
||||
common::SERIAL_PATHNAME,
|
||||
common::IVS_PATHNAME,
|
||||
common::INITIALIZED_CHECK_PATHNAME,
|
||||
common::WRITE_FINISHED_PATHNAME,
|
||||
common::AP_SETTING_PATHNAME,
|
||||
common::RTC_SYNC_CHECK_PATHNAME
|
||||
};
|
||||
|
||||
|
||||
bool ExistsUpdateCheckedFile();
|
||||
bool ExistsSerialNumberFile();
|
||||
bool ExistsIVSFile();
|
||||
bool ExistsConsoleInitializedFile();
|
||||
bool ExistsWriteFinishedFile();
|
||||
bool ExistsAPSetting();
|
||||
bool ExistsRtcSyncFinishedFile();
|
||||
|
||||
void InitializeFileCheck();
|
||||
|
||||
}
|
||||
|
||||
#endif /* FILECHECKER_H_ */
|
||||
Loading…
Reference in New Issue
Block a user