예제 #1
0
CORE::CString
GetUniqueFileName( const CORE::CString& filename )
{GUCEF_TRACE;

    CORE::CString fileExt = CORE::ExtractFileExtention( filename );
    CORE::CString fileWithoutExt;

    if ( fileExt.IsNULLOrEmpty() )
    {
        fileWithoutExt = filename;
    }
    else
    {
        fileWithoutExt = filename.CutChars( fileExt.Length()+1, false );
    }

    CORE::UInt32 i = 2;
    CORE::CString filenameToTest = filename;
    while ( CORE::FileExists( filenameToTest ) )
    {
        filenameToTest = fileWithoutExt + '(' + CORE::UInt32ToString( i ) + ")." + fileExt;
        ++i;
    }

    return filenameToTest;
}
bool
CLogSvcClient::OnTaskCycleLog( const TLogMsgType logMsgType    ,
                               const CORE::Int32 logLevel      ,
                               const CORE::CString& logMessage ,
                               const CORE::UInt32 threadId     )
{GUCEF_TRACE;

    CORE::Int16 logMsgTypeValue = logMsgType;
    CORE::Int8 msgHeader[ 16 ];  // 16 = 1+4+1+2+4+4
    CORE::UInt32 logMsgLength = logMessage.Length() + 11;

    msgHeader[ 0 ] = (CORE::Int8) LOGSVCMSGTYPE_DELIMITER;   // set delimiter for message: 1 byte
    memcpy( msgHeader+1, &logMsgLength, 4 );                 // set the total message length : 4 bytes
    msgHeader[ 5 ] = (CORE::Int8) LOGSVCMSGTYPE_LOGMSG;      // set TCP msg type: 1 byte
    memcpy( msgHeader+6, &logMsgTypeValue, 2 );              // set log msg type: 2 bytes
    memcpy( msgHeader+8, &logLevel, 4 );                     // set log level: 4 bytes
    memcpy( msgHeader+12, &threadId, 4 );                    // set thread id: 4 bytes

    if ( m_connectionInitialized )
    {
        // Send the logging msg header
        if ( m_tcpClient.Send( msgHeader, 16 ) )
        {
            // Now send the logging text
            m_tcpClient.Send( logMessage.C_String() ,
                              logMessage.Length()   );
        }
    }
    else
    {
        // The logging connection is not initialized yet
        // queue the msg until the connection is initialized

        TLogMessage queueItem;
        memcpy( queueItem.msgHeader, msgHeader, 16 );
        queueItem.logMsg = logMessage;

        m_logQueue.push_back( queueItem );
    }
    return true;
}