Example #1
0
//-------------------------------------------------------------------------------------
std::string Resmgr::getPyUserResPath()
{
	static std::string respath = "";

	if(respath == "")
	{
		respath = matchRes("server/kbengine.xml");
		std::vector<std::string> tmpvec;
		tmpvec = KBEngine::strutil::kbe_splits(respath, "server/kbengine.xml");

		if(tmpvec.size() > 1)
		{
			respath = tmpvec[0];
		}
		else
		{
			if(respaths_.size() > 1)
				respath = respaths_[1];
			else if(respaths_.size() > 0)
				respath = respaths_[0];
		}
	}

	return respath;
}
Example #2
0
//-------------------------------------------------------------------------------------
std::string Resmgr::getPyUserScriptsPath()
{
	static std::string path = "";

	if(path == "")
	{
		std::string entitiesxml = "entities.xml";
		path = matchRes(entitiesxml);

		if(path == entitiesxml)
		{
			entitiesxml = "scripts/" + entitiesxml;
			path = matchRes(entitiesxml);
			entitiesxml = "entities.xml";
		}


		std::vector<std::string> tmpvec;
		tmpvec = KBEngine::strutil::kbe_splits(path, entitiesxml);
		if(tmpvec.size() > 1)
		{
			path = tmpvec[0];
		}
		else
		{
			if(respaths_.size() > 2)
				path = respaths_[2];
			else if(respaths_.size() > 1)
				path = respaths_[1];
			else if(respaths_.size() > 0)
				path = respaths_[0];
		}
	}

	return path;
}
Example #3
0
//-------------------------------------------------------------------------------------
ResourceObjectPtr Resmgr::openResource(const char* res, const char* model, uint32 flags)
{
    std::string respath = matchRes(res);

    if(Resmgr::respool_checktick == 0)
    {
        return new FileObject(respath.c_str(), flags, model);
    }

    KBEngine::thread::ThreadGuard tg(&mutex_);
    KBEUnordered_map< std::string, ResourceObjectPtr >::iterator iter = respool_.find(respath);
    if(iter == respool_.end())
    {
        FileObject* fobj = new FileObject(respath.c_str(), flags, model);
        respool_[respath] = fobj;
        fobj->update();
        return fobj;
    }

    iter->second->update();
    return iter->second;
}
Example #4
0
//-------------------------------------------------------------------------------------
std::string Resmgr::matchRes(std::string res)
{
    return matchRes(res.c_str());
}
Example #5
0
//-------------------------------------------------------------------------------------
std::string Resmgr::matchRes(const std::string& res)
{
	return matchRes(res.c_str());
}
Example #6
0
//-------------------------------------------------------------------------------------
FILE* Resmgr::openResource(const char* res, const char* model)
{
    return fopen(matchRes(res).c_str(), model);
}