void History::AddLine(const std::string& line) { // Add a line to entries and file. if (line.empty()) return; fEntries.push_back(line); AppendToFile(); }
bool FileLogger::Log(const gs2d::str_type::string& str, const TYPE& type) const { #if defined(WIN32) || defined(APPLE_IOS) || defined(MACOSX) GS2D_COUT << str << std::endl; if (type == ERROR) { GS2D_CERR << GS_L("\x07"); } #endif if (type == ERROR) WriteToErrorLog(str); else if (type == WARNING) WriteToWarningLog(str); #ifdef ANDROID switch (type) { case ERROR: case WARNING: LOGE(str.c_str()); break; default: LOGI(str.c_str()); } #endif return AppendToFile(m_fileName, str); }
void FileLogger::WriteToWarningLog(const gs2d::str_type::string& str) { static bool warningLogFileCreated = false; if (!warningLogFileCreated) { gs2d::str_type::ofstream ofs(GetWarningLogFileDirectory().c_str()); if (ofs.is_open()) { ofs << GS_L("[") << GetWarningLogFileDirectory() << GS_L("]") << std::endl; ofs.close(); } } AppendToFile(GetWarningLogFileDirectory(), str); warningLogFileCreated = true; }
void FileLogger::WriteToErrorLog(const gs2d::str_type::string& str) { static bool errorLogFileCreated = false; if (!errorLogFileCreated) { gs2d::str_type::ofstream ofs(GetErrorLogFilePath().c_str()); if (ofs.is_open()) { ofs << GS_L("[") << GetErrorLogFilePath() << GS_L("]") << std::endl; ofs.close(); } } AppendToFile(GetErrorLogFilePath(), str); errorLogFileCreated = true; }
nsresult nsIncrementalDownload::FlushChunk() { NS_ASSERTION(mTotalSize != int64_t(-1), "total size should be known"); if (mChunkLen == 0) return NS_OK; nsresult rv = AppendToFile(mDest, mChunk.get(), mChunkLen); if (NS_FAILED(rv)) return rv; mCurrentSize += int64_t(mChunkLen); mChunkLen = 0; return NS_OK; }
void DumpFlash(tDevice dev, tDumpMode mode) { int totalBlocks= WII_FLASH_SIZE/FLASH_BLOCKSIZE; // Number of pages in NAND int totalSteps= totalBlocks/WII_MAX_BUFFER; FILE *pFile; int blocks_read=0; int steps= 0; // To test //totalSteps= 2; buffer = (u8*) memalign(0x40, WII_MAX_BUFFER*getDumpBlockSize(mode)); if(buffer==NULL) { printf("ERROR: Unable to allocate enough memory for buffer. Unable to continue. Exiting...\n"); pressAnyButton(); exit(0); } initialise_fat(dev); pFile = fopen(getDeviceFile(dev, mode), "wb+"); if (pFile==NULL) { printf("ERROR: fopen(\"%s\") failed. No FAT filesystem on the %s?\n", getDeviceFile(dev, mode), getDeviceName(dev)); pressAnyButton(); exit(0); } else { fclose(pFile); CleanScreen(); for(steps=0; steps<totalSteps; steps++) { // Block set to read in this step starts on... blocks_read= steps*WII_MAX_BUFFER; if((steps % WII_SCREEN_LINES)==0) {CleanScreen(); printf("\nDumping NAND. Pass %d of %d.", (steps/WII_SCREEN_LINES)+1, WII_SCREEN_STEPS);} ReadFlash(blocks_read, mode); AppendToFile(dev, mode); } } printf("\n\nEnd of Flash Dump."); pressAnyButton(); if(buffer!=NULL) free(buffer); }
nsresult nsIncrementalDownload::FlushChunk() { NS_ASSERTION(mTotalSize != nsInt64(-1), "total size should be known"); if (mChunkLen == 0) return NS_OK; nsresult rv = AppendToFile(mDest, mChunk, mChunkLen); if (NS_FAILED(rv)) return rv; mCurrentSize += nsInt64(mChunkLen); mChunkLen = 0; if (mProgressSink) mProgressSink->OnProgress(this, mObserverContext, PRUint64(PRInt64(mCurrentSize)), PRUint64(PRInt64(mTotalSize))); return NS_OK; }
void log(const TCHAR* msg, bool bFromSendRecieve, CString csFile, long lLine) { ASSERT(AfxIsValidString(msg)); SYSTEMTIME st; GetSystemTime(&st); CString csText; csText.Format(_T("[%d/%d/%d %02d:%02d:%02d.%03d - "), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds); CString csFileLine; csFile = GetFileName(csFile); csFileLine.Format(_T("%s %d] "), csFile, lLine); csText += csFileLine; csText += msg; csText += "\n"; #ifndef _DEBUG if(CGetSetOptions::m_bOutputDebugString) #endif { OutputDebugString(csText); } #ifndef _DEBUG if(!bFromSendRecieve) { if(!g_Opt.m_bEnableDebugLogging) return; } #endif CString csExeFile = CGetSetOptions::GetPath(PATH_LOG_FILE); csExeFile += "Ditto.log"; AppendToFile(csExeFile, csText); }