threerings/playn — Issue #3: Issues with JavaAssetManager#setPathPrefix
Author: tmjee
Created: 2011-11-22 01:15:08+00:00
State: open

This is how setPathPrefix looks like currently

public void setPathPrefix(String prefix) {
if (prefix.startsWith("/") || prefix.endsWith("/")) {
throw new IllegalArgumentException("Prefix must not start or end with '/'.");
}
pathPrefix = prefix + "/";
}

Shouldn't it be something like instead

public void setPathPrefix(String prefix) {
if (prefix.startsWith("/") || prefix.endsWith("/")) {
throw new IllegalArgumentException("Prefix must not start or end with '/'.");
}
pathPrefix = prefix.length() > 0 ? prefix + "/" : prefix;
}

Say if i have my image in src/main/resources/images/myface.png and i do

assetManager().setPathPrefix("");

so i can do
assetManager().getImage("images/myface.png");

i'll get thrown with exception saying it cannot find '/images/myface.png'. internally it's trying to get the resource from

getClass().getClassLoader().getResource("/images/myface.png");

which should really be
getClass().getClassLoader().getResource("images/myface.png");