package projectzombie.resources;

import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;

import gl_engine.ResourceLoader;

public class Resource
{
	String path;
	byte[] data;
	
	private String filePath(String path) {
		return "/resources/"+path;
	}
	
	public String getPath() {
		return filePath(path);
	}
	
	public Resource(String path)
	{
		// Set the specified data
		this.path = path;
	}
	
	public void load() {
		data = ResourceLoader.loadResource("/resources" + path);
	}
	
	public byte[] getBytes() {
		return data;
	}
	
	public String getString() {
		return new String(data, StandardCharsets.UTF_8);
	}
	
	public ByteBuffer getByteBuffer()
	{
		ByteBuffer buffer = ByteBuffer.allocateDirect(data.length);
		
		for(int i=0;i<data.length;i++) {
			buffer.put(i, data[i]);
		}
		
		return buffer;
	}
}
