const char* getDataPath() { if (strlen(s_AppDataPath)) { return s_AppDataPath; } do { TUChar AppID[EOS_FILE_MAX_PATH] = {0}; UInt32 nCmdType = 0; Int32 nRet = SS_AppRequest_GetAppName(AppID, &nCmdType); BREAK_IF(nRet < 0); TUChar AppPath[EOS_FILE_MAX_PATH] = {0}; char DataPath[EOS_FILE_MAX_PATH] = {0}; SS_GetApplicationPath(AppID, SS_APP_PATH_TYPE_CONST, AppPath); TUString::StrUnicodeToStrUtf8((Char*) DataPath, AppPath); #ifndef _TRANZDA_VM_ char *pszDriver = ""; #else char *pszDriver = "D:/Work7"; #endif // record the data path strcpy(s_AppDataPath, pszDriver); strcat(s_AppDataPath, DataPath); } while (0); return s_AppDataPath; }
CCXApplication::CCXApplication() : m_bRunning(FALSE) , m_bNeedStop(FALSE) , m_bInBackground(FALSE) { memset(&m_tMsg, 0, sizeof(m_tMsg)); SS_GetCurrentGTID(&m_tMsg.gtid); m_tMsg.type = CCX_ON_APPLICATION_IDLE; Sys_RegisterMessageCallBack(CCX_ON_APPLICATION_IDLE, CCXApplication::_OnAppIdle, (UInt32)this); memset(m_AppDataPath, 0, sizeof(char) * EOS_FILE_MAX_PATH); do { TUChar AppID[EOS_FILE_MAX_PATH] = {0}; UInt32 nCmdType = 0; Int32 nRet = SS_AppRequest_GetAppName(AppID, &nCmdType); CCX_BREAK_IF(nRet < 0); TUChar AppPath[EOS_FILE_MAX_PATH] = {0}; SS_GetApplicationPath(AppID, SS_APP_PATH_TYPE_EXECUTABLE, AppPath); TUString::StrUnicodeToStrUtf8((Char*) m_AppDataPath, AppPath); } while (0); }
void CCLog(const char * pszFormat, ...) { if (! s_szLogFilePath[0]) { // save the log file named "Cocos2dxLog.txt" to the directory which the app.so in. TUChar AppID[EOS_FILE_MAX_PATH] = {0}; UInt32 nCmdType = 0; Int32 nRet = SS_AppRequest_GetAppName(AppID, &nCmdType); if (nRet < 0) { return; } TUChar AppPath[EOS_FILE_MAX_PATH] = {0}; if (SS_GetApplicationPath(AppID, SS_APP_PATH_TYPE_EXECUTABLE, AppPath) < 0) { return; } char szAppPath[EOS_FILE_MAX_PATH] = {0}; TUString::StrUnicodeToStrUtf8((Char*) szAppPath, AppPath); #ifndef _TRANZDA_VM_ strcpy(s_szLogFilePath, ""); #else strcpy(s_szLogFilePath, "D:/Work7"); #endif strcat(s_szLogFilePath, szAppPath); strcat(s_szLogFilePath, "Cocos2dxLog.txt"); } char szBuf[MAX_LEN]; va_list ap; va_start(ap, pszFormat); #ifdef _TRANZDA_VM_ vsprintf_s(szBuf, MAX_LEN, pszFormat, ap); #else vsnprintf(szBuf, MAX_LEN, pszFormat, ap); #endif va_end(ap); #ifdef _TRANZDA_VM_ WCHAR wszBuf[MAX_LEN] = {0}; MultiByteToWideChar(CP_UTF8, 0, szBuf, -1, wszBuf, sizeof(wszBuf)); OutputDebugStringW(wszBuf); OutputDebugStringA("\n"); #else FILE * pf = fopen(s_szLogFilePath, "a+"); if (! pf) { return; } fwrite(szBuf, 1, strlen(szBuf), pf); fwrite("\r\n", 1, strlen("\r\n"), pf); fflush(pf); fclose(pf); #endif }