* Now added "asset name requirements" to FileLocator to prevent Windows -> Linux porting issues
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7869 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
9f160234f8
commit
15fbe27d13
@ -40,7 +40,6 @@ 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;
|
||||
|
||||
/**
|
||||
@ -134,8 +133,5 @@ public class ClasspathLocator implements AssetLocator {
|
||||
}catch (IOException ex){
|
||||
throw new AssetLoadException("Failed to read URL " + url, ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -34,11 +34,14 @@ package com.jme3.asset.plugins;
|
||||
|
||||
import com.jme3.asset.AssetInfo;
|
||||
import com.jme3.asset.AssetKey;
|
||||
import com.jme3.asset.AssetLoadException;
|
||||
import com.jme3.asset.AssetLocator;
|
||||
import com.jme3.asset.AssetManager;
|
||||
import com.jme3.asset.AssetNotFoundException;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
@ -82,6 +85,19 @@ public class FileLocator implements AssetLocator {
|
||||
String name = key.getName();
|
||||
File file = new File(root, name);
|
||||
if (file.exists() && file.isFile()){
|
||||
try {
|
||||
// Now, check asset name requirements
|
||||
String canonical = file.getCanonicalPath();
|
||||
String absolute = file.getAbsolutePath();
|
||||
if (!canonical.endsWith(absolute)){
|
||||
throw new AssetNotFoundException("Asset name doesn't match requirements.\n"+
|
||||
"\"" + canonical + "\" doesn't match \"" + absolute + "\"");
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
throw new AssetLoadException("Failed to get file canonical path " + file, ex);
|
||||
}
|
||||
|
||||
|
||||
return new AssetInfoFile(manager, key, file);
|
||||
}else{
|
||||
return null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user