bool ResourceCompilerImpl::compile(const char* fileName, std::map<std::string, std::string>& options) {
		std::cout << "Compiling " << fileName << std::endl;

		engine::Hashed id(fileName);

		if(resourcesCompiled.count(id) > 0) {
			std::cout << fileName << " already compiled" << std::endl;
			return true;
		}

		ResourceLoader* loader = findLoader(engine::file::getExtension(fileName).c_str());

		resourcesCompiled.insert(id);
		loader->compileResource(fileName, options);

		std::cout << "Compiled " << fileName << std::endl;
		return true;
	}
Beispiel #2
0
bool ResourceManager::validateResource( const Path& path )
{
	if( path.empty() ) return false;
	
	const Path& extension = PathGetFileExtension(path);
	
	if( extension.empty() )
	{
		LogWarn( "Resource '%s' has an invalid extension", path.c_str() );
		return false;
	}

	if( !findLoader(extension) )
	{
		LogWarn("No resource loader found for resource '%s'", path.c_str());
		return false;
	}

	return true;
}
Beispiel #3
0
Resource* ResourceManager::prepareResource( ResourceLoadOptions& options )
{
	const Path& path = options.name;

	Stream* stream = archive->openFile(path, GetResourcesAllocator());
	
	if( !stream )
	{
		LogWarn("Resource was not found: '%s'", path.c_str());
		return nullptr;
	}

	const Path& file = PathGetFile(path);

	// Get the available resource loader and prepare the resource.
	ResourceLoader* loader = findLoader( PathGetFileExtension(file) );

	if( !loader )
	{
		LogWarn("No resource loader found for resource '%s'", file.c_str());
		return nullptr;
	}

	options.stream = stream;

	Resource* resource = loader->prepare(options);
	
	if( !resource )
	{
		LogError("Error preparing resource: '%s'", path.c_str());
		return nullptr;
	}

	resource->setStatus( ResourceStatus::Loading );
	resource->setPath( file );

	options.resource = resource;

	return resource;
}
 //! Returns true if there is a ResourceLoadWriter registered to load the specified file
 bool canLoad(VirtualFile* file)   const { return findLoader(file->path()) != NULL; }
 //! Returns true if there is a ResourceLoadWriter registered to load the specified path or extension
 bool canLoad(const String& path)  const { return findLoader(path) != NULL; }