• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ AAsset_read函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中AAsset_read函数的典型用法代码示例。如果您正苦于以下问题:C++ AAsset_read函数的具体用法?C++ AAsset_read怎么用?C++ AAsset_read使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了AAsset_read函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: ReadFileAsset

	void ReadFileAsset(const tstring & path, star::SerializedData & data)
	{
		auto app = star::StarEngine::GetInstance()->GetAndroidApp();
		auto manager = app->activity->assetManager;
		AAsset* asset = AAssetManager_open(
				manager,
				star::string_cast<sstring>(path.c_str()).c_str(),
				AASSET_MODE_UNKNOWN
				);
		star::Logger::GetInstance()->Log(asset != NULL,
			_T("Couldn't find '") + path + _T("'."));
		data.size = AAsset_getLength(asset);
		data.data = new schar[sizeof(schar) * data.size];
		AAsset_read(asset, data.data, data.size);
		AAsset_close(asset);
	}
开发者ID:Syvion,项目名称:StarEngine,代码行数:16,代码来源:HelpersAndroid.cpp


示例2: writeLog

bool FileReader::read(unsigned int count, void*buffer)
{
	writeLog("%d %x %x", count, buffer, asset);
	if(asset != nullptr)
	{
		writeLog("not null or sumthin");
		if(AAsset_read(asset, buffer,count) >=0)
		{
			writeLog("everything went better than expedition");
			return true;
		}
	}

	writeLog("Null asset");
	return false;
}
开发者ID:NeoLeijona,项目名称:EVO,代码行数:16,代码来源:FileReader.cpp


示例3: DEBUGPRINT

size_t FileInput::read(unsigned char *buffer, size_t size)
{
	if(!m_asset || !buffer)
	{
		Console::Print(Console::Error, "Could not read from file.");
		return 0;
	}

	DEBUGPRINT("Reading %i bytes from asset %x", size, m_asset);

	int returnval = AAsset_read(m_asset, buffer, size);

	DEBUGPRINT("AAsset_read returned %i", returnval);

	return returnval;
}
开发者ID:robindegen,项目名称:android_game_engine,代码行数:16,代码来源:fileinput.cpp


示例4: vertexShaderStream

char* Renderer::LoadKernelFromAssets(const string * path)
{
#ifdef PLATFORM_WINDOWS
	string prefix = "kernelsPC/";
#else
	string prefix = "kernels/";
#endif
	string suffix = ".glsl";
	string fPath = prefix + *path + suffix;
#ifdef PLATFORM_WINDOWS

	fPath = Renderer::GetInstance()->ASSET_PATH + fPath;

	string sCode;
	ifstream vertexShaderStream(fPath.c_str(), ios::in);
	if (vertexShaderStream.is_open())
	{
		string Line = "";
		while (getline(vertexShaderStream, Line))
		{
			sCode += "\n" + Line;
		}
		vertexShaderStream.close();
	}

	int length = sCode.length();
	char* ret = new char[length + 1];
	strcpy(ret, sCode.c_str());
	ret[length] = '\0';

	return ret;

#else

	AAssetManager* mgr = System::GetInstance()->GetEngineData()->app->activity->assetManager;

	AAsset* shaderAsset = AAssetManager_open(mgr, fPath.c_str(), AASSET_MODE_UNKNOWN);
	unsigned int length = AAsset_getLength(shaderAsset);

	char * code = new char[length + 1];

	AAsset_read(shaderAsset, (void*)code, length);
	code[length] = '\0';
	return code;

#endif
}
开发者ID:ACPLMaverick,项目名称:MAVNET,代码行数:47,代码来源:Renderer.cpp


示例5: File_Read

WRes File_Read(CSzFile *p, void *data, size_t *size)
{
  size_t originalSize = *size;
  if (originalSize == 0)
    return 0;

  #ifdef USE_WINDOWS_FILE

  *size = 0;
  do
  {
    DWORD curSize = (originalSize > kChunkSizeMax) ? kChunkSizeMax : (DWORD)originalSize;
    DWORD processed = 0;
    BOOL res = ReadFile(p->handle, data, curSize, &processed, NULL);
    data = (void *)((Byte *)data + processed);
    originalSize -= processed;
    *size += processed;
    if (!res)
      return GetLastError();
    if (processed == 0)
      break;
  }
  while (originalSize > 0);
  return 0;

  #else
  if(p->mgr)
  {
	  msg_Dbg("file read");
#ifndef ANDROID22
	  if(p->asset)
		  *size = AAsset_read(p->asset,data,originalSize);
#endif
	  if (*size == originalSize)
		return 0;
	  return -1;
  }
  else
  {
	  *size = fread(data, 1, originalSize, p->file);
	  if (*size == originalSize)
		return 0;
	  return ferror(p->file);
  }

  #endif
}
开发者ID:Alford087,项目名称:NativeLibCompression,代码行数:47,代码来源:7zFile.c


示例6: jsModulesDir

bool JniJSModulesUnbundle::isUnbundle(
    AAssetManager *assetManager,
    const std::string& assetName) {
  if (!assetManager) {
    return false;
  }

  auto magicFileName = jsModulesDir(assetName) + MAGIC_FILE_NAME;
  auto asset = openAsset(assetManager, magicFileName.c_str());
  if (asset == nullptr) {
    return false;
  }

  magic_number_t fileHeader = 0;
  AAsset_read(asset.get(), &fileHeader, sizeof(fileHeader));
  return fileHeader == htole32(MAGIC_FILE_HEADER);
}
开发者ID:APSL,项目名称:react-native,代码行数:17,代码来源:JniJSModulesUnbundle.cpp


示例7: esFileRead

///
// esFileRead()
//
//    Wrapper for platform specific File read
//
static size_t esFileRead ( esFile *pFile, int bytesToRead, void *buffer )
{
   size_t bytesRead = 0;

   if ( pFile == NULL )
   {
      return bytesRead;
   }

#ifdef ANDROID
   bytesRead = AAsset_read ( pFile, buffer, bytesToRead );
#else
   bytesRead = fread ( buffer, bytesToRead, 1, pFile );
#endif

   return bytesRead;
}
开发者ID:OnTheEasiestWay,项目名称:OpenGL3,代码行数:22,代码来源:esUtil.c


示例8: LoadMesh

	/** 
	* Load a scene from a supported 3D file format
	*
	* @param filename Name of the file (or asset) to load
	* @param flags (Optional) Set of ASSIMP processing flags
	*
	* @return Returns true if the scene has been loaded
	*/
	bool LoadMesh(const std::string& filename, int flags = defaultFlags)
	{
#if defined(__ANDROID__)
		// Meshes are stored inside the apk on Android (compressed)
		// So they need to be loaded via the asset manager

		AAsset* asset = AAssetManager_open(assetManager, filename.c_str(), AASSET_MODE_STREAMING);
		assert(asset);
		size_t size = AAsset_getLength(asset);

		assert(size > 0);
		
		void *meshData = malloc(size);
		AAsset_read(asset, meshData, size);
		AAsset_close(asset);

		pScene = Importer.ReadFileFromMemory(meshData, size, flags);

		free(meshData);
#else
		pScene = Importer.ReadFile(filename.c_str(), flags);
#endif

		if (pScene)
		{
			m_Entries.clear();
			m_Entries.resize(pScene->mNumMeshes);
			// Read in all meshes in the scene
			for (auto i = 0; i < m_Entries.size(); i++)
			{
				m_Entries[i].vertexBase = numVertices;
				numVertices += pScene->mMeshes[i]->mNumVertices;
				const aiMesh* paiMesh = pScene->mMeshes[i];
				InitMesh(&m_Entries[i], paiMesh, pScene);
			}
			return true;
		}
		else 
		{
			printf("Error parsing '%s': '%s'\n", filename.c_str(), Importer.GetErrorString());
#if defined(__ANDROID__)
			LOGE("Error parsing '%s': '%s'", filename.c_str(), Importer.GetErrorString());
#endif
			return false;
		}
	}
开发者ID:dreadwords,项目名称:Vulkan,代码行数:54,代码来源:vulkanMeshLoader.hpp


示例9: loadCompressedTexture

bool loadCompressedTexture(GLenum target, int level, GLenum internalFormat, int width,
                           int height, const std::string& fileName)
{
#if defined(SUPPORT_ANDROID)
    AAsset* asset = AAssetManager_open(ctx.assetManager, fileName.c_str(), O_RDONLY);
    if (!asset)
    {
        LOGW("Unable to open asset %s", fileName.c_str());
        return false;
    }
    off_t size = AAsset_getLength(asset);
    void* pixels = malloc(size);
    AAsset_read(asset, pixels, size);
    AAsset_close(asset);
#else // !SUPPORT_ANDROID
    int fd = open(fileName.c_str(), O_RDONLY); 

    if (fd == -1)
    {
        perror("open");
        return false;
    }

    struct stat sb;
    if (fstat(fd, &sb) == -1)
    {
        perror("stat");
        return false;
    }
    off_t size = sb.st_size;
    void* pixels = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
#endif // !SUPPORT_ANDROID

    glCompressedTexImage2D(target, level, internalFormat, width, height, 0, size, pixels);

#if defined(SUPPORT_ANDROID)
    free(pixels);
#else
    munmap(pixels, sb.st_size);
    close(fd);
#endif

    ASSERT_GL();
    return true;
}
开发者ID:akallabeth,项目名称:glmemperf,代码行数:45,代码来源:util.cpp


