mirror of
https://github.com/rvtr/ctr_Repair.git
synced 2025-10-31 13:51:08 -04:00
SDカード未挿入時のログ出力をバッファリングしておいて、挿入後の書き込み関数実行時に書き込むように
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@497 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
parent
e986284a7c
commit
575a05c713
@ -135,6 +135,7 @@ extern "C" void nnMain(void)
|
||||
// RenderSystemを作ってからログが出せる
|
||||
common::Logger::InitializeEjectThread();
|
||||
common::Logger::SetEjectHandler(OnSdEjected);
|
||||
common::Logger::SetInsertHandler(OnSdInserted);
|
||||
// 起動時に削除
|
||||
common::Logger::GetLoggerInstance()->ClearSdLog();
|
||||
|
||||
|
||||
@ -489,6 +489,11 @@ void OnSdEjected()
|
||||
}
|
||||
}
|
||||
|
||||
void OnSdInserted()
|
||||
{
|
||||
common::Logger::GetLoggerInstance()->ClearSdLog();
|
||||
}
|
||||
|
||||
void InitializeState()
|
||||
{
|
||||
s_BackupState = STARTUP;
|
||||
|
||||
@ -54,6 +54,9 @@ bool IsBackupWarning();
|
||||
// SDカードが抜き出されたときに実行したい関数
|
||||
void OnSdEjected();
|
||||
|
||||
// SDカードが挿し込まれたときに実行する処理
|
||||
void OnSdInserted();
|
||||
|
||||
// 状態を初期化する
|
||||
void InitializeState();
|
||||
|
||||
|
||||
@ -82,6 +82,7 @@ void SdmcInsertedEventThreadFunc()
|
||||
{
|
||||
s_SdInsertedEventFunc();
|
||||
}
|
||||
SdMountManager::ForceUnmount();
|
||||
s_SdInsertedEvent.ClearSignal();
|
||||
s_SdLogger.Inactivate();
|
||||
}
|
||||
@ -124,12 +125,6 @@ SdLogger* GetSdInstance()
|
||||
void SdLogger::Print(const char* fmt, ::std::va_list arg)
|
||||
{
|
||||
Activate();
|
||||
if(!m_Permitted)
|
||||
{
|
||||
NN_LOG("SD Write Not Permitted\n");
|
||||
return;
|
||||
}
|
||||
|
||||
nn::Result result;
|
||||
result = SdMountManager::Mount();
|
||||
if (result.IsFailure())
|
||||
@ -143,6 +138,29 @@ void SdLogger::Print(const char* fmt, ::std::va_list arg)
|
||||
|
||||
stringSize = nn::nstd::TVSNPrintf(str, sizeof(str), fmt, arg);
|
||||
|
||||
// 書き込み不可であればバッファリングのみ行う
|
||||
if(!m_Permitted)
|
||||
{
|
||||
NN_LOG("SD Write Not Permitted\n");
|
||||
m_Buffer.push_back(std::string(str));
|
||||
return;
|
||||
}
|
||||
|
||||
// バッファリング済みならまず吐き出す
|
||||
for(std::vector<std::string>::iterator it = m_Buffer.begin(); it != m_Buffer.end(); it++)
|
||||
{
|
||||
PrintCore(it->c_str(), it->size());
|
||||
}
|
||||
m_Buffer.clear();
|
||||
|
||||
PrintCore(str, stringSize);
|
||||
|
||||
SdMountManager::Unmount();
|
||||
}
|
||||
|
||||
nn::Result SdLogger::PrintCore(const char* str, size_t size)
|
||||
{
|
||||
nn::Result result;
|
||||
::std::wstring log(common::SDMC_ROOT_DIRECTORY_PATH);
|
||||
log += common::LOG_PATHNAME;
|
||||
|
||||
@ -168,7 +186,7 @@ void SdLogger::Print(const char* fmt, ::std::va_list arg)
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
s32 writeSize;
|
||||
result = sd.TryWrite(&writeSize, str, stringSize, true);
|
||||
result = sd.TryWrite(&writeSize, str, size, true);
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
result = sd.TryFlush();
|
||||
@ -204,7 +222,8 @@ void SdLogger::Print(const char* fmt, ::std::va_list arg)
|
||||
|
||||
dir.Finalize();
|
||||
sd.Finalize();
|
||||
SdMountManager::Unmount();
|
||||
|
||||
return nn::ResultSuccess();
|
||||
}
|
||||
|
||||
void SdLogger::Clear()
|
||||
|
||||
@ -17,6 +17,8 @@
|
||||
#define SDLOGGER_H_
|
||||
|
||||
#include <nn.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
namespace common
|
||||
{
|
||||
@ -42,7 +44,10 @@ public:
|
||||
private:
|
||||
void Activate();
|
||||
|
||||
nn::Result PrintCore(const char* str, size_t size);
|
||||
|
||||
nn::fs::FileOutputStream sd;
|
||||
std::vector<std::string> m_Buffer;
|
||||
bool m_TryActivate;
|
||||
bool m_Permitted;
|
||||
NN_PADDING2;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user