チェックエラー発生時の出力にディレクトリ名を付加。コードネームを置換

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@443 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
N2614 2011-10-05 09:11:38 +00:00
parent a6f0593494
commit 14a5daadd4
2 changed files with 106 additions and 86 deletions

View File

@ -23,11 +23,6 @@
namespace ConsoleBackup
{
namespace
{
}
SavedataCheckerBase::SavedataCheckerBase(void* buf, size_t size) :
m_Buf(buf), m_Bufsize(size), m_CalculatedFileSize(0), m_TotalReadSize(0), m_CheckErrorOccured(false)
{
@ -39,7 +34,8 @@ SavedataCheckerBase::~SavedataCheckerBase()
NN_LOG("m_TotalReadSize = %lld\n", m_TotalReadSize);
}
nn::Result SavedataCheckerBase::CleanUpFilesRecursively(bool* modified, std::wstring currentDirectory, bool erase)
nn::Result SavedataCheckerBase::CleanUpFilesRecursively(bool* modified, std::string baseName,
std::wstring currentDirectory, bool erase)
{
nn::fs::Directory dir;
nn::fs::DirectoryEntry entry;
@ -47,13 +43,15 @@ nn::Result SavedataCheckerBase::CleanUpFilesRecursively(bool* modified, std::wst
NN_LOG("%s\n", common::GetCharStr(currentDirectory.c_str()));
result = dir.TryInitialize(currentDirectory.c_str());
if(result.IsFailure())
if (result.IsFailure())
{
COMMON_LOGGER_WARN("Error: %s\n", common::GetCharStr(currentDirectory.c_str()));
COMMON_LOGGER_WARN(
"Error: %s/%s\n", baseName.c_str(), common::GetCharStr(GetFilePathWithoutArchive(currentDirectory).c_str()));
m_CheckErrorOccured = true;
if (erase)
{
COMMON_LOGGER_WARN("Deleting: %s\n", common::GetCharStr(currentDirectory.c_str()));
COMMON_LOGGER_WARN(
"Deleting: %s%/s\n", baseName.c_str(), common::GetCharStr(GetFilePathWithoutArchive(currentDirectory).c_str()));
result = nn::fs::TryDeleteDirectory(currentDirectory.c_str());
COMMON_LOGGER_RETURN_RESULT_IF_FAILED(result);
*modified = true;
@ -65,14 +63,16 @@ nn::Result SavedataCheckerBase::CleanUpFilesRecursively(bool* modified, std::wst
{
s32 numRead;
result = dir.TryRead(&numRead, &entry, 1);
if(result.IsFailure())
if (result.IsFailure())
{
dir.Finalize();
COMMON_LOGGER_WARN("Error: %s\n", common::GetCharStr(currentDirectory.c_str()));
COMMON_LOGGER_WARN(
"Error: %s/%s\n", baseName.c_str(), common::GetCharStr(GetFilePathWithoutArchive(currentDirectory).c_str()));
m_CheckErrorOccured = true;
if (erase)
{
COMMON_LOGGER_WARN("Deleting: %s\n", common::GetCharStr(currentDirectory.c_str()));
COMMON_LOGGER_WARN(
"Deleting: %s/%s\n", baseName.c_str(), common::GetCharStr(GetFilePathWithoutArchive(currentDirectory).c_str()));
result = nn::fs::TryDeleteDirectoryRecursively(currentDirectory.c_str());
COMMON_LOGGER_RETURN_RESULT_IF_FAILED(result);
*modified = true;
@ -95,7 +95,8 @@ nn::Result SavedataCheckerBase::CleanUpFilesRecursively(bool* modified, std::wst
// ディレクトリの場合
if (entry.attributes.isDirectory)
{
return CleanUpFilesRecursively(modified, currentDirectory + std::wstring(entry.entryName) + std::wstring(L"/"), erase);
return CleanUpFilesRecursively(modified, baseName,
currentDirectory + std::wstring(entry.entryName) + std::wstring(L"/"), erase);
}
// ファイルの場合
else
@ -108,11 +109,11 @@ nn::Result SavedataCheckerBase::CleanUpFilesRecursively(bool* modified, std::wst
if(result.IsFailure())
{
nn::dbg::PrintResult(result);
COMMON_LOGGER_WARN("Error: %s\n", common::GetCharStr(path));
COMMON_LOGGER_WARN("Error: %s/%s\n", baseName.c_str(), common::GetCharStr(GetFilePathWithoutArchive(filePath).c_str()));
m_CheckErrorOccured = true;
if (erase)
{
COMMON_LOGGER_WARN("Deleting: %s\n", common::GetCharStr(path));
COMMON_LOGGER_WARN("Deleting: %s/%s\n", baseName.c_str(), common::GetCharStr(GetFilePathWithoutArchive(filePath).c_str()));
result = nn::fs::TryDeleteFile(path);
*modified = true;
}
@ -126,13 +127,13 @@ nn::Result SavedataCheckerBase::CleanUpFilesRecursively(bool* modified, std::wst
if(result.IsFailure())
{
nn::dbg::PrintResult(result);
COMMON_LOGGER_WARN("Error: %s\n", common::GetCharStr(path));
COMMON_LOGGER_WARN("Error: %s/%s\n", baseName.c_str(), common::GetCharStr(GetFilePathWithoutArchive(filePath).c_str()));
m_TotalReadSize += file.GetSize();
file.Finalize();
m_CheckErrorOccured = true;
if (erase)
{
COMMON_LOGGER_WARN("Deleting: %s\n", common::GetCharStr(path));
COMMON_LOGGER_WARN("Deleting: %s/%s\n", baseName.c_str(), common::GetCharStr(GetFilePathWithoutArchive(filePath).c_str()));
result = nn::fs::TryDeleteFile(path);
COMMON_LOGGER_RESULT_IF_FAILED(result);
*modified = true;
@ -229,6 +230,18 @@ bool SavedataCheckerBase::GetCheckErrorOccured()
return m_CheckErrorOccured;
}
std::wstring SavedataCheckerBase::GetFilePathWithoutArchive(std::wstring path)
{
std::wstring::size_type pos = path.find(L":/");
if(pos != std::wstring::npos)
{
return path.substr(pos + sizeof(L""));
}
else
{
return path;
}
}
NandSavedataChecker::NandSavedataChecker()
{
@ -311,14 +324,14 @@ nn::Result SystemSavedataChecker::CleanUp(bool erase)
{
if(result <= nn::fs::ResultVerificationFailed())
{
NN_LOG("Mount Error: %ls\n", SYSTEM_SAVEDATA_COUPLE_LIST[i].name.c_str());
NN_LOG("Mount Error: %s\n", SYSTEM_SAVEDATA_COUPLE_LIST[i].name.c_str());
COMMON_LOGGER_WARN(
"Error Savedata %s\n", common::GetCharStr(SYSTEM_SAVEDATA_COUPLE_LIST[i].name.c_str()));
"Error Savedata %s\n", SYSTEM_SAVEDATA_COUPLE_LIST[i].name.c_str());
m_CheckErrorOccured = true;
if (erase)
{
COMMON_LOGGER_WARN(
"Deleting Savedata %s\n", common::GetCharStr(SYSTEM_SAVEDATA_COUPLE_LIST[i].name.c_str()));
"Deleting Savedata %s\n", SYSTEM_SAVEDATA_COUPLE_LIST[i].name.c_str());
// 削除する
result = nn::fs::DeleteSystemSaveData(SYSTEM_SAVEDATA_COUPLE_LIST[i].id);
COMMON_LOGGER_RETURN_RESULT_IF_FAILED(result);
@ -327,9 +340,9 @@ nn::Result SystemSavedataChecker::CleanUp(bool erase)
}
else
{
NN_LOG("Mount %ls\n", SYSTEM_SAVEDATA_COUPLE_LIST[i].name.c_str());
NN_LOG("Mount %s\n", SYSTEM_SAVEDATA_COUPLE_LIST[i].name.c_str());
// ファイルを個別にチェックする
result = CleanUpFilesRecursively(&modified, L"ssave:/", erase);
result = CleanUpFilesRecursively(&modified, SYSTEM_SAVEDATA_COUPLE_LIST[i].name.c_str(), L"ssave:/", erase);
COMMON_LOGGER_RETURN_RESULT_IF_FAILED(result);
if(modified)
@ -396,12 +409,14 @@ nn::Result SharedExtSavedataChecker::CleanUp(bool erase)
bool modified = false;
for (s32 i = 0; i < numId; i++ )
{
char baseName[10];
nn::nstd::TSNPrintf(baseName, sizeof(baseName), "%X", IdArray[i]);
if (nn::fs::MountSharedExtSaveData(SHARED_EXT_SAVEDATA_ARCHIVE_NAME, IdArray[i]).IsSuccess())
{
NN_LOG("Mount %x\n", IdArray[i]);
// アーカイブ内のファイル・ディレクトリをチェックする
result = CleanUpFilesRecursively(&modified, L"shext:/", erase);
result = CleanUpFilesRecursively(&modified, baseName, L"shext:/", erase);
COMMON_LOGGER_RETURN_RESULT_IF_FAILED(result);
result = nn::fs::Unmount(SHARED_EXT_SAVEDATA_ARCHIVE_NAME);
@ -414,11 +429,11 @@ nn::Result SharedExtSavedataChecker::CleanUp(bool erase)
{
NN_LOG("Mount Error: %x\n", IdArray[i]);
COMMON_LOGGER_WARN("Error Shared-Ext-Savedata %x\n", IdArray[i]);
COMMON_LOGGER_WARN("Error Savedata %x\n", IdArray[i]);
m_CheckErrorOccured = true;
if (erase)
{
COMMON_LOGGER_WARN("Deleting Shared-Ext-Savedata %x\n", IdArray[i]);
COMMON_LOGGER_WARN("Deleting Savedata %x\n", IdArray[i]);
result = nn::fs::DeleteSharedExtSaveData(IdArray[i]);
COMMON_LOGGER_RETURN_RESULT_IF_FAILED(result);
}

View File

@ -26,86 +26,86 @@ namespace ConsoleBackup
struct SystemSaveDataCouple
{
std::wstring name;
std::string name;
nn::fs::SystemSaveDataId id;
};
const SystemSaveDataCouple SYSTEM_SAVEDATA_COUPLE_LIST[] =
{
{ L"fill_data", 0x00010000 },
{ L"cfg", 0x00010017 },
{ L"ptm", 0x00010022 },
{ L"cecd", 0x00010026 },
{ L"nim", 0x0001002C },
{ L"friends", 0x00010032 },
{ L"boss", 0x00010034 },
{ L"news", 0x00010035 },
{"fill_data", 0x00010000 },
{"cfg", 0x00010017 },
{"ptm", 0x00010022 },
{"cecd", 0x00010026 },
{"nim", 0x0001002C },
{"friends", 0x00010032 },
{"boss", 0x00010034 },
{"news", 0x00010035 },
{ L"PLOG_JP", 0x00020202 },
{ L"PLOG_US", 0x00020212 },
{ L"PLOG_EU", 0x00020222 },
{"ACTIVITY_LOG_JP", 0x00020202 },
{"ACTIVITY_LOG_US", 0x00020212 },
{"ACTIVITY_LOG_EU", 0x00020222 },
{ L"EDIT_JP", 0x00020207 },
{ L"EDIT_US", 0x00020217 },
{ L"EDIT_EU", 0x00020227 },
{"MII_MAKER_JP", 0x00020207 },
{"MII_MAKER_US", 0x00020217 },
{"MII_MAKER_EU", 0x00020227 },
{ L"PNOTE_JP", 0x00020204 },
{ L"PNOTE_US", 0x00020214 },
{ L"PNOTE_EU", 0x00020224 },
{"PHOTO_JP", 0x00020204 },
{"PHOTO_US", 0x00020214 },
{"PHOTO_EU", 0x00020224 },
{ L"SNOTE_JP", 0x00020205 },
{ L"SNOTE_US", 0x00020215 },
{ L"SNOTE_EU", 0x00020225 },
{"SOUND_JP", 0x00020205 },
{"SOUND_US", 0x00020215 },
{"SOUND_EU", 0x00020225 },
{ L"TIGER_JP", 0x00020209 },
{ L"TIGER_US", 0x00020219 },
{ L"TIGER_EU", 0x00020229 },
{"ESHOP_JP", 0x00020209 },
{"ESHOP_US", 0x00020219 },
{"ESHOP_EU", 0x00020229 },
{ L"MARS_JP", 0x0002020b },
{ L"MARS_US", 0x0002021b },
{ L"MARS_EU", 0x0002022b },
{"ZONE_JP", 0x0002020b },
{"ZONE_US", 0x0002021b },
{"ZONE_EU", 0x0002022b },
{ L"CARDBOARD_JP", 0x0002020a },
{ L"CARDBOARD_US", 0x0002021a },
{ L"CARDBOARD_EU", 0x0002022a },
{"MIGRATION_JP", 0x0002020a },
{"MIGRATION_US", 0x0002021a },
{"MIGRATION_EU", 0x0002022a },
{ L"FRUIT_JP", 0x0002020c },
{ L"FRUIT_US", 0x0002021c },
{ L"FRUIT_EU", 0x0002022c },
{"DIARY_JP", 0x0002020c },
{"DIARY_US", 0x0002021c },
{"DIARY_EU", 0x0002022c },
{ L"MEET_JP", 0x00020208 },
{ L"MEET_US", 0x00020218 },
{ L"MEET_EU", 0x00020228 },
{"MII_PLAZA_JP", 0x00020208 },
{"MII_PLAZA_US", 0x00020218 },
{"MII_PLAZA_EU", 0x00020228 },
{ L"CPLAY_HAL_JP", 0x0002020d },
{ L"CPLAY_HAL_US", 0x0002021d },
{ L"CPLAY_HAL_EU", 0x0002022d },
{"ARGAMES_HAL_JP", 0x0002020d },
{"ARGAMES_HAL_US", 0x0002021d },
{"ARGAMES_HAL_EU", 0x0002022d },
{ L"CPLAY_NCL_JP", 0x0002020e },
{ L"CPLAY_NCL_US", 0x0002021e },
{ L"CPLAY_NCL_EU", 0x0002022e },
{"ARGAMES_NCL_JP", 0x0002020e },
{"ARGAMES_NCL_US", 0x0002021e },
{"ARGAMES_NCL_EU", 0x0002022e },
{ L"MMEN_JP", 0x00020081 },
{ L"MMEN_US", 0x0002008f },
{ L"MMEN_EU", 0x00020098 },
{"MENU_JP", 0x00020081 },
{"MENU_US", 0x0002008f },
{"MENU_EU", 0x00020098 },
{ L"friend_JP", 0x0002008d },
{ L"friend_US", 0x00020096 },
{ L"friend_EU", 0x0002009f },
{"friend_JP", 0x0002008d },
{"friend_US", 0x00020096 },
{"friend_EU", 0x0002009f },
{ L"SPIDER_JP", 0x00020088 },
{ L"SPIDER_US", 0x0002009d },
{ L"SPIDER_EU", 0x00020094 },
{"BROWSER_JP", 0x00020088 },
{"BROWSER_US", 0x0002009d },
{"BROWSER_EU", 0x00020094 },
{ L"EBIRD_JP", 0x00020086 },
{ L"EBIRD_US", 0x00020092 },
{ L"EBIRD_EU", 0x0002009b },
{"ESPEC_JP", 0x00020086 },
{"ESPEC_US", 0x00020092 },
{"ESPEC_EU", 0x0002009b },
{ L"CHERRY_JP", 0x00020087 },
{ L"CHERRY_US", 0x00020093 },
{ L"CHERRY_EU", 0x0002009c },
{"MEMO_JP", 0x00020087 },
{"MEMO_US", 0x00020093 },
{"MEMO_EU", 0x0002009c },
{ L"error", 0x000200c5 }
{"error", 0x000200c5 }
};
@ -140,9 +140,11 @@ public:
protected:
//! @brief ファイルとディレクトリを再帰的にチェックする。エラーがあれば削除する
//! @param[out] modified ファイルかディレクトリを削除したかどうか
//! @param[in] currentDirectory チェックを開始するディレクトリ。スラッシュで終端すること。
//! @param[in] erase ファイルかディレクトリを削除するかどうか
nn::Result CleanUpFilesRecursively(bool* modified, std::wstring currentDirectory, bool erase);
//! @param[in] baseName 削除するセーブデータの区別に表示するための名前
//! @param[in] currentDirectory チェックを開始するディレクトリ。スラッシュで終端すること。
//! @param[in] erase ファイルかディレクトリを削除するかどうか
nn::Result CleanUpFilesRecursively(bool* modified, std::string baseName, std::wstring currentDirectory,
bool erase);
//! @brief ファイルサイズを取得する
//! @param[out] size ファイルサイズ
@ -166,6 +168,9 @@ protected:
//! @brief チェック時にエラーが起こったかどうか
bool m_CheckErrorOccured;
NN_PADDING4;
private:
std::wstring GetFilePathWithoutArchive(std::wstring path);
};