設定ファイルがない場合SDに出力しないように

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@93 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
N2614 2011-02-28 02:37:31 +00:00
parent 47a5a71ef6
commit 85ef909842
2 changed files with 53 additions and 2 deletions

View File

@ -65,6 +65,7 @@ void SdmcEjectedEventThreadFunc()
} }
SdMountManager::ForceUnmount(); SdMountManager::ForceUnmount();
s_SdEjectedEvent.ClearSignal(); s_SdEjectedEvent.ClearSignal();
s_SdLogger.Inactivate();
} }
} }
@ -109,7 +110,7 @@ void SetInsertHandler(void (*func)())
s_SdInsertedEventFunc = func; s_SdInsertedEventFunc = func;
} }
SdLogger::SdLogger() SdLogger::SdLogger() : m_TryActivate(false), m_Permitted(false)
{ {
} }
@ -121,8 +122,14 @@ SdLogger* GetSdInstance()
void SdLogger::Print(const char* fmt, ::std::va_list arg) void SdLogger::Print(const char* fmt, ::std::va_list arg)
{ {
nn::Result result; Activate();
if(!m_Permitted)
{
NN_LOG("SD Write Not Permitted\n");
return;
}
nn::Result result;
result = SdMountManager::Mount(); result = SdMountManager::Mount();
if (result.IsFailure()) if (result.IsFailure())
{ {
@ -201,6 +208,12 @@ void SdLogger::Print(const char* fmt, ::std::va_list arg)
void SdLogger::Clear() void SdLogger::Clear()
{ {
Activate();
if(!m_Permitted)
{
return;
}
nn::Result result; nn::Result result;
SdMountManager::Mount(); SdMountManager::Mount();
@ -216,6 +229,38 @@ void SdLogger::Clear()
SdMountManager::Unmount(); SdMountManager::Unmount();
} }
void SdLogger::Inactivate()
{
m_TryActivate = false;
m_Permitted = false;
}
void SdLogger::Activate()
{
if(m_TryActivate)
{
return;
}
nn::Result result;
result = common::SdMountManager::Mount();
if (result.IsSuccess())
{
nn::fs::FileInputStream fis;
result = fis.TryInitialize(common::AP_SETTING_PATHNAME);
if(result.IsSuccess())
{
m_Permitted = true;
}
fis.Finalize();
}
common::SdMountManager::Unmount();
m_TryActivate = true;
}
} // namespace Logger } // namespace Logger
} // namespace ConsoleBackup } // namespace ConsoleBackup

View File

@ -32,9 +32,15 @@ public:
void Print(const char* fmt, ::std::va_list arg); void Print(const char* fmt, ::std::va_list arg);
void Clear(); void Clear();
void Inactivate();
private: private:
void Activate();
nn::fs::FileOutputStream sd; nn::fs::FileOutputStream sd;
bool m_TryActivate;
bool m_Permitted;
NN_PADDING2;
}; };