void CLogOutput::Output(const std::string& str) { GML_STDMUTEX_LOCK(log); // Output std::string msg; #if !defined UNITSYNC && !defined DEDICATED if (gs) { msg += IntToString(gs->frameNum, "[f=%07d] "); } #endif msg += str; if (!initialized) { ToStderr(msg); preInitLog().push_back(msg); return; } #ifdef _MSC_VER int index = strlen(str.c_str()) - 1; bool newline = ((index < 0) || (str[index] != '\n')); OutputDebugString(msg.c_str()); if (newline) { OutputDebugString("\n"); } #endif // _MSC_VER ToFile(msg); ToStderr(msg); }
void CLogOutput::Initialize() { if (initialized) return; filePath = CreateFilePath(fileName); RotateLogFile(); filelog = new std::ofstream(filePath.c_str()); if (filelog->bad()) SafeDelete(filelog); initialized = true; InitializeSections(); std::vector<std::string>::iterator pili; for (pili = preInitLog().begin(); pili != preInitLog().end(); ++pili) { ToFile(*pili); } preInitLog().clear(); LOG("LogOutput initialized."); LOG("Spring %s", SpringVersion::GetFull().c_str()); LOG("Build date/time: %s", SpringVersion::GetBuildTime().c_str()); LOG("Build environment: %s", SpringVersion::GetBuildEnvironment().c_str()); LOG("Compiler: %s", SpringVersion::GetCompiler().c_str()); }
bool IPlatformFile::CopyFile(const TCHAR* To, const TCHAR* From) { const int64 MaxBufferSize = 1024*1024; TAutoPtr<IFileHandle> FromFile(OpenRead(From)); if (!FromFile.IsValid()) { return false; } TAutoPtr<IFileHandle> ToFile(OpenWrite(To)); if (!ToFile.IsValid()) { return false; } int64 Size = FromFile->Size(); if (Size < 1) { check(Size == 0); return true; } int64 AllocSize = FMath::Min<int64>(MaxBufferSize, Size); check(AllocSize); uint8* Buffer = (uint8*)FMemory::Malloc(int32(AllocSize)); check(Buffer); while (Size) { int64 ThisSize = FMath::Min<int64>(AllocSize, Size); FromFile->Read(Buffer, ThisSize); ToFile->Write(Buffer, ThisSize); Size -= ThisSize; check(Size >= 0); } FMemory::Free(Buffer); return true; }
int cStringList::ToFile(const cString &fname,int s, int ed, cString ending) { if(fname.Contains('*')) return 0; if(ed==-1) ed=Length(); ofstream ofile(fname); int r=ToFile(ofile,s,ed,ending); ofile.close(); return r; }
Component *ComponentOp2::Copy() { std::stringstream t; ToFile(t); return FromFile(t); }
BOOL CVersionInfo::Save() { return ToFile(); }