package speiger.src.coreengine.assets.impl.parsers;

import java.io.BufferedReader;
import java.io.IOException;
import java.nio.channels.SeekableByteChannel;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;

import speiger.src.coreengine.assets.api.IAssetParser;

public class Closables {
	public static final IAssetParser<BufferedReader> READER = new Reader();
	public static final IAssetParser<SeekableByteChannel> BYTE_CHANNEL = new ByteChannel();
	
	public static class Reader implements IAssetParser<BufferedReader> {
		@Override
		public BufferedReader parse(Path path) throws IOException {
			return Files.newBufferedReader(path);
		}
	}
	
	public static class ByteChannel implements IAssetParser<SeekableByteChannel> {
		@Override
		public SeekableByteChannel parse(Path path) throws IOException {
			return Files.newByteChannel(path, StandardOpenOption.READ);
		}
	}
}
