From: <ma...@us...> - 2008-04-20 17:00:00
|
Revision: 3027 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3027&view=rev Author: matzon Date: 2008-04-20 09:59:57 -0700 (Sun, 20 Apr 2008) Log Message: ----------- fix: native file name also has to be updated if they are using lzma or pack Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2008-04-20 15:53:11 UTC (rev 3026) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2008-04-20 16:59:57 UTC (rev 3027) @@ -659,27 +659,12 @@ percentage = 95; - // update filenames to match extracted files - for (int i = 0; i < urlList.length; i++) { - String filename = getFileName(urlList[i]); - - if (filename.endsWith(".pack.lzma")) { - urlList[i] = new URL("file://" + path + filename.replaceAll(".pack.lzma", "")); - } - else if (filename.endsWith(".pack")) { - urlList[i] = new URL("file://" + path + filename.replaceAll(".pack", "")); - } - else if (filename.endsWith(".lzma")) { - urlList[i] = new URL("file://" + path + filename.replaceAll(".lzma", "")); - } - } - Class[] parameters = new Class[] {URL.class}; // modify class path by adding downloaded jars to it for (int i = 0; i < urlList.length-1; i++) { // get location of jar as a url - URL u = new URL("file:" + path + getFileName(urlList[i])); + URL u = new URL("file:" + path + getJarName(urlList[i])); // add to class path Method method = URLClassLoader.class.getDeclaredMethod("addURL", parameters); @@ -946,7 +931,7 @@ int initialPercentage = percentage; // get name of jar file with natives from urlList, it will be the last url - String nativeJar = getFileName(urlList[urlList.length - 1]); + String nativeJar = getJarName(urlList[urlList.length - 1]); // get the current certificate to compare against native files Certificate[] certificate = AppletLoader.class.getProtectionDomain().getCodeSource().getCertificates(); @@ -1076,9 +1061,29 @@ } return null; } - + /** + * Get jar name from URL. + * + * @param url Get jar file name from this url + * @return file name as string + */ + protected String getJarName(URL url) { + String fileName = url.getFile(); + + if (fileName.endsWith(".pack.lzma")) { + fileName = fileName.replaceAll(".pack.lzma", ""); + } else if (fileName.endsWith(".pack")) { + fileName = fileName.replaceAll(".pack", ""); + } else if (fileName.endsWith(".lzma")) { + fileName = fileName.replaceAll(".lzma", ""); + } + + return fileName.substring(fileName.lastIndexOf('/') + 1); + } + + /** * Get file name portion of URL. * * @param url Get file name from this url This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |