diff --git a/applet/appletloader.html b/applet/appletloader.html index 304242a5..cc757175 100644 --- a/applet/appletloader.html +++ b/applet/appletloader.html @@ -50,6 +50,9 @@ + + + diff --git a/src/java/org/lwjgl/util/applet/AppletLoader.java b/src/java/org/lwjgl/util/applet/AppletLoader.java index 2f913b81..04846812 100644 --- a/src/java/org/lwjgl/util/applet/AppletLoader.java +++ b/src/java/org/lwjgl/util/applet/AppletLoader.java @@ -183,6 +183,9 @@ public class AppletLoader extends Applet implements Runnable, AppletStub { /** whether we're running in debug mode */ protected boolean debugMode; + /** whether to prepend host to cache path */ + protected boolean prependHost; + /** String to display as a subtask */ protected String subtaskMessage = ""; @@ -221,6 +224,9 @@ public class AppletLoader extends Applet implements Runnable, AppletStub { // whether to run in debug mode debugMode = getBooleanParameter("al_debug", false); + // whether to prepend host to cache path + prependHost = getBooleanParameter("al_prepend_host", true); + // get colors of applet bgColor = getColor("al_bgcolor", Color.white); setBackground(bgColor); @@ -486,7 +492,17 @@ public class AppletLoader extends Applet implements Runnable, AppletStub { // get path where applet will be stored String path = (String) AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws Exception { - return System.getProperty("java.io.tmpdir") + File.separator + getParameter("al_title") + File.separator; + + // we append the code base to avoid naming collisions with al_title + String codebase = ""; + if(prependHost) { + codebase = getCodeBase().getHost(); + if(codebase == null || codebase.length() == 0) { + codebase = "localhost"; + } + codebase += File.separator; + } + return System.getProperty("java.io.tmpdir") + File.separator + codebase + getParameter("al_title") + File.separator; } }); @@ -494,7 +510,7 @@ public class AppletLoader extends Applet implements Runnable, AppletStub { // create directory if (!dir.exists()) { - dir.mkdir(); + dir.mkdirs(); } dir = new File(dir, "version");