int _tmain(int argc, TCHAR *argv[]) { setlocale( LC_ALL, "" ); bool append = false; int rc = 1; if (argc > 1) { if (_tcsicmp(argv[1], _T("/i")) == 0 || _tcsicmp(argv[1], _T("-i")) == 0) { if (argc < 4) { return 1; } else { if (_tcsicmp(argv[2], _T("/a")) == 0 || _tcsicmp(argv[2], _T("-a")) == 0) append = true; else if (_tcsicmp(argv[2], _T("/o")) == 0 || _tcsicmp(argv[2], _T("-o")) == 0) ; //override else { usage_(argv[0]); return 1; } if (!_tfreopen(argv[3], _T("r"), stdin)) { _tprintf(_T("Error opening file %s"), argv[3]); usage_(argv[0]); return 1; } } rc = import_(append); } else if (_tcsicmp(argv[1], _T("/e")) == 0 || _tcsicmp(argv[1], _T("-e")) == 0) { if (argc > 2) if (!_tfreopen(argv[2], _T("w"), stdout)) { _tprintf(_T("Error opening file %s"), argv[2]); usage_(argv[0]); return 1; } rc = export_(); } else { usage_(argv[0]); } } else { usage_(argv[0]); } return rc; }
bool Log::clear(void) { bool ret = true; ::EnterCriticalSection(&m_lock); if (m_log_fp != NULL) { m_log_fp = _tfreopen(m_fullpath.str().c_str(), _T("w"), m_log_fp); if (NULL == m_log_fp) { ret = false; } } ::LeaveCriticalSection(&m_lock); return ret; }