This commit is contained in:
hyzboy 2020-01-13 11:55:03 +08:00
parent 641256a8db
commit b622b98f79
3 changed files with 18 additions and 23 deletions

View File

@ -50,8 +50,6 @@ namespace hgl
*/
class AssetsSource
{
protected:
UTF8String uri_short_name;
public:
@ -74,12 +72,9 @@ namespace hgl
virtual AssetsSource * CreateSubSource (const UTF8String &){return nullptr;}
};//class AssetsSource
AssetsSource *CreateByFilesystem(const UTF8String &sn,const OSString &pathname,const bool only_read);
AssetsSource *CreateSourceByFilesystem(const UTF8String &sn,const OSString &pathname,const bool only_read);
bool RegistryAssetsSource(const UTF8String &uri_short_name,AssetsSource *);
void UnregistryAssetsSource(const UTF8String &uri_short_name);
AssetsSource *GetAssetsSource(const UTF8String &uri_short_name);
AssetsSource *GetSource(const UTF8String &uri_short_name);
io::InputStream *GetAssets(const UTF8String &uri);
}//namespace assets

View File

@ -10,17 +10,6 @@ namespace hgl
Map<UTF8String,AssetsSource *> assets_source_map;
}//namespace
AssetsSource::AssetsSource(const UTF8String &sn)
{
uri_short_name=sn;
RegistryAssetsSource(sn,this);
}
AssetsSource::~AssetsSource()
{
UnregistryAssetsSource(uri_short_name);
}
bool RegistryAssetsSource(const UTF8String &uri_short_name,AssetsSource *as)
{
if(!as)
@ -44,7 +33,7 @@ namespace hgl
assets_source_map.DeleteByKey(uri_short_name);
}
AssetsSource *GetAssetsSource(const UTF8String &uri_short_name)
AssetsSource *GetSource(const UTF8String &uri_short_name)
{
if(uri_short_name.IsEmpty())
return(nullptr);
@ -68,7 +57,7 @@ namespace hgl
const UTF8String sn=uri.SubString(0,pos);
AssetsSource *source=GetAssetsSource(sn);
AssetsSource *source=GetSource(uri);
if(!source)
return(nullptr);
@ -77,5 +66,16 @@ namespace hgl
return source->OpenByName(surl);
}
AssetsSource::AssetsSource(const UTF8String &sn)
{
uri_short_name=sn;
RegistryAssetsSource(sn,this);
}
AssetsSource::~AssetsSource()
{
UnregistryAssetsSource(uri_short_name);
}
}//namespace assets
}//namespace hgl

View File

@ -39,7 +39,7 @@ namespace hgl
}
};//class AssetsSourceFilesytem:public AssetsSource
AssetsSource *CreateByFilesystem(const OSString &path,const bool only_read)
AssetsSource *CreateSourceByFilesystem(const OSString &path,const bool only_read)
{
if(path.IsEmpty())
return(nullptr);