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