mirror of
https://github.com/rvtr/ctr_Repair.git
synced 2025-10-31 13:51:08 -04:00
trunk r475,481のマージ
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@494 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
parent
e4d94fac1c
commit
6159f0be9e
@ -115,7 +115,7 @@ nn::Result SavedataCheckerBase::CleanUpFilesRecursively(bool* modified, std::str
|
|||||||
result = file.TryInitialize(path);
|
result = file.TryInitialize(path);
|
||||||
if(result.IsFailure())
|
if(result.IsFailure())
|
||||||
{
|
{
|
||||||
nn::dbg::PrintResult(result);
|
COMMON_LOGGER_RESULT_IF_FAILED(result);
|
||||||
const bool silent = IsForceDeleteFile(common::GetCharStr(entry.entryName));
|
const bool silent = IsForceDeleteFile(common::GetCharStr(entry.entryName));
|
||||||
if(!silent)
|
if(!silent)
|
||||||
{
|
{
|
||||||
@ -140,7 +140,7 @@ nn::Result SavedataCheckerBase::CleanUpFilesRecursively(bool* modified, std::str
|
|||||||
result = file.TryRead(&readSize, m_Buf, m_Bufsize);
|
result = file.TryRead(&readSize, m_Buf, m_Bufsize);
|
||||||
if(result.IsFailure())
|
if(result.IsFailure())
|
||||||
{
|
{
|
||||||
nn::dbg::PrintResult(result);
|
COMMON_LOGGER_RESULT_IF_FAILED(result);
|
||||||
const bool silent = IsForceDeleteFile(common::GetCharStr(entry.entryName));
|
const bool silent = IsForceDeleteFile(common::GetCharStr(entry.entryName));
|
||||||
if(!silent)
|
if(!silent)
|
||||||
{
|
{
|
||||||
@ -180,61 +180,7 @@ nn::Result SavedataCheckerBase::CleanUpFilesRecursively(bool* modified, std::str
|
|||||||
|
|
||||||
nn::Result SavedataCheckerBase::GetFileSize(std::wstring currentDirectory)
|
nn::Result SavedataCheckerBase::GetFileSize(std::wstring currentDirectory)
|
||||||
{
|
{
|
||||||
nn::fs::Directory dir;
|
return common::CalculateFileSizeRecursively(currentDirectory, m_CalculatedFileSize);
|
||||||
nn::fs::DirectoryEntry entry;
|
|
||||||
nn::Result result;
|
|
||||||
|
|
||||||
NN_LOG("%s\n", common::GetCharStr(currentDirectory.c_str()));
|
|
||||||
result = dir.TryInitialize(currentDirectory.c_str());
|
|
||||||
if(result.IsFailure())
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
s32 numRead;
|
|
||||||
result = dir.TryRead(&numRead, &entry, 1);
|
|
||||||
if(result.IsFailure())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if(numRead == 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (std::wcscmp(entry.entryName, L".") == 0 || std::wcscmp(entry.entryName, L"..") == 0)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ディレクトリの場合
|
|
||||||
if (entry.attributes.isDirectory)
|
|
||||||
{
|
|
||||||
return GetFileSize(currentDirectory + std::wstring(entry.entryName) + std::wstring(L"/"));
|
|
||||||
}
|
|
||||||
// ファイルの場合
|
|
||||||
else
|
|
||||||
{
|
|
||||||
nn::fs::FileInputStream file;
|
|
||||||
std::wstring filePath = (currentDirectory + std::wstring(entry.entryName)).c_str();
|
|
||||||
const wchar_t* path = filePath.c_str();
|
|
||||||
|
|
||||||
result = file.TryInitialize(path);
|
|
||||||
if(result.IsFailure())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_CalculatedFileSize += file.GetSize();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nn::ResultSuccess();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
s64 SavedataCheckerBase::GetCalculatedSize()
|
s64 SavedataCheckerBase::GetCalculatedSize()
|
||||||
|
|||||||
@ -894,7 +894,7 @@ bool ExistsIvsDirectory(std::string& ivsRoot)
|
|||||||
result = dir.TryInitialize(common::SD_NINTENDO_3DS_ROOT_PATH);
|
result = dir.TryInitialize(common::SD_NINTENDO_3DS_ROOT_PATH);
|
||||||
if(result.IsFailure())
|
if(result.IsFailure())
|
||||||
{
|
{
|
||||||
NN_DBG_PRINT_RESULT(result);
|
COMMON_LOGGER_RESULT_IF_FAILED(result);
|
||||||
common::SdMountManager::Unmount();
|
common::SdMountManager::Unmount();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -768,4 +768,63 @@ bool AddPathNameAndUpdateContext(nn::fs::FileOutputStream* file, const wchar_t *
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nn::Result CalculateFileSizeRecursively(std::wstring currentDirectory, s64& fileSize)
|
||||||
|
{
|
||||||
|
nn::fs::Directory dir;
|
||||||
|
nn::fs::DirectoryEntry entry;
|
||||||
|
nn::Result result;
|
||||||
|
|
||||||
|
NN_LOG("%s\n", common::GetCharStr(currentDirectory.c_str()));
|
||||||
|
result = dir.TryInitialize(currentDirectory.c_str());
|
||||||
|
if(result.IsFailure())
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
s32 numRead;
|
||||||
|
result = dir.TryRead(&numRead, &entry, 1);
|
||||||
|
if(result.IsFailure())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(numRead == 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (std::wcscmp(entry.entryName, L".") == 0 || std::wcscmp(entry.entryName, L"..") == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ディレクトリの場合
|
||||||
|
if (entry.attributes.isDirectory)
|
||||||
|
{
|
||||||
|
return CalculateFileSizeRecursively(currentDirectory + std::wstring(entry.entryName) + std::wstring(L"/"), fileSize);
|
||||||
|
}
|
||||||
|
// ファイルの場合
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nn::fs::FileInputStream file;
|
||||||
|
std::wstring filePath = (currentDirectory + std::wstring(entry.entryName)).c_str();
|
||||||
|
const wchar_t* path = filePath.c_str();
|
||||||
|
|
||||||
|
result = file.TryInitialize(path);
|
||||||
|
if(result.IsFailure())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
fileSize += file.GetSize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nn::ResultSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -59,6 +59,9 @@ const char* GetCharStr(const wchar_t* path);
|
|||||||
|
|
||||||
void AddPkcsPadding(u8* paddingSize, void* buf, size_t bufSize, s32* readSize);
|
void AddPkcsPadding(u8* paddingSize, void* buf, size_t bufSize, s32* readSize);
|
||||||
|
|
||||||
|
// ディレクトリ以下のファイルサイズを計算する
|
||||||
|
nn::Result CalculateFileSizeRecursively(std::wstring currentDirectory, s64& fileSize);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* FILETRANSFER_H_ */
|
#endif /* FILETRANSFER_H_ */
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user