Ejemplo n.º 1
0
AKRESULT CFileIOHandler_wwise::Open(AkFileID nFileID, AkOpenMode eOpenMode, AkFileSystemFlags* pFlags, bool& rSyncOpen, AkFileDesc& rFileDesc)
{
	AKRESULT eResult = AK_Fail;

	if (pFlags != nullptr && (rSyncOpen || !m_bAsyncOpen))
	{
		rSyncOpen = true;
		AkOSChar sFinalFilePath[AK_MAX_PATH] = {'\0'};
		AKPLATFORM::SafeStrCat(sFinalFilePath, m_sBankPath, AK_MAX_PATH);

		if (eOpenMode == AK_OpenModeRead)
		{
			// Add language folder if the file is localized.
			if (pFlags->uCompanyID == AKCOMPANYID_AUDIOKINETIC && pFlags->bIsLanguageSpecific)
			{
				AKPLATFORM::SafeStrCat(sFinalFilePath, m_sLanguageFolder, AK_MAX_PATH);
			}
		}

		AkOSChar sFileName[MAX_FILETITLE_SIZE] = {'\0'};

		AkOSChar const* const sFilenameFormat = pFlags->uCodecID == AKCODECID_BANK ? ID_TO_STRING_FORMAT_BANK : ID_TO_STRING_FORMAT_WEM;

		AK_OSPRINTF(sFileName, MAX_FILETITLE_SIZE, sFilenameFormat, static_cast<int unsigned>(nFileID));

		AKPLATFORM::SafeStrCat(sFinalFilePath, sFileName, AK_MAX_PATH);

		char* sTemp = nullptr;
		CONVERT_OSCHAR_TO_CHAR(sFinalFilePath, sTemp);

		size_t const nFileSize = gEnv->pCryPak->FGetSize(sTemp);

		if (nFileSize > 0)
		{
			FILE* const pFile = gEnv->pCryPak->FOpen(sTemp, "rbx", ICryPak::FOPEN_HINT_DIRECT_OPERATION);

			if (pFile != nullptr)
			{
				rFileDesc.iFileSize					= static_cast<AkInt64>(nFileSize);
				rFileDesc.hFile							= GetFileHandle(pFile);
				rFileDesc.uSector						= 0;
				rFileDesc.deviceID					= m_nDeviceID;
				rFileDesc.pCustomParam			= nullptr;
				rFileDesc.uCustomParamSize	= 0;

				eResult = AK_Success;
			}
		}
	}

	return eResult;
}
void SceneBase::SetLoadFileErrorMessage(const char* fileName)
{
    char errorMessage[INTEGRATIONDEMO_MAX_MESSAGE];
#if defined (AK_IOS) || defined (AK_MAC_OS_X)
    char* soundBankPath = SOUND_BANK_PATH;
    sprintf(errorMessage, "Failed to load file \"%s\" under Soundbank path: \n\n%s", fileName, soundBankPath);
#else
    char* soundBankPath = NULL;
    CONVERT_OSCHAR_TO_CHAR(SOUND_BANK_PATH, soundBankPath);
    sprintf(errorMessage, "Failed to load file \"%s\" under Soundbank path: \n\n%s", fileName, soundBankPath);
#endif //#if defined (AK_IOS) || defined (AK_MAC_OS_X)
    SetErrorMessage(errorMessage);
}
AkUInt64 CAkFilePackageLUT::GetExternalID(
  const AkOSChar			*in_pszExternalName		// External Source name.
) {
  char *szString;
  CONVERT_OSCHAR_TO_CHAR(in_pszExternalName, szString);

  size_t stringSize = strlen( szString );

  // 1- Make lower case.
  _MakeLowerA( szString, stringSize );

  AK::FNVHash64 MainHash;
  return MainHash.Compute( (const unsigned char *) szString, (unsigned int)stringSize );
}
Ejemplo n.º 4
0
AKRESULT CFileIOHandler_wwise::Open(AkOSChar const* sFileName, AkOpenMode eOpenMode, AkFileSystemFlags* pFlags, bool& rSyncOpen, AkFileDesc& rFileDesc)
{
	AKRESULT eResult = AK_Fail;

	if (rSyncOpen || !m_bAsyncOpen)
	{
		rSyncOpen = true;
		AkOSChar sFinalFilePath[AK_MAX_PATH] = {'\0'};
		AKPLATFORM::SafeStrCat(sFinalFilePath, m_sBankPath, AK_MAX_PATH);

		if (pFlags != nullptr && eOpenMode == AK_OpenModeRead)
		{
			// Add language folder if the file is localized.
			if (pFlags->uCompanyID == AKCOMPANYID_AUDIOKINETIC && pFlags->uCodecID == AKCODECID_BANK && pFlags->bIsLanguageSpecific)
			{
				AKPLATFORM::SafeStrCat(sFinalFilePath, m_sLanguageFolder, AK_MAX_PATH);
			}
		}

		AKPLATFORM::SafeStrCat(sFinalFilePath, sFileName, AK_MAX_PATH);

		char* sTemp = nullptr;
		CONVERT_OSCHAR_TO_CHAR(sFinalFilePath, sTemp);
		char const* sOpenMode = nullptr;

		switch (eOpenMode)
		{
		case AK_OpenModeRead:
			{
				sOpenMode = "rbx";

				break;
			}
		case AK_OpenModeWrite:
			{
				sOpenMode = "wbx";

				break;
			}
		case AK_OpenModeWriteOvrwr:
			{
				sOpenMode = "w+bx";

				break;
			}
		case AK_OpenModeReadWrite:
			{
				sOpenMode = "abx";

				break;
			}
		default:
			{
				AKASSERT(!"Unknown file open mode!");

				break;
			}
		}

		FILE* const pFile = gEnv->pCryPak->FOpen(sTemp, sOpenMode, ICryPak::FOPEN_HINT_DIRECT_OPERATION);

		if (pFile != nullptr)
		{
			rFileDesc.iFileSize					= static_cast<AkInt64>(gEnv->pCryPak->FGetSize(sTemp));
			rFileDesc.hFile							= GetFileHandle(pFile);
			rFileDesc.uSector						= 0;
			rFileDesc.deviceID					= m_nDeviceID;
			rFileDesc.pCustomParam			= nullptr;
			rFileDesc.uCustomParamSize	= 0;

			eResult = AK_Success;
		}
	}

	return eResult;
}