Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with JavaAssetManager#setPathPrefix #3

Closed
tmjee opened this issue Nov 22, 2011 · 1 comment
Closed

Issues with JavaAssetManager#setPathPrefix #3

tmjee opened this issue Nov 22, 2011 · 1 comment

Comments

@tmjee
Copy link

tmjee commented Nov 22, 2011

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");
@samskivert
Copy link
Member

Fixed in commit 5c57dcf.

samskivert added a commit that referenced this issue Jan 2, 2014
There's a playn-perf project which does more serious benchmarking and is a fine
place for new benchmarks to go.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants