MCPcopy Create free account
hub / github.com/ashkulz/NppFTP / OpenLog

Method OpenLog

UTCP/src/uh_ctrl.cpp:1471–1513  ·  view source on GitHub ↗

OpenLog Internal function Opens up the history log file for writing. Params none Return 0 - (UH_SUCCESS) 1 - (UH_ERROR) ***********************************************/

Source from the content-addressed store, hash-verified

1469 1 - (UH_ERROR)
1470***********************************************/
1471int CUH_Control::OpenLog(){
1472
1473 CloseLog();
1474
1475 if(m_timeStampedLog){
1476 //get the date string
1477 time_t t = time(NULL);
1478 struct tm * systime = localtime(&t);
1479 _TCHAR strDate[30];
1480 m_logDay = systime->tm_mday;
1481 m_logMonth = systime->tm_mon;
1482 m_logYear = systime->tm_year;
1483 _sntprintf(strDate,sizeof(strDate)/sizeof(_TCHAR)-1,_T("%2.2d%2.2d%4.4d"),systime->tm_mday,systime->tm_mon+1,
1484 systime->tm_year+1900);
1485
1486 //find the .
1487 int pos;
1488 int len = (int)_tcslen(m_logName);
1489 for(pos = 0; pos < len; pos++){
1490 if(m_logName[pos] == '.')
1491 break;
1492 }
1493
1494 //add the date string just before the . in the filename
1495 _TCHAR * buf = new _TCHAR[len+10];
1496 _tcscpy(buf,m_logName);
1497 buf[pos] =0;
1498 _tcscat(buf,strDate);
1499 _tcscat(buf,&m_logName[pos]);
1500
1501 m_fileHandle = _tfopen(buf,_T("a+"));
1502
1503 delete[] buf;
1504 }
1505 else{
1506 m_fileHandle = _tfopen(m_logName,_T("a+"));
1507 }
1508
1509 if(m_fileHandle == NULL)
1510 return UH_ERROR;
1511
1512 return UH_SUCCESS;
1513}
1514
1515/**********************************************
1516CloseLog

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected