mirror of
https://github.com/rvtr/ctr_Repair.git
synced 2025-10-31 13:51:08 -04:00
IVS依存のディレクトリ名も含めてCopyDirectoryでコピーするように
ファイル一覧でディレクトリは-1のサイズに変更 ファイル一覧にあるファイルのみ書き込むように git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@155 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
parent
fc0324adb4
commit
2f6bdd55ac
@ -353,6 +353,7 @@ void WriteTwlData(enum common::TWL_PATH_INDEX path)
|
|||||||
std::strlen(common::TWL_ARCHIVE_NAME_TABLE[path]) + 1);
|
std::strlen(common::TWL_ARCHIVE_NAME_TABLE[path]) + 1);
|
||||||
std::wstring archiveString(archiveName);
|
std::wstring archiveString(archiveName);
|
||||||
common::CopyDirectory(
|
common::CopyDirectory(
|
||||||
|
NULL,
|
||||||
(archiveString + ::std::wstring(L"/")).c_str(),
|
(archiveString + ::std::wstring(L"/")).c_str(),
|
||||||
(common::SDMC_ROOT_DIRECTORY_PATH + ::std::wstring(common::SD_TWL_ROOTNAME_TABLE[path])).c_str(),
|
(common::SDMC_ROOT_DIRECTORY_PATH + ::std::wstring(common::SD_TWL_ROOTNAME_TABLE[path])).c_str(),
|
||||||
buf, bufSize, true, &list, &s_FileListContext);
|
buf, bufSize, true, &list, &s_FileListContext);
|
||||||
@ -456,10 +457,11 @@ void ExportThreadFunc()
|
|||||||
if (result.IsSuccess())
|
if (result.IsSuccess())
|
||||||
{
|
{
|
||||||
common::CopyDirectory(
|
common::CopyDirectory(
|
||||||
(::std::wstring(common::NAND_DATA_ROOT_PATHNAME_WITH_SLASH) + ::std::wstring(s_RootName)
|
NULL,
|
||||||
+ ::std::wstring(L"/")).c_str(),
|
::std::wstring(common::NAND_DATA_ROOT_PATHNAME_WITH_SLASH).c_str(),
|
||||||
(common::SDMC_ROOT_DIRECTORY_PATH + ::std::wstring(common::SD_SAVEDATA_ROOT_NAME) + ::std::wstring(
|
(std::wstring(common::SDMC_ROOT_DIRECTORY_PATH) + ::std::wstring(
|
||||||
s_RootName) + ::std::wstring(L"/")).c_str(), buf, bufSize, true, &list, &s_FileListContext);
|
common::SD_SAVEDATA_ROOT_NAME)).c_str(), buf, bufSize, true, &list,
|
||||||
|
&s_FileListContext);
|
||||||
|
|
||||||
AddCmac(&list, &s_FileListContext);
|
AddCmac(&list, &s_FileListContext);
|
||||||
list.TryFlush();
|
list.TryFlush();
|
||||||
@ -503,8 +505,6 @@ nn::Result WriteSaveData()
|
|||||||
// コピー用ディレクトリ作成
|
// コピー用ディレクトリ作成
|
||||||
s_SdWriter.CreateDirectory((::std::wstring(common::SDMC_ROOT_DIRECTORY_PATH) + ::std::wstring(
|
s_SdWriter.CreateDirectory((::std::wstring(common::SDMC_ROOT_DIRECTORY_PATH) + ::std::wstring(
|
||||||
common::SD_SAVEDATA_ROOT_NAME)).c_str());
|
common::SD_SAVEDATA_ROOT_NAME)).c_str());
|
||||||
s_SdWriter.CreateDirectory((::std::wstring(common::SDMC_ROOT_DIRECTORY_PATH) + ::std::wstring(
|
|
||||||
common::SD_SAVEDATA_ROOT_NAME) + ::std::wstring(s_RootName) + ::std::wstring(L"/")).c_str());
|
|
||||||
|
|
||||||
COMMON_LOGGER("Export NAND Data Start...\n");
|
COMMON_LOGGER("Export NAND Data Start...\n");
|
||||||
|
|
||||||
|
|||||||
@ -46,6 +46,7 @@ typedef enum RestoreState
|
|||||||
UPDATE_DONE, // アップデート完了
|
UPDATE_DONE, // アップデート完了
|
||||||
NUP_ONLY_WAIT_SD_EJECT, // NUP_ONLYモードでSDカード抜き待ち
|
NUP_ONLY_WAIT_SD_EJECT, // NUP_ONLYモードでSDカード抜き待ち
|
||||||
NUP_ONLY_WAIT_NEXT, // NUP_ONLYモードでキー入力待ち
|
NUP_ONLY_WAIT_NEXT, // NUP_ONLYモードでキー入力待ち
|
||||||
|
RESTORE_READ_FILELIST, // ファイル一覧の読み込み
|
||||||
RESTORE_TWL_SOUND, // TWLサウンドの書き込み中
|
RESTORE_TWL_SOUND, // TWLサウンドの書き込み中
|
||||||
RESTORE_TWL_PHOTO, // TWL写真の書き込み中
|
RESTORE_TWL_PHOTO, // TWL写真の書き込み中
|
||||||
RESTORE_IN_PROGRESS, // 書き込み中
|
RESTORE_IN_PROGRESS, // 書き込み中
|
||||||
@ -451,7 +452,7 @@ void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s_RestoreState = RESTORE_TWL_SOUND;
|
s_RestoreState = RESTORE_READ_FILELIST;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -473,7 +474,7 @@ void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep,
|
|||||||
|
|
||||||
if (nextStep)
|
if (nextStep)
|
||||||
{
|
{
|
||||||
s_RestoreState = RESTORE_TWL_SOUND;
|
s_RestoreState = RESTORE_READ_FILELIST;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -572,6 +573,22 @@ void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case RESTORE_READ_FILELIST:
|
||||||
|
{
|
||||||
|
result = SetupFileList();
|
||||||
|
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||||
|
|
||||||
|
if(result.IsSuccess())
|
||||||
|
{
|
||||||
|
s_RestoreState = RESTORE_TWL_SOUND;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
s_RestoreState = FAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
// TWLサウンド領域の書き込み中
|
// TWLサウンド領域の書き込み中
|
||||||
case RESTORE_TWL_SOUND:
|
case RESTORE_TWL_SOUND:
|
||||||
|
|||||||
@ -71,6 +71,16 @@ bool s_CheckedEqualsDeviceIdFileandDeviceId = false;
|
|||||||
bool s_CheckedEqualsRegionDataandRegion = false;
|
bool s_CheckedEqualsRegionDataandRegion = false;
|
||||||
bool s_ReadSerialNumber = false;
|
bool s_ReadSerialNumber = false;
|
||||||
|
|
||||||
|
struct SdFileSize
|
||||||
|
{
|
||||||
|
s64 totalFileSize;
|
||||||
|
s64 twlSoundFileSize;
|
||||||
|
s64 twlPhotoFileSize;
|
||||||
|
s64 ctrFileSize;
|
||||||
|
};
|
||||||
|
|
||||||
|
SdFileSize s_SdFileSize;
|
||||||
|
|
||||||
// シリアルナンバー
|
// シリアルナンバー
|
||||||
u8 s_SerialNo[nn::cfg::CTR::CFG_SECURE_INFO_SERIAL_NO_LEN];
|
u8 s_SerialNo[nn::cfg::CTR::CFG_SECURE_INFO_SERIAL_NO_LEN];
|
||||||
|
|
||||||
@ -84,15 +94,14 @@ nn::Result ImportNorData();
|
|||||||
// SDカードに保存してあるバージョン情報
|
// SDカードに保存してあるバージョン情報
|
||||||
common::VerDef s_SDVersionData;
|
common::VerDef s_SDVersionData;
|
||||||
|
|
||||||
struct ImportDataEntry
|
// SDカードから読み込んだファイル一覧
|
||||||
{
|
common::ImportDataList s_FileLists;
|
||||||
std::string fileName;
|
|
||||||
NN_PADDING3;
|
|
||||||
bool isDirectory;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SDからファイル一覧を読み込む
|
||||||
|
nn::Result ReadFileList(SdFileSize* sdFileSize, common::ImportDataList* fileList);
|
||||||
|
|
||||||
CheckedNetworkSetting s_CurrentNetowrkSetting1;
|
CheckedNetworkSetting s_CurrentNetowrkSetting1;
|
||||||
|
|
||||||
void ConvertTimeZoneString(const char* str)
|
void ConvertTimeZoneString(const char* str)
|
||||||
@ -676,6 +685,7 @@ void ImportThreadFunc()
|
|||||||
{
|
{
|
||||||
|
|
||||||
common::CopyDirectory(
|
common::CopyDirectory(
|
||||||
|
&s_FileLists,
|
||||||
(::std::wstring(common::SDMC_ROOT_DIRECTORY_PATH) + ::std::wstring(common::SD_SAVEDATA_ROOT_NAME)).c_str(),
|
(::std::wstring(common::SDMC_ROOT_DIRECTORY_PATH) + ::std::wstring(common::SD_SAVEDATA_ROOT_NAME)).c_str(),
|
||||||
common::NAND_DATA_ROOT_PATHNAME_WITH_SLASH,
|
common::NAND_DATA_ROOT_PATHNAME_WITH_SLASH,
|
||||||
buf, bufSize, false, NULL, NULL);
|
buf, bufSize, false, NULL, NULL);
|
||||||
@ -697,19 +707,8 @@ void ImportSaveData()
|
|||||||
// SDカードからNANDに読み込み
|
// SDカードからNANDに読み込み
|
||||||
nn::Result result;
|
nn::Result result;
|
||||||
|
|
||||||
// SDカードにあるセーブデータサイズを計算
|
|
||||||
u32 fileNum = 0;
|
|
||||||
s64 fileSize = 0;
|
|
||||||
|
|
||||||
common::SdMountManager::Mount();
|
|
||||||
common::CalculateFileNum(::std::wstring(common::SDMC_ROOT_DIRECTORY_PATH) + ::std::wstring(common::SD_SAVEDATA_ROOT_NAME), fileNum, fileSize);
|
|
||||||
common::SdMountManager::Unmount();
|
|
||||||
|
|
||||||
// ファイルサイズ設定
|
// ファイルサイズ設定
|
||||||
common::InitializeTransferProgress(fileSize);
|
common::InitializeTransferProgress(s_SdFileSize.ctrFileSize);
|
||||||
|
|
||||||
NN_LOG("File Number = %d\n", fileNum);
|
|
||||||
NN_LOG("File Size = %d\n", fileSize);
|
|
||||||
|
|
||||||
// SDカードにあるセーブデータディレクトリ以下のデータをNANDにコピー
|
// SDカードにあるセーブデータディレクトリ以下のデータをNANDにコピー
|
||||||
COMMON_LOGGER("Import NAND Data Start...\n");
|
COMMON_LOGGER("Import NAND Data Start...\n");
|
||||||
@ -1296,7 +1295,7 @@ CheckedNetworkSetting* GetTempNetworkSetting()
|
|||||||
return &s_CurrentNetowrkSetting1;
|
return &s_CurrentNetowrkSetting1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImportTwlData(enum common::TWL_PATH_INDEX path)
|
void ImportTwlData(enum common::TWL_PATH_INDEX path, s64 fileSize)
|
||||||
{
|
{
|
||||||
NN_ASSERT(path < common::TWL_PATHNAME_MAX);
|
NN_ASSERT(path < common::TWL_PATHNAME_MAX);
|
||||||
|
|
||||||
@ -1310,26 +1309,17 @@ void ImportTwlData(enum common::TWL_PATH_INDEX path)
|
|||||||
size_t bufSize = common::HeapManager::GetHeap()->GetAllocatableSize();
|
size_t bufSize = common::HeapManager::GetHeap()->GetAllocatableSize();
|
||||||
NN_LOG("AllocatableSize = %d\n", bufSize);
|
NN_LOG("AllocatableSize = %d\n", bufSize);
|
||||||
|
|
||||||
|
|
||||||
u32 fileNum = 0;
|
|
||||||
s64 fileSize = 0;
|
|
||||||
|
|
||||||
common::CalculateFileNum(::std::wstring(common::SDMC_ROOT_DIRECTORY_PATH) + ::std::wstring(
|
|
||||||
common::SD_TWL_ROOTNAME_TABLE[path]), fileNum, fileSize);
|
|
||||||
// ファイルサイズ設定
|
// ファイルサイズ設定
|
||||||
common::InitializeTransferProgress(fileSize);
|
common::InitializeTransferProgress(fileSize);
|
||||||
|
|
||||||
NN_LOG("File Number = %d\n", fileNum);
|
|
||||||
NN_LOG("File Size = %d\n", fileSize);
|
|
||||||
|
|
||||||
|
|
||||||
void* buf = common::HeapManager::GetHeap()->Allocate(bufSize, AES_BLOCK_SIZE);
|
void* buf = common::HeapManager::GetHeap()->Allocate(bufSize, AES_BLOCK_SIZE);
|
||||||
if (buf != NULL)
|
if (buf != NULL)
|
||||||
{
|
{
|
||||||
wchar_t archiveName[256];
|
wchar_t archiveName[nn::fs::MAX_FILE_PATH_LENGTH];
|
||||||
::std::mbstowcs(archiveName, common::TWL_ARCHIVE_NAME_TABLE[path], std::strlen(common::TWL_ARCHIVE_NAME_TABLE[path]) + 1);
|
::std::mbstowcs(archiveName, common::TWL_ARCHIVE_NAME_TABLE[path], std::strlen(common::TWL_ARCHIVE_NAME_TABLE[path]) + 1);
|
||||||
std::wstring archiveString(archiveName);
|
std::wstring archiveString(archiveName);
|
||||||
common::CopyDirectory(
|
common::CopyDirectory(
|
||||||
|
&s_FileLists,
|
||||||
(::std::wstring(common::SDMC_ROOT_DIRECTORY_PATH) + ::std::wstring(common::SD_TWL_ROOTNAME_TABLE[path])).c_str(),
|
(::std::wstring(common::SDMC_ROOT_DIRECTORY_PATH) + ::std::wstring(common::SD_TWL_ROOTNAME_TABLE[path])).c_str(),
|
||||||
(archiveString + ::std::wstring(L"/")).c_str(),
|
(archiveString + ::std::wstring(L"/")).c_str(),
|
||||||
buf, bufSize, false, NULL, NULL);
|
buf, bufSize, false, NULL, NULL);
|
||||||
@ -1345,13 +1335,13 @@ void ImportTwlData(enum common::TWL_PATH_INDEX path)
|
|||||||
void ImportTwlPhotoDataFunc()
|
void ImportTwlPhotoDataFunc()
|
||||||
{
|
{
|
||||||
COMMON_LOGGER("Import Twl Photo Data.\n");
|
COMMON_LOGGER("Import Twl Photo Data.\n");
|
||||||
ImportTwlData(common::TWL_PHOTO);
|
ImportTwlData(common::TWL_PHOTO, s_SdFileSize.twlPhotoFileSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImportTwlSoundDataFunc()
|
void ImportTwlSoundDataFunc()
|
||||||
{
|
{
|
||||||
COMMON_LOGGER("Import Twl Sound Data.\n");
|
COMMON_LOGGER("Import Twl Sound Data.\n");
|
||||||
ImportTwlData(common::TWL_SOUND);
|
ImportTwlData(common::TWL_SOUND, s_SdFileSize.twlSoundFileSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImportTwlPhotoData()
|
void ImportTwlPhotoData()
|
||||||
@ -1525,7 +1515,18 @@ nn::Result InitializeHardwareDependentSetting()
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
nn::Result ReadFileList(s64* totalFileSize, std::vector<ImportDataEntry>* fileList)
|
nn::Result SetupFileList()
|
||||||
|
{
|
||||||
|
std::memset(&s_SdFileSize, 0, sizeof(s_SdFileSize));
|
||||||
|
|
||||||
|
// ファイル一覧を読み込む
|
||||||
|
nn::Result result = ReadFileList(&s_SdFileSize, &s_FileLists);
|
||||||
|
NN_UTIL_RETURN_IF_FAILED(result);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
nn::Result ReadFileList(SdFileSize* sdFiles, common::ImportDataList* fileList)
|
||||||
{
|
{
|
||||||
nn::Result result = nn::ResultSuccess();
|
nn::Result result = nn::ResultSuccess();
|
||||||
|
|
||||||
@ -1562,7 +1563,7 @@ nn::Result ReadFileList(s64* totalFileSize, std::vector<ImportDataEntry>* fileLi
|
|||||||
char *token = NULL;
|
char *token = NULL;
|
||||||
token = std::strtok(reinterpret_cast<char*>(buf), comma);
|
token = std::strtok(reinterpret_cast<char*>(buf), comma);
|
||||||
bool parseFileName = false;
|
bool parseFileName = false;
|
||||||
ImportDataEntry entry;
|
common::ImportDataEntry entry;
|
||||||
|
|
||||||
entry.fileName = std::string(token);
|
entry.fileName = std::string(token);
|
||||||
while( token != NULL)
|
while( token != NULL)
|
||||||
@ -1583,8 +1584,26 @@ nn::Result ReadFileList(s64* totalFileSize, std::vector<ImportDataEntry>* fileLi
|
|||||||
s64 size = std::atoll(token);
|
s64 size = std::atoll(token);
|
||||||
if(size != -1)
|
if(size != -1)
|
||||||
{
|
{
|
||||||
*totalFileSize += size;
|
|
||||||
entry.isDirectory = false;
|
entry.isDirectory = false;
|
||||||
|
sdFiles->totalFileSize += size;
|
||||||
|
|
||||||
|
wchar_t wcToken[nn::fs::MAX_FILE_PATH_LENGTH];
|
||||||
|
if(std::mbstowcs(wcToken, entry.fileName.c_str(), entry.fileName.size()) != entry.fileName.size() - 1)
|
||||||
|
{
|
||||||
|
if(std::wcsstr(wcToken, common::SD_SAVEDATA_ROOT_NAME) != NULL)
|
||||||
|
{
|
||||||
|
sdFiles->ctrFileSize += size;
|
||||||
|
}
|
||||||
|
else if(std::wcsstr(wcToken, common::SD_SAVEDATA_TWL_PHOTO_ROOT_NAME) != NULL)
|
||||||
|
{
|
||||||
|
sdFiles->twlPhotoFileSize += size;
|
||||||
|
}
|
||||||
|
else if(std::wcsstr(wcToken, common::SD_SAVEDATA_TWL_SOUND_ROOT_NAME) != NULL)
|
||||||
|
{
|
||||||
|
sdFiles->twlSoundFileSize += size;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1621,12 +1640,6 @@ nn::Result ImportData()
|
|||||||
// NANDのごみを削除する
|
// NANDのごみを削除する
|
||||||
Cleanup();
|
Cleanup();
|
||||||
|
|
||||||
// ファイル一覧を読み込む
|
|
||||||
s64 totalFileSize = 0;
|
|
||||||
std::vector<ImportDataEntry> fileList;
|
|
||||||
result = ReadFileList(&totalFileSize, &fileList);
|
|
||||||
NN_UTIL_RETURN_IF_FAILED(result);
|
|
||||||
|
|
||||||
// SDカードのIVSファイルを書き込む
|
// SDカードのIVSファイルを書き込む
|
||||||
result = ImportIvs();
|
result = ImportIvs();
|
||||||
NN_UTIL_RETURN_IF_FAILED(result);
|
NN_UTIL_RETURN_IF_FAILED(result);
|
||||||
|
|||||||
@ -26,6 +26,7 @@ namespace ConsoleRestore
|
|||||||
nn::Result EqualsDeviceIdFileandDeviceId();
|
nn::Result EqualsDeviceIdFileandDeviceId();
|
||||||
nn::Result EqualsRegionDataandRegion();
|
nn::Result EqualsRegionDataandRegion();
|
||||||
nn::Result ReadSerialNumber(u8* serial);
|
nn::Result ReadSerialNumber(u8* serial);
|
||||||
|
nn::Result SetupFileList();
|
||||||
|
|
||||||
void FinalizeImportThread();
|
void FinalizeImportThread();
|
||||||
bool IsImportFinished();
|
bool IsImportFinished();
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
*---------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <nn/crypto/crypto_AesCmac.h>
|
#include <nn/crypto/crypto_AesCmac.h>
|
||||||
#include <nn/crypto/crypto_SwAesCtrContext.h>
|
#include <nn/crypto/crypto_SwAesCtrContext.h>
|
||||||
@ -48,7 +49,7 @@ void AddPathNameAndUpdateContext(nn::fs::FileOutputStream* file, const wchar_t *
|
|||||||
|
|
||||||
const char* GetCharStr(const wchar_t* path)
|
const char* GetCharStr(const wchar_t* path)
|
||||||
{
|
{
|
||||||
static char filename[256];
|
static char filename[nn::fs::MAX_FILE_PATH_LENGTH];
|
||||||
std::memset(filename, 0, sizeof(filename));
|
std::memset(filename, 0, sizeof(filename));
|
||||||
std::wcstombs(filename, path, sizeof(filename));
|
std::wcstombs(filename, path, sizeof(filename));
|
||||||
filename[sizeof(filename) - 1] = '\0';
|
filename[sizeof(filename) - 1] = '\0';
|
||||||
@ -108,14 +109,39 @@ nn::Result CalculateFileNum(std::wstring currentDirectory, u32& fileNum, s64& fi
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ExistsInList(ImportDataList* fileList, const wchar_t* path, bool isDirectory)
|
||||||
|
{
|
||||||
|
std::wstring sdPath(path);
|
||||||
|
if(isDirectory)
|
||||||
|
{
|
||||||
|
sdPath += std::wstring(L"/");
|
||||||
|
}
|
||||||
|
|
||||||
|
char str[nn::fs::MAX_FILE_PATH_LENGTH];
|
||||||
|
std::strlcpy(str, GetCharStr(sdPath.c_str()), sizeof(str));
|
||||||
|
|
||||||
|
bool returnValue = false;
|
||||||
|
for(ImportDataList::iterator it = fileList->begin(); it != fileList->end(); it++)
|
||||||
|
{
|
||||||
|
if(std::strcmp(str, it->fileName.c_str()) == 0)
|
||||||
|
{
|
||||||
|
returnValue = true;
|
||||||
|
NN_LOG("%s exists in FileList.txt\n", str);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
// ディレクトリ間のコピー
|
// ディレクトリ間のコピー
|
||||||
// アーカイブ越しのコピーが可能
|
// アーカイブ越しのコピーが可能
|
||||||
// アーカイブにマウントした状態で呼び出す必要あり
|
// アーカイブにマウントした状態で呼び出す必要あり
|
||||||
// 書き込み先のディレクトリはあらかじめ消去しておくこと。
|
// 書き込み先のディレクトリはあらかじめ消去しておくこと。
|
||||||
// 引数はスラッシュ付き
|
// 引数はスラッシュ付き
|
||||||
// TODO:分割して短くする
|
// TODO:分割して短くする
|
||||||
bool CopyDirectory(const wchar_t * from_path, const wchar_t * to_path, void* buf, const size_t bufSize, bool encode,
|
bool CopyDirectory(ImportDataList* fileList, const wchar_t * from_path, const wchar_t * to_path, void* buf,
|
||||||
nn::fs::FileOutputStream* list, nn::crypto::Sha256Context* listContext)
|
const size_t bufSize, bool encode, nn::fs::FileOutputStream* list, nn::crypto::Sha256Context* listContext)
|
||||||
{
|
{
|
||||||
nn::fs::Directory from_dir;
|
nn::fs::Directory from_dir;
|
||||||
nn::fs::DirectoryEntry entry;
|
nn::fs::DirectoryEntry entry;
|
||||||
@ -153,6 +179,16 @@ bool CopyDirectory(const wchar_t * from_path, const wchar_t * to_path, void* buf
|
|||||||
target_to.clear(std::stringstream::goodbit);
|
target_to.clear(std::stringstream::goodbit);
|
||||||
target_to << to_path << entry.entryName;
|
target_to << to_path << entry.entryName;
|
||||||
|
|
||||||
|
// NAND書き込みの場合はリストに存在するかチェックする
|
||||||
|
if (!encode)
|
||||||
|
{
|
||||||
|
if (!ExistsInList(fileList, target_from.str().c_str(), entry.attributes.isDirectory))
|
||||||
|
{
|
||||||
|
NN_LOG("============No such file %ls in FileList.txt. Skip=============\n", target_from.str().c_str());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ディレクトリの場合
|
// ディレクトリの場合
|
||||||
if (entry.attributes.isDirectory)
|
if (entry.attributes.isDirectory)
|
||||||
{
|
{
|
||||||
@ -175,7 +211,7 @@ bool CopyDirectory(const wchar_t * from_path, const wchar_t * to_path, void* buf
|
|||||||
|
|
||||||
|
|
||||||
// 再帰処理
|
// 再帰処理
|
||||||
if (!CopyDirectory(target_from.str().c_str(), target_to.str().c_str(), buf, bufSize, encode, list, listContext))
|
if (!CopyDirectory(fileList, target_from.str().c_str(), target_to.str().c_str(), buf, bufSize, encode, list, listContext))
|
||||||
{
|
{
|
||||||
ret_value = false;
|
ret_value = false;
|
||||||
}
|
}
|
||||||
@ -585,7 +621,7 @@ bool ConfirmFile(nn::fs::FileInputStream* from_file, nn::fs::FileStream* to_file
|
|||||||
if (!VerifyMac(from_file, to_file, sdFileSize, nandFileSize, buf, bufSize))
|
if (!VerifyMac(from_file, to_file, sdFileSize, nandFileSize, buf, bufSize))
|
||||||
{
|
{
|
||||||
// 検証に失敗したので削除する
|
// 検証に失敗したので削除する
|
||||||
COMMON_LOGGER("Verification Failed %s, Delete\n", GetCharStr(sdPath));
|
COMMON_LOGGER("**********Verification Failed %s, Delete**********\n", GetCharStr(sdPath));
|
||||||
result = nn::fs::TryDeleteFile(tmpPath);
|
result = nn::fs::TryDeleteFile(tmpPath);
|
||||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||||
ret_value = false;
|
ret_value = false;
|
||||||
|
|||||||
@ -19,13 +19,14 @@
|
|||||||
#include <nn.h>
|
#include <nn.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include "common_Types.h"
|
||||||
|
|
||||||
namespace common
|
namespace common
|
||||||
{
|
{
|
||||||
|
|
||||||
nn::Result CalculateFileNum(std::wstring currentDirectory, u32& fileNum, s64& fileSize);
|
nn::Result CalculateFileNum(std::wstring currentDirectory, u32& fileNum, s64& fileSize);
|
||||||
bool CopyDirectory(const wchar_t * from_path, const wchar_t * to_path, void* buf, const size_t bufSize, bool encode,
|
bool CopyDirectory(ImportDataList* fileList, const wchar_t * from_path, const wchar_t * to_path, void* buf,
|
||||||
nn::fs::FileOutputStream* list, nn::crypto::Sha256Context* listContext);
|
const size_t bufSize, bool encode, nn::fs::FileOutputStream* list, nn::crypto::Sha256Context* listContext);
|
||||||
u32 GetProgress();
|
u32 GetProgress();
|
||||||
void InitializeTransferProgress(u64 totalSize);
|
void InitializeTransferProgress(u64 totalSize);
|
||||||
|
|
||||||
|
|||||||
@ -23,6 +23,9 @@
|
|||||||
#include <nn/pl/CTR/pl_SharedDataTitleId.h>
|
#include <nn/pl/CTR/pl_SharedDataTitleId.h>
|
||||||
#include <nn/pl/CTR/pl_Version.h>
|
#include <nn/pl/CTR/pl_Version.h>
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace common
|
namespace common
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -87,6 +90,14 @@ struct BackupDataHeader
|
|||||||
NN_PADDING4;
|
NN_PADDING4;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ImportDataEntry
|
||||||
|
{
|
||||||
|
std::string fileName;
|
||||||
|
NN_PADDING3;
|
||||||
|
bool isDirectory;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::vector<common::ImportDataEntry> ImportDataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* COMMON_TYPES_H_ */
|
#endif /* COMMON_TYPES_H_ */
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user