import com.jme3.asset.*;
import com.jme3.system.JmeSystem;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
+import java.util.logging.Level;
import java.util.logging.Logger;
/**
if (url == null)
return null;
+ if (url.getProtocol().equals("file")){
+ try {
+ String path = new File(url.toURI()).getCanonicalPath();
+
+ // convert to / for windows
+ if (File.separatorChar == '\\'){
+ path = path.replace('\\', '/');
+ }
+
+ // compare path
+ if (!path.endsWith(name)){
+ throw new AssetNotFoundException("Asset name doesn't match requirements.\n"+
+ "\"" + path + "\" doesn't match \"" + name + "\"");
+ }
+ } catch (URISyntaxException ex) {
+ throw new AssetLoadException("Error converting URL to URI", ex);
+ } catch (IOException ex){
+ throw new AssetLoadException("Failed to get canonical path for " + url, ex);
+ }
+ }
+
try{
URLConnection conn = url.openConnection();
conn.setUseCaches(false);
return new ClasspathAssetInfo(manager, key, conn);
}catch (IOException ex){
- return null;
+ throw new AssetLoadException("Failed to read URL " + url, ex);
}
}