示例10: androidExtract

bool androidExtract( const std::string& name ) {
	const char* pFile = name.c_str();
	std::string newPath = androidGetPath(pFile);
	AAssetDir* a;
	if ( androidExtracted(name.c_str()) ) {
		FLOG_DEBUG("File %s already extracted", name.c_str());
		return true;
	}

	AAsset* asset = AAssetManager_open(gActivity->assetManager, name.c_str(),
	                                   AASSET_MODE_STREAMING);
	std::string assetContent;

	if (asset != NULL) {
		// Find size
		off_t assetSize = AAsset_getLength(asset);

		// Prepare input buffer
		assetContent.resize(assetSize);

		// Store input buffer
		AAsset_read(asset, &assetContent[0], assetSize);

		// Close
		AAsset_close(asset);

		// Prepare output buffer
		std::ofstream assetExtracted(newPath.c_str(),
		                             std::ios::out | std::ios::binary);
		if (!assetExtracted) {
			FLOG_ERROR("File %s not extracted", newPath.c_str());
			return false;
		}

		// Write output buffer into a file
		assetExtracted.write(assetContent.c_str(), assetSize);
		assetExtracted.close();

		FLOG_DEBUG("File extracted");
		return true;
	} else {
		FLOG_ERROR("File %s not extracted. Returning empty string", name.c_str());
		return false;
	}
}
开发者ID:filipwasil,项目名称:fillwave,代码行数:45,代码来源:AndroidLoader.cpp


示例11: BEHAVIAC_LOGERROR

    bool CFileSystem::ReadFile(Handle file, void* pBuffer, uint32_t nNumberOfBytesToRead, uint32_t* pNumberOfBytesRead) {
        if (!file) {
            BEHAVIAC_LOGERROR("File not open");
            return 0;
        }

#if BEHAVIAC_CCDEFINE_ANDROID && (BEHAVIAC_CCDEFINE_ANDROID_VER > 8)
        size_t ret = AAsset_read((AAsset*)file, pBuffer, nNumberOfBytesToRead);
#else
        size_t ret = fread(pBuffer, 1, nNumberOfBytesToRead, (FILE*)file);
#endif

        if (pNumberOfBytesRead) {
            *pNumberOfBytesRead = ret;
        }

        return true;
    }
开发者ID:czfsvn,项目名称:LinuxC,代码行数:18,代码来源:filesystem_gcc.cpp


示例12: AAssetManager_open

GLubyte* FileReader::loadTGA(const std::string &fileName, tgaHeader &header)
{
	AAsset* asset = AAssetManager_open(FileReader::manager, fileName.c_str(), AASSET_MODE_UNKNOWN);
	if(asset == NULL)
	{
		writeLog("Asset = NULL");
	}
    AAsset_read(asset, &header.idLength, 1);
    AAsset_read(asset, &header.colorMapType, 1);
    AAsset_read(asset, &header.type, 1);
    AAsset_seek(asset, 9, SEEK_CUR);
    AAsset_read(asset, &header.width, 2);
    AAsset_read(asset, &header.height, 2);
    AAsset_read(asset, &header.depth, 1);
    AAsset_read(asset, &header.descriptor, 1);
    AAsset_seek(asset, header.idLength, SEEK_CUR);
    
	//writeLog("spritewidth: %d, height: %d, depth: %d", header.width, header.height, header.depth);

    //24bit / 8 = 3 (RGB), 32bit / 8 = 4 (RGBA)
    int componentCount = header.depth/8;
    
    int size = componentCount * header.width * header.height;
    GLubyte* data = new GLubyte[size];
    
    AAsset_read(asset, data, size);
    
    //data is now BGRA so we format it to RGBA
    for(int i = 0; i < size; i += componentCount)
    {
        GLubyte temp = data[i];
        
        //Switch red and blue
        data[i] = data[i+2];
        data[i+2] = temp;
    }
    
    AAsset_close(asset);

	return data;

}
开发者ID:NeoLeijona,项目名称:EVO,代码行数:42,代码来源:FileReader.cpp


