package projectzombie.util;

import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.zip.GZIPInputStream;

import bdf.types.BdfReader;
import projectzombie.settings.Environment;

public class FileHelpers
{
	public static BdfReader readBDF(String path)
	{
		try
		{
			InputStream in = new GZIPInputStream(new FileInputStream(Environment.gdir + path));
			ByteArrayOutputStream out = new ByteArrayOutputStream();
			
			byte buffer[] = new byte[1024];
			int size;
			
			while((size = in.read(buffer)) != -1) {
				out.write(buffer, 0, size);
			}
			
			in.close();
			
			return new BdfReader(out.toByteArray());
		}
		
		catch(IOException e) {
			return new BdfReader();
		}
	}
}
