バッファリング済みテキストは一括で書き込むように

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@591 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
N2614 2012-01-23 05:52:51 +00:00
parent c6f44637c4
commit 45897ab20c
2 changed files with 16 additions and 4 deletions

View File

@ -17,6 +17,7 @@
#include <string> #include <string>
#include "SDMountManager.h" #include "SDMountManager.h"
#include "FileName.h" #include "FileName.h"
#include "HeapManager.h"
namespace common namespace common
{ {
@ -112,7 +113,7 @@ void SetInsertHandler(void (*func)())
s_SdInsertedEventFunc = func; s_SdInsertedEventFunc = func;
} }
SdLogger::SdLogger() : m_TryActivate(false), m_Permitted(false) SdLogger::SdLogger() : m_BufferSize(0), m_TryActivate(false), m_Permitted(false)
{ {
} }
@ -143,15 +144,25 @@ void SdLogger::Print(const char* fmt, ::std::va_list arg)
{ {
NN_LOG("SD Write Not Permitted\n"); NN_LOG("SD Write Not Permitted\n");
m_Buffer.push_back(std::string(str)); m_Buffer.push_back(std::string(str));
m_BufferSize += stringSize * sizeof(char);
return; return;
} }
// バッファリング済みならまず吐き出す // バッファリング済みならまず吐き出す
for(std::vector<std::string>::iterator it = m_Buffer.begin(); it != m_Buffer.end(); it++) if (m_BufferSize != 0)
{ {
PrintCore(it->c_str(), it->size()); HeapManager heap(m_BufferSize);
void* buf = heap.GetAddr();
size_t strSize = 0;
for (std::vector<std::string>::iterator it = m_Buffer.begin(); it != m_Buffer.end(); it++)
{
std::memcpy(reinterpret_cast<char*>(buf) + strSize, it->c_str(), it->size() * sizeof(char));
strSize += it->size();
}
PrintCore(reinterpret_cast<char*>(buf), m_BufferSize);
m_Buffer.clear();
m_BufferSize = 0;
} }
m_Buffer.clear();
PrintCore(str, stringSize); PrintCore(str, stringSize);

View File

@ -48,6 +48,7 @@ private:
nn::fs::FileOutputStream sd; nn::fs::FileOutputStream sd;
std::vector<std::string> m_Buffer; std::vector<std::string> m_Buffer;
size_t m_BufferSize;
bool m_TryActivate; bool m_TryActivate;
bool m_Permitted; bool m_Permitted;
NN_PADDING2; NN_PADDING2;