添加资产管理,暂时只有加载文件到内存

This commit is contained in:
HuYingzhuo 2019-04-28 16:03:27 +08:00
parent 4ca69c06f5
commit 214f1b8abc
2 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,24 @@
#include<fstream>
#ifndef WIN32
#include<unistd.h>
#endif//
char *LoadFileToMemory(const char *filename,unsigned __int32 &file_length)
{
std::ifstream fs;
fs.open(filename,std::ios_base::binary);
if(!fs.is_open())
return(nullptr);
fs.seekg(0,std::ios_base::end);
file_length=fs.tellg();
char *data=new char[file_length];
fs.seekg(0,std::ios_base::beg);
fs.read(data,file_length);
fs.close();
return data;
}

View File

@ -0,0 +1,6 @@
#ifndef HGL_ASSETS_MANAGE_INCLUDE
#define HGL_ASSETS_MANAGE_INCLUDE
char *LoadFileToMemory(const char *filename,unsigned __int32 &file_length);
#endif//HGL_ASSETS_MANAGE_INCLUDE