예제 #1
0
///////////////////////////////////////////////////////////////////////////////
/// \brief
/// Checks to see if the specified resource exists.
///
bool MgResourceDefinitionManager::ResourceExists(CREFSTRING wcResourcePathname)
{
    string mbResourcePathname;
    MgUtil::WideCharToMultiByte(wcResourcePathname, mbResourcePathname);

    return ResourceExists(mbResourcePathname);
}
예제 #2
0
Handle BetterGetResource(short resFile,ResType theType,short resID)
{
	short		saveFile=::CurResFile();
	Handle		theHandle;
	
	if (resFile!=-1)
		UseResFile(resFile);
		
	theHandle=Get1Resource(theType,resID);
	if (!theHandle)
	{
		gGetResErr=ResError();
		if (!gGetResErr)
		{
			if (ResourceExists(resFile,theType,resID))
				gGetResErr=memFullErr;
			else
				gGetResErr=resNotFound;
		}
	}
	else
		gGetResErr=noErr;
		
	UseResFile(saveFile);
	
	return theHandle;
}
예제 #3
0
파일: VideoLua.c 프로젝트: Raugharr/Herald
int LuaAnimationSetImage(lua_State* _State) {
	const char* _Name = luaL_checkstring(_State, 1);
	struct AnimationLoading* _Data = NULL;

	lua_pushvalue(_State, LUA_REGISTRYINDEX);
	lua_pushstring(_State, ANIM_LUASTR);
	lua_rawget(_State, -2);
	_Data = lua_touserdata(_State, -1);
	if(ResourceExists(_Name) == 0)
		return luaL_error(_State, "Resource %s cannot be found", _Name);
	_Data->ImageName = calloc(strlen(_Name) + 1, sizeof(char));
	strcpy((char*)_Data->ImageName, _Name);
	return 0;
}
예제 #4
0
// pass resFile as -1 to use the current file
OSErr BetterAddResource(short resFile,Handle theData,ResType type,short *id,StringPtr name,short mode)
{
	short		oldResFile=::CurResFile();
	OSErr		err=noErr;
	
	if (resFile!=-1)
		UseResFile(resFile);
	// If this resource exists then we may have some problems
	if (ResourceExists(-1,type,*id))
	{
		switch (mode)
		{
			case kOverwriteResource:
				if (!DeleteResource(-1,type,*id))
					err=rmvResFailed;
				break;
				
			case kUniqueID:
				*id=Unique1ID(type);
				break;
				
			case kBottleIt:
				err=userCanceledErr;
				break;
		}
	}
	
	if (!err)
	{
		// Now there is space for the resource lets add it
		AddResource(theData,type,*id,name ? name:"\p");
		err=ResError();
		if (err==noErr)
		{
			WriteResource(theData);
			err=ResError();
		}
	}