ファイル一覧にファイルサイズを含めるように

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@153 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
N2614 2011-03-18 08:12:34 +00:00
parent 10dd9270d2
commit da1f86929b

View File

@ -43,7 +43,8 @@ bool VerifyMac(nn::fs::FileInputStream* sdFile, nn::fs::FileStream* nandFile, s6
bool ConfirmFile(nn::fs::FileInputStream* from_file, nn::fs::FileStream* to_file, s64 sdFileSize, s64 nandFileSize,
void* buf, size_t bufSize, const wchar_t* sdPath, const wchar_t* tmpPath, const wchar_t* truePath);
void AddPkcsPadding(u8* paddingSize, void* buf, size_t bufSize, s32* readSize);
void AddPathNameAndUpdateContext(nn::fs::FileOutputStream* file, const wchar_t *str, nn::crypto::Sha256Context* context);
void AddPathNameAndUpdateContext(nn::fs::FileOutputStream* file, const wchar_t *str, s64 fileSize,
nn::crypto::Sha256Context* context);
const char* GetCharStr(const wchar_t* path)
{
@ -169,7 +170,7 @@ bool CopyDirectory(const wchar_t * from_path, const wchar_t * to_path, void* buf
target_to << L"/";
if(encode)
{
AddPathNameAndUpdateContext(list, target_to.str().c_str(), listContext);
AddPathNameAndUpdateContext(list, target_to.str().c_str(), 0, listContext);
}
@ -187,12 +188,6 @@ bool CopyDirectory(const wchar_t * from_path, const wchar_t * to_path, void* buf
target_tmp.str(L"");
target_tmp.clear(std::stringstream::goodbit);
if(encode)
{
AddPathNameAndUpdateContext(list, target_to.str().c_str(), listContext);
}
if(!encode)
{
target_tmp << to_path << L"_" << entry.entryName;
@ -231,6 +226,11 @@ bool CopyDirectory(const wchar_t * from_path, const wchar_t * to_path, void* buf
}
else
{
if(encode)
{
AddPathNameAndUpdateContext(list, target_to.str().c_str(), filesize, listContext);
}
nn::crypto::SwAesCtrContext swAesCtrContext;
swAesCtrContext.Initialize(iv, common::key, sizeof(key));
@ -623,10 +623,13 @@ void AddPkcsPadding(u8* paddingSize, void* buf, size_t bufSize, s32* readSize)
}
}
//! @brief ファイルに文字列を改行付きで追加します
//! @brief ファイルに文字列とサイズカンマ区切り、改行付きで追加します
//! @param[in] file 文字列を出力したいファイル
//! @param[in] str 入力文字列
void AddPathNameAndUpdateContext(nn::fs::FileOutputStream* file, const wchar_t *str, nn::crypto::Sha256Context* context)
//! @param[in] str 入力文字列
//! @param[in] fileSize サイズ
//! @param[in] context SHA-256計算用コンテキスト
void AddPathNameAndUpdateContext(nn::fs::FileOutputStream* file, const wchar_t *str, s64 fileSize,
nn::crypto::Sha256Context* context)
{
nn::Result result;
s32 writeSize;
@ -636,6 +639,15 @@ void AddPathNameAndUpdateContext(nn::fs::FileOutputStream* file, const wchar_t *
context->Update(output.c_str(), output.size());
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
char comma = ',';
result = file->TryWrite(&writeSize, &comma, sizeof(comma), true);
context->Update(&comma, sizeof(comma));
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
result = file->TryWrite(&writeSize, &fileSize, sizeof(fileSize), true);
context->Update(&fileSize, sizeof(fileSize));
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
char newLine = '\n';
result = file->TryWrite(&writeSize, &newLine, sizeof(newLine), true);
context->Update(&newLine, sizeof(newLine));