You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
851 B
50 lines
851 B
package net.tortuga.util.loading;
|
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
import org.newdawn.slick.util.ResourceLoader;
|
|
|
|
|
|
/**
|
|
* Directory access in resources
|
|
*
|
|
* @author Ondřej Hruška (MightyPork)
|
|
*/
|
|
public class ResourceDirectoryLoader implements DirectoryLoader {
|
|
|
|
private String path;
|
|
|
|
|
|
/**
|
|
* Create resource directory access
|
|
*
|
|
* @param path the path
|
|
*/
|
|
public ResourceDirectoryLoader(String path) {
|
|
this.path = path;
|
|
if (path.endsWith("/")) this.path = path.substring(0, path.length() - 1);
|
|
}
|
|
|
|
|
|
@Override
|
|
public boolean fileExists(String filename)
|
|
{
|
|
return ResourceLoader.resourceExists(path + "/" + filename);
|
|
}
|
|
|
|
|
|
@Override
|
|
public InputStream openFile(String filename)
|
|
{
|
|
return ResourceLoader.getResourceAsStream(path + "/" + filename);
|
|
}
|
|
|
|
|
|
@Override
|
|
public String toString()
|
|
{
|
|
return "Res('" + path + "')";
|
|
}
|
|
|
|
}
|
|
|