示例13: fopen

char *
VSShaderLib::textFileRead(std::string fileName) {

	char *content = NULL;

#ifndef __ANDROID_API__
	FILE *fp;

	size_t count=0;

	if (fileName != "") {
		fp = fopen(fileName.c_str(),"rt");

		if (fp != NULL) {
      
			fseek(fp, 0, SEEK_END);
			count = ftell(fp);
			rewind(fp);

			if (count > 0) {
				content = (char *)malloc(sizeof(char) * (count+1));
				count = fread(content, sizeof(char), count, fp);
				content[count] = '\0';
			}
			fclose(fp);
		}
	}
	return content;
#else
	AAsset* asset = AAssetManager_open(s_AssetManager, fileName.c_str(), AASSET_MODE_UNKNOWN);
	const char *loc = "VSShaderLib::readText";
	if (NULL == asset) {
		__android_log_print(ANDROID_LOG_ERROR, loc, "%s", "_ASSET_NOT_FOUND_");
		return content;
	}
	size_t size = (size_t)AAsset_getLength(asset);
	content = (char*)malloc(sizeof(char)*size + 1);
	AAsset_read(asset, content, size);
	content[size] = '\0';
	__android_log_print(ANDROID_LOG_DEBUG, loc, "%s", content);
	AAsset_close(asset);
	return content;
#endif
}
开发者ID:lighthouse3d,项目名称:VSL,代码行数:44,代码来源:vsShaderLib.cpp


示例14: AAssetManager_open

FileUtils::FileData FileUtils::getFileData(const char* fileName)
{
	DebugLog::print( "FileUtils::getFileData(%s)", fileName );

	AAsset* asset = AAssetManager_open(g_aassetManager, (const char *) fileName, AASSET_MODE_UNKNOWN);
    if (NULL == asset) {
        DebugLog::print("Failed !");
        return FileData();
    }

    long size = AAsset_getLength(asset);
    FileData res = findFreeFileDataSlot(size);	
    res.size = size;
    
    AAsset_read (asset, res.bytes, size);
    AAsset_close(asset);	

    return res;
}
开发者ID:SylerWang,项目名称:FunFashion,代码行数:19,代码来源:FileUtilsAndroid.cpp


示例15: androidExtractAll

bool androidExtractAll() {
	AAssetDir* assetDir = AAssetManager_openDir(gActivity->assetManager, "");
	const char* filename = (const char*)NULL;
	std::string assetContent;
	while ((filename = AAssetDir_getNextFileName(assetDir)) != NULL) {
		std::string newPath = androidGetPath(filename);
		AAsset* asset = AAssetManager_open(gActivity->assetManager, filename,
		                                   AASSET_MODE_STREAMING);
		FLOG_DEBUG("File %s opened for extraction ...", filename );
		// Find size
		off_t assetSize = AAsset_getLength(asset);

		// Prepare input buffer
		assetContent.resize(assetSize);

		// Store input buffer
		AAsset_read(asset, &assetContent[0], assetSize);

		// Close
		AAsset_close(asset);

		// Check if file exists
		std::ifstream f(newPath.c_str());
		if (f.good()) {
			f.close();
			FLOG_DEBUG("Asset %s already extracted", filename);
		} else {
			// Prepare output buffer
			std::ofstream assetExtracted(newPath.c_str(),
			                             std::ios::out | std::ios::binary);
			if (!assetExtracted) {
				FLOG_ERROR("File %s not extracted", newPath.c_str());
				return false;
			}

			// Write output buffer into a file
			assetExtracted.write(assetContent.c_str(), assetSize);
			assetExtracted.close();

			FLOG_DEBUG("File %s extracted", filename);
		}
	}
	return true;
	AAssetDir_close(assetDir);
}
开发者ID:filipwasil,项目名称:fillwave,代码行数:45,代码来源:AndroidLoader.cpp


示例16: androidReadToString

void androidReadToString(const char* pFileName, std::string& fileContent) {
	assert( gActivity->assetManager );

	AAsset* pFile = AAssetManager_open(gActivity->assetManager, pFileName,
	                                   AASSET_MODE_UNKNOWN);

	if (pFile != NULL) {
		off_t fileSize = AAsset_getLength(pFile);

		fileContent.resize(fileSize);
		char* pData = new char[fileSize];
		AAsset_read(pFile, &fileContent[0], fileSize);

		AAsset_close(pFile);
		FLOG_DEBUG("File %s found", pFileName);
	} else {
		FLOG_ERROR("File %s not found", pFileName);
	}
}
开发者ID:filipwasil,项目名称:fillwave,代码行数:19,代码来源:AndroidLoader.cpp


示例17: j_moc_init

/*
 * For native implementation for java methods, if it's static method
 * belongs to class itself, then second parameter should be jclass(it
 * refers to MocClient here), otherwise, it should be jobject because
 * it's just instance of specified class.
 */
static jboolean
j_moc_init(JNIEnv *env, jobject obj,
        jobject assetManager, jstring fileStr)
{
    char *fileChars = NULL;
    if (fileStr) {
        fileChars = (char*) (*env)->GetStringUTFChars(env, fileStr, NULL);
        LOGI("moc client would to be initialized by file %s.", fileChars);
    } else {
        fileChars = "conf/mocclient.hdf";
        LOGI("moc client would to be initialized by default configurations.");
    }

    AAssetManager *manager = AAssetManager_fromJava(env, assetManager);
    assert(manager != NULL);

    AAsset *file = AAssetManager_open(manager, "conf/mocclient.hdf", AASSET_MODE_UNKNOWN);
    if (file == NULL) {
        LOGE("sepecified file does not exists in apk.");
    }

    /* read contents from config file */
    off_t bufferSize = AAsset_getLength(file);
    char *buffer     = (char*) malloc(bufferSize + 1);
    buffer[bufferSize] = 0;

    AAsset_read(file, buffer, bufferSize);

    /* close file */
    AAsset_close(file);

     moc_init_frombuf(buffer);

    /*
     * initial module calback hash table
     * but it only supports bang module currently
     */
    hash_init(&registed_callback_module_table, hash_str_hash, hash_str_comp, NULL);
    hash_insert(registed_callback_module_table, (void*) "bang", (void*) j_moc_regist_callback_bang);

    return true;
}
开发者ID:bigclean,项目名称:moc,代码行数:48,代码来源:j_moc.c


示例18: AAsset_read

int FileAccessAndroid::get_buffer(uint8_t *p_dst, int p_length) const {


	off_t r = AAsset_read(a,p_dst,p_length);

	if (pos+p_length >len ) {
		eof=true;
	}

	if (r>=0) {

		pos+=r;
		if (pos>len) {
			pos=len;
		}

	}
	return r;

}
开发者ID:Blake-Hudson,项目名称:godot,代码行数:20,代码来源:file_access_android.cpp


示例19: AAssetManager_open

std::string gg::Util::loadFile(const std::string &fileName)
{
	//TODO: check for invalid filenames
	AAsset* asset = AAssetManager_open(gg::AssetManager::manager, fileName.c_str(), AASSET_MODE_UNKNOWN);
	off_t length = AAsset_getLength(asset);

	char* text = new char[length+1];
	if(AAsset_read(asset, text, length) < 1)
	{
		writeLog("File not loaded! Error! Error!");
	}

	text[length] = 0;

	AAsset_close(asset);
	text[length] = 0;
	std::string r(text);

	return r;
}
开发者ID:Hangyakusha,项目名称:TeamNoHope,代码行数:20,代码来源:utilAndroid.cpp


示例20: LoadFileFunc

static void* LoadFileFunc(const char* pFilename, char** pData, size_t &size)
{
	size = 0;
	AAsset* pAsset = AAssetManager_open(g_AssetManager, pFilename, AASSET_MODE_BUFFER);

	if(pAsset)
	{
		off_t length = AAsset_getLength(pAsset);

		if(length)
		{
			SHandle *pHandle = new SHandle();

			if(pHandle)
			{
				pHandle->size = length;
				pHandle->pData = new char[length];

				if(pHandle->pData)
				{
					if(length == AAsset_read(pAsset, pHandle->pData, length))
					{
						AAsset_close(pAsset);

						size = length;
						*pData = pHandle->pData;
						return pHandle;
					}

					delete[] pHandle->pData;
				}

				delete pHandle;
			}
		}

		AAsset_close(pAsset);
	}

	return 0;
}
开发者ID:joyfish,项目名称:GameThirdPartyLibs,代码行数:41,代码来源:PVRShellOS.cpp



注:本文中的AAsset_read函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ AB函数代码示例发布时间:2022-05-30
下一篇:
C++ AAsset_getLength函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap