CString CConfigMsgLogDlg::GetUniqueLogFilePath(void) { CString omStrFullPath = ""; std::string acPathBuffer = {L'\0'}; // Get current working char acFilePath[BM_MAX_PATH] = {L'\0'}; // Get current working GetCurrentVerBusMasterUserDataPath(acPathBuffer); BOOL bFound = TRUE; // Means - "found unique name" for (USHORT Count = 0; bFound == TRUE; Count++) { CString omNewLogFileName = ""; // New Log file name auto baseName = GetDefaultLogFileName(); omNewLogFileName.Format("%s_%d.log", baseName.c_str(), Count); PathCombine(acFilePath, acPathBuffer.c_str(), omNewLogFileName.GetBuffer(MAX_PATH)); omStrFullPath = acFilePath; // We have two different strings to compare. The first one is the bare // log file name and the second one is the full path. // Iterate through the list of existing logging blocks. If the same // file name has a hit, then try for another name. bFound = FoundInLogList(omStrFullPath, omNewLogFileName); } // At the end of this routine a unique log file should've been found. return omStrFullPath; }
CString CConfigMsgLogDlg::GetUniqueLogFilePath(void) { CString omStrFullPath = ""; char acPathBuffer[MAX_PATH] = {L'\0'}; // Get current working GetCurrentDirectory(MAX_PATH, acPathBuffer); // directory BOOL bFound = TRUE; // Means - "found unique name" for (USHORT Count = 0; bFound == TRUE; Count++) { CString omNewLogFileName = ""; // New Log file name // Contrive a log file name on interation index if (CAN == m_eCurrBus) { omNewLogFileName.Format(BUSMASTER_CAN_LOGFILENAME, Count); } else if (J1939 == m_eCurrBus) { omNewLogFileName.Format(BUSMASTER_J1939_LOGFILENAME, Count); } omStrFullPath = acPathBuffer; // Full Path omStrFullPath = omStrFullPath + _T("\\") + omNewLogFileName; // We have two different strings to compare. The first one is the bare // log file name and the second one is the full path. // Iterate through the list of existing logging blocks. If the same // file name has a hit, then try for another name. bFound = FoundInLogList(omStrFullPath, omNewLogFileName); } // At the end of this routine a unique log file should've been found. return omStrFullPath; }