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 "Controller.h"
|
||||||
|
#include "FileChecker.h"
|
||||||
#include "ConsoleBackup.h"
|
#include "ConsoleBackup.h"
|
||||||
#include "Exporter.h"
|
#include "Exporter.h"
|
||||||
#include "SimplePlayer.h"
|
#include "SimplePlayer.h"
|
||||||
@ -37,6 +38,9 @@ typedef enum BackupState
|
|||||||
} BackupState;
|
} BackupState;
|
||||||
|
|
||||||
|
|
||||||
|
// APSettingの書式が無い警告サウンドを鳴らしたかどうか
|
||||||
|
bool s_ExistAPSettingAnnotation = false;
|
||||||
|
|
||||||
BackupState s_BackupState = STARTUP;
|
BackupState s_BackupState = STARTUP;
|
||||||
bool s_PlayedFinishedSound = false;
|
bool s_PlayedFinishedSound = false;
|
||||||
bool s_PlayedFailSound = false;
|
bool s_PlayedFailSound = false;
|
||||||
@ -64,26 +68,40 @@ void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep,
|
|||||||
// SDカードが挿入されているか?
|
// SDカードが挿入されているか?
|
||||||
if (nn::fs::IsSdmcInserted())
|
if (nn::fs::IsSdmcInserted())
|
||||||
{
|
{
|
||||||
// 書き込み中に抜かないように
|
// 無線設定ファイルがあるか?
|
||||||
if (nextStep)
|
if (common::ExistsAPSetting())
|
||||||
{
|
{
|
||||||
// SDカードに書き込みできるか?
|
// 書き込み中に抜かないように
|
||||||
if (nn::fs::IsSdmcWritable())
|
if (nextStep)
|
||||||
{
|
{
|
||||||
// シリアルナンバーを読み取れるか?
|
// SDカードに書き込みできるか?
|
||||||
if (!CanReadSerialNumber())
|
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
|
else
|
||||||
@ -211,6 +229,7 @@ void OnSdEjected()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
common::InitializeFileCheck();
|
||||||
InitializeState();
|
InitializeState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -220,6 +239,7 @@ void InitializeState()
|
|||||||
s_BackupState = STARTUP;
|
s_BackupState = STARTUP;
|
||||||
s_PlayedFailSound = false;
|
s_PlayedFailSound = false;
|
||||||
s_PlayedFinishedSound = false;
|
s_PlayedFinishedSound = false;
|
||||||
|
s_ExistAPSettingAnnotation = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ConsoleBackup
|
} // namespace ConsoleBackup
|
||||||
|
|||||||
@ -31,6 +31,7 @@ SOURCES[] =
|
|||||||
Exporter.cpp
|
Exporter.cpp
|
||||||
../common/DrawSystemState.cpp
|
../common/DrawSystemState.cpp
|
||||||
../common/FileTransfer.cpp
|
../common/FileTransfer.cpp
|
||||||
|
../common/FileChecker.cpp
|
||||||
../common/SdReaderWriter.cpp
|
../common/SdReaderWriter.cpp
|
||||||
../common/HeapManager.cpp
|
../common/HeapManager.cpp
|
||||||
../common/SdLogger.cpp
|
../common/SdLogger.cpp
|
||||||
|
|||||||
@ -20,6 +20,7 @@
|
|||||||
#include <nn/ptm/CTR/ptm_ApiSysmenu.h>
|
#include <nn/ptm/CTR/ptm_ApiSysmenu.h>
|
||||||
|
|
||||||
#include "Controller.h"
|
#include "Controller.h"
|
||||||
|
#include "FileChecker.h"
|
||||||
#include "ConsoleRestore.h"
|
#include "ConsoleRestore.h"
|
||||||
#include "SimplePlayer.h"
|
#include "SimplePlayer.h"
|
||||||
#include "CommonLogger.h"
|
#include "CommonLogger.h"
|
||||||
@ -83,6 +84,8 @@ bool NeedsAcAdater()
|
|||||||
|
|
||||||
bool CheckAndReadAPSetting(::std::vector<std::string>& operationMessage)
|
bool CheckAndReadAPSetting(::std::vector<std::string>& operationMessage)
|
||||||
{
|
{
|
||||||
|
using namespace common;
|
||||||
|
|
||||||
if (!ExistsAPSetting())
|
if (!ExistsAPSetting())
|
||||||
{
|
{
|
||||||
if(!s_ExistAPSettingAnnotation)
|
if(!s_ExistAPSettingAnnotation)
|
||||||
@ -140,7 +143,7 @@ void PutAliveMessage(::std::vector<std::string>& operationMessage, const char* s
|
|||||||
|
|
||||||
void ExecSyncMcuRtc()
|
void ExecSyncMcuRtc()
|
||||||
{
|
{
|
||||||
if(!ExistsRtcSyncFinishedFile())
|
if(!common::ExistsRtcSyncFinishedFile())
|
||||||
{
|
{
|
||||||
ImportMcuRtc();
|
ImportMcuRtc();
|
||||||
// 時計を無効化する
|
// 時計を無効化する
|
||||||
@ -150,6 +153,8 @@ void ExecSyncMcuRtc()
|
|||||||
|
|
||||||
void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep, bool& continueRestore)
|
void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep, bool& continueRestore)
|
||||||
{
|
{
|
||||||
|
using namespace common;
|
||||||
|
|
||||||
// 状態遷移Controller
|
// 状態遷移Controller
|
||||||
switch (s_RestoreState)
|
switch (s_RestoreState)
|
||||||
{
|
{
|
||||||
@ -212,7 +217,7 @@ void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep,
|
|||||||
if (nextStep && !nn::fs::IsSdmcWritable())
|
if (nextStep && !nn::fs::IsSdmcWritable())
|
||||||
{
|
{
|
||||||
error = true;
|
error = true;
|
||||||
common::PlaySound(common::SOUND_ANNOTATION);
|
PlaySound(SOUND_ANNOTATION);
|
||||||
COMMON_LOGGER("Can't Write SD Card!!\n");
|
COMMON_LOGGER("Can't Write SD Card!!\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -303,19 +308,19 @@ void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep,
|
|||||||
ExecSyncMcuRtc();
|
ExecSyncMcuRtc();
|
||||||
|
|
||||||
s_RestoreState = UPDATE_IN_PROGRESS;
|
s_RestoreState = UPDATE_IN_PROGRESS;
|
||||||
common::PlaySound(common::SOUND_CURSOR);
|
PlaySound(SOUND_CURSOR);
|
||||||
}
|
}
|
||||||
else if(needsErase)
|
else if(needsErase)
|
||||||
{
|
{
|
||||||
COMMON_LOGGER("Erase Trash\n");
|
COMMON_LOGGER("Erase Trash\n");
|
||||||
s_RestoreState = ERASE;
|
s_RestoreState = ERASE;
|
||||||
common::PlaySound(common::SOUND_CURSOR);
|
PlaySound(SOUND_CURSOR);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
COMMON_LOGGER("Start Import Data\n");
|
COMMON_LOGGER("Start Import Data\n");
|
||||||
s_RestoreState = RESTORE_IN_PROGRESS;
|
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)
|
if (!s_SerialNumberAnnotation)
|
||||||
{
|
{
|
||||||
s_SerialNumberAnnotation = true;
|
s_SerialNumberAnnotation = true;
|
||||||
common::PlaySound(common::SOUND_ANNOTATION);
|
PlaySound(SOUND_ANNOTATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextStep)
|
if (nextStep)
|
||||||
@ -543,7 +548,7 @@ void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep,
|
|||||||
static bool init = true;
|
static bool init = true;
|
||||||
if (init)
|
if (init)
|
||||||
{
|
{
|
||||||
common::PlaySound(common::SOUND_OK);
|
PlaySound(SOUND_OK);
|
||||||
init = false;
|
init = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -555,7 +560,7 @@ void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep,
|
|||||||
operationMessage.push_back(::std::string("Failed."));
|
operationMessage.push_back(::std::string("Failed."));
|
||||||
if (!s_PlayedFailSound)
|
if (!s_PlayedFailSound)
|
||||||
{
|
{
|
||||||
common::PlaySound(common::SOUND_NG);
|
PlaySound(SOUND_NG);
|
||||||
s_PlayedFailSound = true;
|
s_PlayedFailSound = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -588,6 +593,7 @@ void OnSdEjected()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
InitializeState();
|
InitializeState();
|
||||||
|
ClearFileReadReslt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -595,7 +601,7 @@ void InitializeState()
|
|||||||
{
|
{
|
||||||
s_RestoreState = STARTUP;
|
s_RestoreState = STARTUP;
|
||||||
|
|
||||||
InitializeFileCheck();
|
common::InitializeFileCheck();
|
||||||
|
|
||||||
s_ExistAPSettingAnnotation = false;
|
s_ExistAPSettingAnnotation = false;
|
||||||
s_ReadSettingDone = false;
|
s_ReadSettingDone = false;
|
||||||
|
|||||||
@ -63,12 +63,6 @@ TimeZone s_TimeZone;
|
|||||||
const size_t NTP_SERVER_NAME_LENGTH = 256;
|
const size_t NTP_SERVER_NAME_LENGTH = 256;
|
||||||
char s_NtpServerName[NTP_SERVER_NAME_LENGTH];
|
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_CheckedEqualsIVSFileandIVS = false;
|
||||||
bool s_ReadSerialNumber = false;
|
bool s_ReadSerialNumber = false;
|
||||||
|
|
||||||
@ -177,30 +171,6 @@ void ConvertTimeZoneString(const char* str)
|
|||||||
namespace
|
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)
|
bool CreateEmptyFile(const wchar_t* path)
|
||||||
{
|
{
|
||||||
nn::Result result;
|
nn::Result result;
|
||||||
@ -225,50 +195,6 @@ bool CreateEmptyFile(const wchar_t* path)
|
|||||||
return create;
|
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()
|
u8* ReadSerialNumber()
|
||||||
@ -287,21 +213,6 @@ u8* ReadSerialNumber()
|
|||||||
s_ReadSerialNumber = true;
|
s_ReadSerialNumber = true;
|
||||||
return s_SerialNo;
|
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()
|
bool EqualsIVSFileandIVS()
|
||||||
{
|
{
|
||||||
nn::Result result;
|
nn::Result result;
|
||||||
@ -372,11 +283,6 @@ bool EqualsIVSFileandIVS()
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ExistsConsoleInitializedFile()
|
|
||||||
{
|
|
||||||
return ExistsFile(EXISTS_CONSOLE_INTIALIZED);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetCountry(nn::cfg::CTR::CfgCountryCode countryCode)
|
void SetCountry(nn::cfg::CTR::CfgCountryCode countryCode)
|
||||||
{
|
{
|
||||||
using namespace nn::cfg::CTR;
|
using namespace nn::cfg::CTR;
|
||||||
@ -1263,6 +1169,11 @@ void ImportTwlSoundData()
|
|||||||
ImportTwlData(common::TWL_SOUND);
|
ImportTwlData(common::TWL_SOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClearFileReadReslt()
|
||||||
|
{
|
||||||
|
s_CheckedEqualsIVSFileandIVS = false;
|
||||||
|
s_ReadSerialNumber = false;
|
||||||
|
}
|
||||||
|
|
||||||
void ImportData()
|
void ImportData()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -23,39 +23,8 @@
|
|||||||
namespace ConsoleRestore
|
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 EqualsIVSFileandIVS();
|
||||||
bool ExistsConsoleInitializedFile();
|
|
||||||
void InitializeFileCheck();
|
|
||||||
u8* ReadSerialNumber();
|
u8* ReadSerialNumber();
|
||||||
bool ExistsWriteFinishedFile();
|
|
||||||
bool ExistsAPSetting();
|
|
||||||
bool ExistsRtcSyncFinishedFile();
|
|
||||||
|
|
||||||
bool IsImportFinished();
|
bool IsImportFinished();
|
||||||
void ImportData();
|
void ImportData();
|
||||||
@ -96,6 +65,7 @@ void ImportMcuRtc();
|
|||||||
// TWL写真領域を初期化してから本体初期化を行う
|
// TWL写真領域を初期化してから本体初期化を行う
|
||||||
void InitializeFileSystem();
|
void InitializeFileSystem();
|
||||||
|
|
||||||
|
void ClearFileReadReslt();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* IMPORTER_H_ */
|
#endif /* IMPORTER_H_ */
|
||||||
|
|||||||
@ -33,6 +33,7 @@ SOURCES[] =
|
|||||||
Ntpclient.cpp
|
Ntpclient.cpp
|
||||||
../common/DrawSystemState.cpp
|
../common/DrawSystemState.cpp
|
||||||
../common/FileTransfer.cpp
|
../common/FileTransfer.cpp
|
||||||
|
../common/FileChecker.cpp
|
||||||
../common/SdReaderWriter.cpp
|
../common/SdReaderWriter.cpp
|
||||||
../common/HeapManager.cpp
|
../common/HeapManager.cpp
|
||||||
../common/SdLogger.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