mirror of
https://github.com/rvtr/ctr_Repair.git
synced 2025-10-31 13:51:08 -04:00
trunk r369のマージ
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@370 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
parent
e0ad38b640
commit
f0c49b9bc3
@ -93,10 +93,8 @@ nn::Result DeleteTrash(std::wstring currentDirectory)
|
|||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
result = dir.TryRead(&numEntry, &entry, 1);
|
result = dir.TryRead(&numEntry, &entry, 1);
|
||||||
if (result.IsFailure())
|
COMMON_LOGGER_RETURN_RESULT_IF_FAILED(result);
|
||||||
{
|
|
||||||
dir.Finalize();
|
|
||||||
}
|
|
||||||
if (numEntry == 0)
|
if (numEntry == 0)
|
||||||
{
|
{
|
||||||
// ルートディレクトリを閉じる
|
// ルートディレクトリを閉じる
|
||||||
@ -298,37 +296,34 @@ void CreateTwlDirectory(enum common::TWL_PATH_INDEX path)
|
|||||||
std::wstring(common::SD_TWL_ROOTNAME_TABLE[path])).c_str());
|
std::wstring(common::SD_TWL_ROOTNAME_TABLE[path])).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListTwlSaveData(std::wstring currentDirectory, std::vector<common::SavePathInfo>* list)
|
bool ListTwlSaveData(std::wstring currentDirectory, std::vector<common::SavePathInfo>* list)
|
||||||
{
|
{
|
||||||
nn::fs::Directory dir;
|
nn::fs::Directory dir;
|
||||||
nn::fs::DirectoryEntry entry;
|
nn::fs::DirectoryEntry entry;
|
||||||
s32 numEntry;
|
s32 numEntry;
|
||||||
|
|
||||||
nn::Result result = dir.TryInitialize(currentDirectory.c_str());
|
nn::Result result = dir.TryInitialize(currentDirectory.c_str());
|
||||||
if(result.IsSuccess())
|
COMMON_LOGGER_RETURN_FALSE_IF_FAILED(result);
|
||||||
{
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
result = dir.TryRead(&numEntry, &entry, 1);
|
|
||||||
if(result.IsFailure())
|
|
||||||
{
|
|
||||||
dir.Finalize();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(numEntry == 0)
|
for (;;)
|
||||||
{
|
{
|
||||||
dir.Finalize();
|
result = dir.TryRead(&numEntry, &entry, 1);
|
||||||
}
|
COMMON_LOGGER_RETURN_FALSE_IF_FAILED(result);
|
||||||
else
|
|
||||||
{
|
if (numEntry == 0)
|
||||||
common::SavePathInfo pathInfo;
|
{
|
||||||
pathInfo.name = currentDirectory + std::wstring(L"/") + std::wstring(entry.entryName);
|
break;
|
||||||
pathInfo.isDirectory = false;
|
}
|
||||||
list->push_back(pathInfo);
|
else
|
||||||
}
|
{
|
||||||
|
common::SavePathInfo pathInfo;
|
||||||
|
pathInfo.name = currentDirectory + std::wstring(L"/") + std::wstring(entry.entryName);
|
||||||
|
pathInfo.isDirectory = false;
|
||||||
|
list->push_back(pathInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddCurrentProgramIdPath(std::vector<std::wstring>* programIdList, std::wstring currentDir)
|
void AddCurrentProgramIdPath(std::vector<std::wstring>* programIdList, std::wstring currentDir)
|
||||||
@ -384,81 +379,80 @@ bool ListTwlSaveDataDirectory(std::wstring currentDirectory, u32 level, std::vec
|
|||||||
const wchar_t* const TWL_SAVEDATA_DIRECTORY_NAME = L"data";
|
const wchar_t* const TWL_SAVEDATA_DIRECTORY_NAME = L"data";
|
||||||
|
|
||||||
result = dir.TryInitialize(currentDirectory.c_str());
|
result = dir.TryInitialize(currentDirectory.c_str());
|
||||||
if (result.IsSuccess())
|
COMMON_LOGGER_RETURN_FALSE_IF_FAILED(result);
|
||||||
|
|
||||||
|
nn::fs::DirectoryEntry entry;
|
||||||
|
s32 numEntry;
|
||||||
|
for (;;)
|
||||||
{
|
{
|
||||||
nn::fs::DirectoryEntry entry;
|
result = dir.TryRead(&numEntry, &entry, 1);
|
||||||
s32 numEntry;
|
COMMON_LOGGER_RETURN_FALSE_IF_FAILED(result);
|
||||||
for (;;)
|
|
||||||
|
if (numEntry == 0)
|
||||||
{
|
{
|
||||||
result = dir.TryRead(&numEntry, &entry, 1);
|
dir.Finalize();
|
||||||
if (result.IsFailure())
|
|
||||||
{
|
|
||||||
dir.Finalize();
|
|
||||||
}
|
|
||||||
if (numEntry == 0)
|
|
||||||
{
|
|
||||||
dir.Finalize();
|
|
||||||
|
|
||||||
bool retValue = false;
|
bool retValue = false;
|
||||||
for (entryIndex = entryList.begin(); entryIndex != entryList.end(); entryIndex++)
|
for (entryIndex = entryList.begin(); entryIndex != entryList.end(); entryIndex++)
|
||||||
|
{
|
||||||
|
// レベル2未満のディレクトリなら再帰的に開く
|
||||||
|
if (level < TWL_SAVEDATA_DIRECTORY_LEVEL)
|
||||||
{
|
{
|
||||||
// レベル2未満のディレクトリなら再帰的に開く
|
if (entryIndex->attributes.isDirectory)
|
||||||
if(level < TWL_SAVEDATA_DIRECTORY_LEVEL)
|
|
||||||
{
|
{
|
||||||
if (entryIndex->attributes.isDirectory)
|
if (ListTwlSaveDataDirectory(
|
||||||
|
currentDirectory + std::wstring(L"/") + std::wstring(entryIndex->entryName), level + 1,
|
||||||
|
list, programIdList))
|
||||||
{
|
{
|
||||||
if (ListTwlSaveDataDirectory(
|
NN_LOG("%ls/%ls has data directory.\n", currentDirectory.c_str(), entryIndex->entryName);
|
||||||
currentDirectory + std::wstring(L"/") + std::wstring(entryIndex->entryName),
|
|
||||||
level + 1, list, programIdList))
|
|
||||||
{
|
|
||||||
NN_LOG("%ls/%ls has data directory.\n", currentDirectory.c_str(), entryIndex->entryName);
|
|
||||||
retValue = true;
|
|
||||||
|
|
||||||
AddCurrentDirectory(list, currentDirectory, entryIndex->entryName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// レベル2のディレクトリなら data かどうかチェック
|
|
||||||
else if(level == TWL_SAVEDATA_DIRECTORY_LEVEL && entryIndex->attributes.isDirectory)
|
|
||||||
{
|
|
||||||
if (std::wcscmp(entryIndex->entryName, TWL_SAVEDATA_DIRECTORY_NAME) == 0)
|
|
||||||
{
|
|
||||||
// ファイル一覧を取得する
|
|
||||||
retValue = true;
|
retValue = true;
|
||||||
ListTwlSaveData(currentDirectory + std::wstring(L"/") + std::wstring(entryIndex->entryName), list);
|
|
||||||
|
|
||||||
AddCurrentDirectory(list, currentDirectory, entryIndex->entryName);
|
AddCurrentDirectory(list, currentDirectory, entryIndex->entryName);
|
||||||
AddCurrentProgramIdPath(programIdList, currentDirectory);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
// レベル2のディレクトリなら data かどうかチェック
|
||||||
|
else if (level == TWL_SAVEDATA_DIRECTORY_LEVEL && entryIndex->attributes.isDirectory)
|
||||||
|
{
|
||||||
|
if (std::wcscmp(entryIndex->entryName, TWL_SAVEDATA_DIRECTORY_NAME) == 0)
|
||||||
{
|
{
|
||||||
return false;
|
// ファイル一覧を取得する
|
||||||
|
retValue = true;
|
||||||
|
if (!ListTwlSaveData(
|
||||||
|
currentDirectory + std::wstring(L"/") + std::wstring(entryIndex->entryName), list))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
AddCurrentDirectory(list, currentDirectory, entryIndex->entryName);
|
||||||
|
AddCurrentProgramIdPath(programIdList, currentDirectory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if(level != 0)
|
|
||||||
{
|
{
|
||||||
return retValue;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
if (level != 0)
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// vectorに保存する
|
return retValue;
|
||||||
entryList.push_back(entry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// vectorに保存する
|
||||||
|
entryList.push_back(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
NN_LOG("failed initialize directory\n");
|
|
||||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
|
||||||
dir.Finalize();
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -804,8 +804,15 @@ void ControlState(common::HardwareStateManager& manager, ::std::vector<std::stri
|
|||||||
CreateConsoleInitializedFile();
|
CreateConsoleInitializedFile();
|
||||||
|
|
||||||
// ファイルシステムの初期化を行う
|
// ファイルシステムの初期化を行う
|
||||||
InitializeFileSystem();
|
if(InitializeFileSystem())
|
||||||
s_RestoreState = REBOOTING;
|
{
|
||||||
|
s_RestoreState = REBOOTING;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
s_RestoreState = FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1557,7 +1564,10 @@ void ControlState(common::HardwareStateManager& manager, ::std::vector<std::stri
|
|||||||
case INITIALIZE_AND_SHUTDOWN:
|
case INITIALIZE_AND_SHUTDOWN:
|
||||||
{
|
{
|
||||||
// 本体初期化を行う
|
// 本体初期化を行う
|
||||||
InitializeFileSystem();
|
if(!InitializeFileSystem())
|
||||||
|
{
|
||||||
|
s_RestoreState = FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
// シャットダウンする
|
// シャットダウンする
|
||||||
nn::ptm::CTR::ShutdownAsync(0, nn::fnd::TimeSpan::FromSeconds(0));
|
nn::ptm::CTR::ShutdownAsync(0, nn::fnd::TimeSpan::FromSeconds(0));
|
||||||
|
|||||||
@ -543,83 +543,83 @@ nn::Result ImportMcuRtc(common::HardwareStateManager& manager)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitializeFileSystem()
|
bool InitializeFileSystem()
|
||||||
{
|
{
|
||||||
nn::Result result;
|
nn::Result result;
|
||||||
|
|
||||||
for (u32 i = 0; i < common::TWL_PATHNAME_MAX; i++)
|
for (u32 i = 0; i < common::TWL_PATHNAME_MAX; i++)
|
||||||
{
|
{
|
||||||
result = nn::fs::MountSpecialArchive(common::TWL_ARCHIVE_NAME_TABLE[i], common::TWL_FS_ARCHIVE_KIND[i]);
|
result = nn::fs::MountSpecialArchive(common::TWL_ARCHIVE_NAME_TABLE[i], common::TWL_FS_ARCHIVE_KIND[i]);
|
||||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
COMMON_LOGGER_RETURN_FALSE_IF_FAILED(result);
|
||||||
if (result.IsSuccess())
|
|
||||||
|
nn::fs::Directory dir;
|
||||||
|
std::vector<nn::fs::DirectoryEntry> entryList; //カレントディレクトリのエントリ一覧を格納
|
||||||
|
std::vector<nn::fs::DirectoryEntry>::iterator entryIndex;
|
||||||
|
|
||||||
|
std::wstring currentDirectory = common::NAND_TWL_ROOT_PATHNAME_WITH_SLASH_TABLE[i];
|
||||||
|
result = dir.TryInitialize(currentDirectory.c_str());
|
||||||
|
COMMON_LOGGER_RETURN_FALSE_IF_FAILED(result);
|
||||||
|
|
||||||
|
nn::fs::DirectoryEntry entry;
|
||||||
|
s32 numEntry;
|
||||||
|
for (;;)
|
||||||
{
|
{
|
||||||
nn::fs::Directory dir;
|
result = dir.TryRead(&numEntry, &entry, 1);
|
||||||
std::vector<nn::fs::DirectoryEntry> entryList; //カレントディレクトリのエントリ一覧を格納
|
COMMON_LOGGER_RETURN_FALSE_IF_FAILED(result);
|
||||||
std::vector<nn::fs::DirectoryEntry>::iterator entryIndex;
|
|
||||||
|
|
||||||
std::wstring currentDirectory = common::NAND_TWL_ROOT_PATHNAME_WITH_SLASH_TABLE[i];
|
if (numEntry == 0)
|
||||||
result = dir.TryInitialize(currentDirectory.c_str());
|
|
||||||
|
|
||||||
nn::fs::DirectoryEntry entry;
|
|
||||||
s32 numEntry;
|
|
||||||
for (;;)
|
|
||||||
{
|
{
|
||||||
result = dir.TryRead(&numEntry, &entry, 1);
|
// ルートディレクトリを閉じる
|
||||||
if (result.IsFailure())
|
dir.Finalize();
|
||||||
{
|
|
||||||
dir.Finalize();
|
|
||||||
}
|
|
||||||
if (numEntry == 0)
|
|
||||||
{
|
|
||||||
// ルートディレクトリを閉じる
|
|
||||||
dir.Finalize();
|
|
||||||
|
|
||||||
// ルートディレクトリの子を開く
|
// ルートディレクトリの子を開く
|
||||||
for (entryIndex = entryList.begin(); entryIndex != entryList.end(); entryIndex++)
|
for (entryIndex = entryList.begin(); entryIndex != entryList.end(); entryIndex++)
|
||||||
|
{
|
||||||
|
// ディレクトリなら削除する
|
||||||
|
if (entryIndex->attributes.isDirectory)
|
||||||
{
|
{
|
||||||
// ディレクトリなら削除する
|
NN_LOG("Try Delete %ls%ls/\n", currentDirectory.c_str(), entryIndex->entryName);
|
||||||
if (entryIndex->attributes.isDirectory)
|
result = nn::fs::TryDeleteDirectoryRecursively(
|
||||||
{
|
(currentDirectory + ::std::wstring(entryIndex->entryName)).c_str());
|
||||||
NN_LOG("Try Delete %ls%ls/\n", currentDirectory.c_str(), entryIndex->entryName);
|
COMMON_LOGGER_RETURN_FALSE_IF_FAILED(result);
|
||||||
result = nn::fs::TryDeleteDirectoryRecursively((currentDirectory + ::std::wstring(
|
|
||||||
entryIndex->entryName)).c_str());
|
|
||||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
|
||||||
|
|
||||||
}
|
|
||||||
// ファイルなら削除する
|
|
||||||
else
|
|
||||||
{
|
|
||||||
NN_LOG("Try Delete %ls%ls\n", currentDirectory.c_str(), entryIndex->entryName);
|
|
||||||
result = nn::fs::TryDeleteFile(
|
|
||||||
(currentDirectory + ::std::wstring(entryIndex->entryName)).c_str());
|
|
||||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// ファイルなら削除する
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NN_LOG("Try Delete %ls%ls\n", currentDirectory.c_str(), entryIndex->entryName);
|
||||||
|
result = nn::fs::TryDeleteFile(
|
||||||
|
(currentDirectory + ::std::wstring(entryIndex->entryName)).c_str());
|
||||||
|
COMMON_LOGGER_RETURN_FALSE_IF_FAILED(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 削除完了
|
// 削除完了
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// vectorに保存する
|
||||||
|
entryList.push_back(entry);
|
||||||
|
if (entry.attributes.isDirectory)
|
||||||
|
{
|
||||||
|
NN_LOG("%ls%ls/\n", currentDirectory.c_str(), entry.entryName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// vectorに保存する
|
NN_LOG("%ls%ls\n", currentDirectory.c_str(), entry.entryName);
|
||||||
entryList.push_back(entry);
|
|
||||||
if (entry.attributes.isDirectory)
|
|
||||||
{
|
|
||||||
NN_LOG("%ls%ls/\n", currentDirectory.c_str(), entry.entryName);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
NN_LOG("%ls%ls\n", currentDirectory.c_str(), entry.entryName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nn::fs::Unmount(common::TWL_ARCHIVE_NAME_TABLE[i]);
|
|
||||||
|
result = nn::fs::Unmount(common::TWL_ARCHIVE_NAME_TABLE[i]);
|
||||||
|
COMMON_LOGGER_RETURN_FALSE_IF_FAILED(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
result = nn::am::DeleteAllTwlUserPrograms();
|
result = nn::am::DeleteAllTwlUserPrograms();
|
||||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
COMMON_LOGGER_RETURN_FALSE_IF_FAILED(result);
|
||||||
nn::fs::InitializeCtrFileSystem();
|
nn::fs::InitializeCtrFileSystem();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
nn::Result ImportIvs()
|
nn::Result ImportIvs()
|
||||||
|
|||||||
@ -137,7 +137,7 @@ nn::Result ImportCountryLanguageData();
|
|||||||
nn::Result ImportMcuRtc(common::HardwareStateManager& manager);
|
nn::Result ImportMcuRtc(common::HardwareStateManager& manager);
|
||||||
|
|
||||||
// TWL写真領域を初期化してから本体初期化を行う
|
// TWL写真領域を初期化してから本体初期化を行う
|
||||||
void InitializeFileSystem();
|
bool InitializeFileSystem();
|
||||||
|
|
||||||
// SDカードのファイルと本体情報の比較結果をクリアする
|
// SDカードのファイルと本体情報の比較結果をクリアする
|
||||||
void ClearFileReadResult();
|
void ClearFileReadResult();
|
||||||
|
|||||||
@ -58,7 +58,6 @@ const char* GetCharStr(const wchar_t* path)
|
|||||||
|
|
||||||
nn::Result CalculateFileNum(std::wstring currentDirectory, u32& fileNum, s64& fileSize)
|
nn::Result CalculateFileNum(std::wstring currentDirectory, u32& fileNum, s64& fileSize)
|
||||||
{
|
{
|
||||||
nn::fs::FileInputStream fis;
|
|
||||||
nn::fs::Directory dir;
|
nn::fs::Directory dir;
|
||||||
nn::Result result;
|
nn::Result result;
|
||||||
std::vector<nn::fs::DirectoryEntry> entryList; //カレントディレクトリのエントリ一覧を格納
|
std::vector<nn::fs::DirectoryEntry> entryList; //カレントディレクトリのエントリ一覧を格納
|
||||||
@ -267,7 +266,9 @@ bool CopyDirectory(ImportDataList* fileList, const wchar_t * from_path, const wc
|
|||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
result = from_dir.TryRead(&numread, &entry, 1);
|
result = from_dir.TryRead(&numread, &entry, 1);
|
||||||
if (result.IsFailure() || numread != 1)
|
COMMON_LOGGER_RETURN_FALSE_IF_FAILED(result);
|
||||||
|
|
||||||
|
if(numread == 0)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user