void VDLogF(int severity, const wchar_t *format, ...) { va_list val; va_start(val, format); VDStringW s; s.append_vsprintf(format, val); va_end(val); VDLog(severity, s); }
void MyError::post(HWND hWndParent, const char *title) const { if (!buf || !*buf) return; VDDEBUG("*** %s: %s\n", title, buf); VDLog(kVDLogError, VDswprintf(L"Error: %hs", 1, &buf)); MessageBox(hWndParent, buf, title, MB_OK | MB_ICONERROR | MB_SETFOREGROUND); }
void AppendAVIAutoscan(const wchar_t *pszFile) { wchar_t buf[MAX_PATH]; wchar_t *s = buf, *t; int count = 0; if (!inputAVI) return; IVDStreamSource *pVSS = inputVideo->asStream(); VDPosition originalCount = pVSS->getEnd(); wcscpy(buf, pszFile); t = VDFileSplitExt(VDFileSplitPath(s)); if (t>buf) --t; try { for(;;) { if (!VDDoesPathExist(buf)) break; if (!inputAVI->Append(buf)) break; ++count; s = t; for(;;) { if (s<buf || !isdigit(*s)) { memmove(s+2, s+1, sizeof(wchar_t) * wcslen(s)); s[1] = L'1'; ++t; } else { if (*s == L'9') { *s-- = L'0'; continue; } ++*s; } break; } } } catch(const MyError& e) { // if the first segment failed, turn the warning into an error if (!count) throw; // log append errors, but otherwise eat them VDLog(kVDLogWarning, VDTextAToW(e.gets())); } guiSetStatus("Appended %d segments (stopped at \"%s\")", 255, count, VDTextWToA(buf).c_str()); if (count) { FrameSubset& s = g_project->GetTimeline().GetSubset(); g_project->BeginTimelineUpdate(); s.insert(s.end(), FrameSubsetNode(originalCount, pVSS->getEnd() - originalCount, false, 0)); g_project->EndTimelineUpdate(); } }
void VDLog(int severity, const VDStringW& s) { VDLog(severity, s.c_str()); }
void VDDumpChangeLog() { HRSRC hResource = FindResource(NULL, MAKEINTRESOURCE(IDR_CHANGES), "STUFF"); if (!hResource) return; HGLOBAL hGlobal = LoadResource(NULL, hResource); if (!hGlobal) return; LPVOID lpData = LockResource(hGlobal); if (!lpData) return; const char *s = (const char *)lpData; while(*s!='\r') ++s; s+=2; tTextStream lineBuffer; VDStringA breakLineBuffer; bool foundNonIndentedLine = false; while(*s) { // parse line if (*s != ' ') { if (foundNonIndentedLine) break; foundNonIndentedLine = true; } const char *end = s; while(*end && *end != '\r' && *end != '\n') ++end; lineBuffer.clear(); append_cooked(lineBuffer, s, end, false); // skip line termination s = end; if (*s == '\r' || *s == '\n') { ++s; if ((s[0] ^ s[-1]) == ('\r' ^ '\n')) ++s; } lineBuffer.push_back(0); // break into lines const char *t = lineBuffer.data(); int maxLine = 78; breakLineBuffer.clear(); do { const char *lineStart = t; const char *break1 = NULL; const char *break2 = NULL; do { while(*t && *t != ' ') ++t; const char *u = t; while(*t && *t == ' ') ++t; if (u - lineStart > maxLine) { if (!break1) { break1 = u + maxLine; break2 = break1; } break; } break1 = u; break2 = t; } while(*t); breakLineBuffer.append(lineStart, break1); VDLog(kVDLogInfo, VDTextAToW(breakLineBuffer.data(), breakLineBuffer.size())); t = break2; breakLineBuffer.clear(); breakLineBuffer.resize(5, ' '); maxLine = 73; } while(*t); } }