string GetTempPath() { TCHAR tempPath[MAX_PATH]; GetTempPathA(MAX_PATH, tempPath); string cryMonoTempDir = string(tempPath) + string("CryMono//"); DWORD attribs = GetFileAttributesA(cryMonoTempDir.c_str()); if(attribs == INVALID_FILE_ATTRIBUTES || attribs | FILE_ATTRIBUTE_DIRECTORY) CryCreateDirectory(cryMonoTempDir.c_str(), nullptr); return cryMonoTempDir; }
// Description: // // Arguments: // // Return: // bool CVisualLog::OpenLogs() { m_sFormat = m_pCVVisualLogImageFormat->GetString(); m_eFormat = GetFormatType( m_sFormat ); m_sLogFolder = m_pCVVisualLogFolder->GetString(); int iLogFolderLen = m_sLogFolder.length(); // Check we have good params to use if ( m_eFormat == EVLF_NONE || iLogFolderLen == 0 ) { GameWarning( "[VisualLog] File format or log folder value invalid" ); return false; } // Create base directory if necessary CryCreateDirectory( m_sLogFolder ); // Figure out next number in sequence m_sLogFolderName/m_sLogFolderNameXXXX, where XXXX is 0000, 0001, etc. int iSeqNum = 0; __finddata64_t fd; intptr_t handle = _findfirst64( PathUtil::Make( m_sLogFolder , "*.*" ), &fd ); if ( handle != -1 ) { do { // Is it a directory with our base name as a prefix? if ( fd.attrib & _A_SUBDIR && fd.name[0]!='.' && !_strnicmp( m_sLogFolder, fd.name, iLogFolderLen ) ) { iSeqNum = max( iSeqNum, atoi( fd.name + iLogFolderLen ) + 1 ); } } while (0 == _findnext64 (handle, &fd)); _findclose(handle); } // Now create directory char sLogPath[256]; _snprintf( sLogPath, sizeof(sLogPath), "%s\\%s%04d", m_sLogFolder.c_str(), m_sLogFolder.c_str(), iSeqNum ); if ( !CryCreateDirectory( sLogPath ) ) { GameWarning( "[VisualLog] Unable to create directory for log files: %s", sLogPath ); return false; } m_sLogPath = sLogPath; m_iLogFolderNum = iSeqNum; char sLogFileName[256]; _snprintf( sLogFileName, sizeof(sLogFileName), "%s\\%s%04d.log", m_sLogPath.c_str(), m_sLogFolder.c_str(), m_iLogFolderNum ); char sLogParamsFileName[256]; _snprintf( sLogParamsFileName, sizeof(sLogParamsFileName), "%s\\%s%04d_params.log", m_sLogPath.c_str(), m_sLogFolder.c_str(), m_iLogFolderNum ); // Open Log Files m_fLogFile = fxopen(sLogFileName, "w"); m_fLogParamsFile = fxopen(sLogParamsFileName, "w"); if ( !m_fLogFile || !m_fLogParamsFile ) { GameWarning( "[VisualLog] Unable to open log files [%s] [%s]", sLogFileName, sLogParamsFileName ); CloseLogs(); return false; } WriteFileHeaders( sLogFileName, sLogParamsFileName ); return true; }