void FileUtils::setResource(const char* pszZipFileName) { // get the full path of zip file char fullPath[EOS_FILE_MAX_PATH] = {0}; if (strlen(s_ResourcePath)) { strcpy(fullPath, s_ResourcePath); } else { const char* pAppDataPath = getDataPath(); strcpy(fullPath, pAppDataPath); } strcat(fullPath, pszZipFileName); // if the zip file not exist,use message box to warn developer TUChar pszTmp[EOS_FILE_MAX_PATH] = {0}; TUString::StrGBToUnicode(pszTmp, (const Char*) fullPath); Boolean bExist = EOS_IsFileExist(pszTmp); if (!bExist) { std::string strErr = "zip file "; strErr += fullPath; strErr += " not exist!"; TUChar szText[EOS_FILE_MAX_PATH] = { 0 }; TUString::StrUtf8ToStrUnicode(szText,(Char*)strErr.c_str()); TApplication::GetCurrentApplication()->MessageBox(szText,NULL,WMB_OK); return; } // clear the zip file path recorded before and record the new path memset(s_ZipFilePath, 0, sizeof(char) * EOS_FILE_MAX_PATH); strcpy(s_ZipFilePath, fullPath); }
Boolean SoundPlayer::OpenAudioFile(const char* pszFilePath) { Boolean bRet = FALSE; do { BREAK_IF(!m_pMediaFile); TUString::StrGBToUnicode(m_fileName, (const Char*)pszFilePath); BREAK_IF(!EOS_IsFileExist(m_fileName)); m_pMediaFile->SetName(m_fileName); BREAK_IF(! m_pPlayer || ! m_pPlayer->Open()); bRet = TRUE; } while (0); return bRet; }
bool FileUtils::isFileExisted(const char* pFilePath) { bool bRet = false; if (strlen(s_ZipFilePath) != 0) { // if have set the zip file path,find the resource in the zip file unzFile pZipFile = unzOpen(s_ZipFilePath); do { BREAK_IF(!pZipFile); Int32 nPos = unzLocateFile(pZipFile, pFilePath, 1); BREAK_IF(nPos != UNZ_OK); bRet = true; unzClose(pZipFile); } while (0); } else { char fullPath[EOS_FILE_MAX_PATH]; fullPathFromRelativePath(pFilePath, fullPath); if (strlen(fullPath) > 0) { TUChar FilePath[EOS_FILE_MAX_PATH] = {0}; TUString::StrGBToUnicode(FilePath, (const Char *) fullPath); // find in the hardware if (EOS_IsFileExist(FilePath)) { bRet = true; } } } return bRet; }