* Added case-sensitivity and other "asset name requirements" to ClasspathLocator to prevent Windows -> Linux porting issues
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7868 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
045a8f6f0d
commit
9f160234f8
@ -34,10 +34,13 @@ package com.jme3.asset.plugins;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
@ -103,12 +106,33 @@ public class ClasspathLocator implements AssetLocator {
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user