static noinline void DoLog(const mpt::log::Context &context, mpt::ustring message) //-------------------------------------------------------------------------------- { // remove eol if already present message = mpt::String::RTrim(message, MPT_USTRING("\r\n")); #if defined(MODPLUG_TRACKER) static uint64_t s_lastlogtime = 0; uint64 cur = mpt::Date::ANSI::Now(); uint64 diff = cur/10000 - s_lastlogtime; s_lastlogtime = cur/10000; #ifdef LOG_TO_FILE { static FILE * s_logfile = nullptr; if(!s_logfile) { s_logfile = mpt_fopen(MPT_PATHSTRING("mptrack.log"), "a"); } if(s_logfile) { fprintf(s_logfile, mpt::ToCharset(mpt::CharsetUTF8, mpt::String::Print(MPT_USTRING("%1+%2 %3(%4): %5 [%6]\n" , mpt::Date::ANSI::ToString(cur) , mpt::ufmt::dec<6>(diff) , mpt::ToUnicode(mpt::CharsetASCII, context.file) , context.line , message , mpt::ToUnicode(mpt::CharsetASCII, context.function) ))).c_str()); fflush(s_logfile); } } #endif // LOG_TO_FILE { OutputDebugStringW(mpt::String::PrintW(L"%1(%2): +%3 %4 [%5]\n" , mpt::ToWide(mpt::CharsetASCII, context.file) , context.line , mpt::wfmt::dec<6>(diff) , message , mpt::ToWide(mpt::CharsetASCII, context.function) ).c_str()); } #else // !MODPLUG_TRACKER std::clog << "openmpt: " << context.file << "(" << context.line << ")" << ": " #if defined(MPT_WITH_CHARSET_LOCALE) << mpt::ToLocale(message) #else << mpt::ToCharset(mpt::CharsetUTF8, message) #endif << " [" << context.function << "]" << std::endl; #endif // MODPLUG_TRACKER }
static noinline void DoLog(const mpt::log::Context &context, std::wstring message) //-------------------------------------------------------------------------------- { // remove eol if already present message = mpt::String::RTrim(message, L"\r\n"); #if defined(MODPLUG_TRACKER) static uint64_t s_lastlogtime = 0; uint64 cur = GetTimeMS(); uint64 diff = cur - s_lastlogtime; s_lastlogtime = cur; #ifdef LOG_TO_FILE { static FILE * s_logfile = nullptr; if(!s_logfile) { s_logfile = mpt_fopen(MPT_PATHSTRING("mptrack.log"), "a"); } if(s_logfile) { fprintf(s_logfile, "%s+%s %s(%i): %s [%s]\n", TimeAsAsString(cur).c_str(), TimeDiffAsString(diff).c_str(), context.file, context.line, mpt::To(mpt::CharsetUTF8, message).c_str(), context.function); fflush(s_logfile); } } #endif // LOG_TO_FILE { OutputDebugStringW(mpt::String::PrintW(L"%1(%2): +%3 %4 [%5]\n", mpt::ToWide(mpt::CharsetASCII, context.file), context.line, TimeDiffAsStringW(diff), message, mpt::ToWide(mpt::CharsetASCII, context.function)).c_str()); } #else // !MODPLUG_TRACKER std::clog << "openmpt: " << context.file << "(" << context.line << ")" << ": " #if defined(MPT_WITH_CHARSET_LOCALE) << mpt::ToLocale(message) #else << mpt::To(mpt::CharsetUTF8, message) #endif << " [" << context.function << "]" << std::endl; #endif // MODPLUG_TRACKER }
bool CModDoc::SaveEnvelope(INSTRUMENTINDEX nIns, EnvelopeType nEnv, const mpt::PathString &fileName) //-------------------------------------------------------------------------------------------------- { if (nIns < 1 || nIns > m_SndFile.m_nInstruments || !m_SndFile.Instruments[nIns]) return false; BeginWaitCursor(); const ModInstrument *pIns = m_SndFile.Instruments[nIns]; if(pIns == nullptr) return false; CStringA s; EnvelopeToString(s, pIns->GetEnvelope(nEnv)); FILE *f = mpt_fopen(fileName, "wb"); if(f == nullptr) { EndWaitCursor(); return false; } fwrite(s.GetString(), s.GetLength(), 1, f); fclose(f); EndWaitCursor(); return true; }