package speiger.src.coreengine.assets.base;

import java.io.Closeable;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.FileTime;
import java.util.List;
import java.util.function.BiConsumer;

import speiger.src.coreengine.assets.AssetLocation;
import speiger.src.coreengine.assets.oldImpl.FolderAssetPackage;
import speiger.src.coreengine.assets.oldImpl.ZipAssetPackage;
import speiger.src.coreengine.utils.helpers.IOUtils;

public interface IAssetPackage extends Closeable
{
	@Override
	public void close();
	public void getModifiedTime(String domain, BiConsumer<AssetLocation, FileTime> accept);
	public List<String> getDomains();
	public IAsset getAsset(AssetLocation location);
	public void gatherAssets(AssetLocation folder, BiConsumer<AssetLocation, IAsset> accept);
	
	public static IAssetPackage of(Path path) {
		if(Files.exists(path)) {
			if(Files.isDirectory(path)) return new FolderAssetPackage(path);
			if(IOUtils.isZip(path)) return new ZipAssetPackage(path);
		}
		return null;
	}
}
