Changeset 12331
- Timestamp:
- 01/05/10 00:03:30 (12 years ago)
- Location:
- trunk/abcl/src/org/armedbear/lisp
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/Lisp.java
r12310 r12331 1238 1238 } 1239 1239 } 1240 if (device instanceof Pathname) 1241 { 1242 // Are we loading a fasl from j.jar? 1243 // XXX this will collide with file names from other JAR files 1244 URL url = Lisp.class.getResource(namestring); 1245 if (url == null) { 1246 // Maybe device-->namestring references another JAR file? 1247 String jarFile = ((Pathname)device).getNamestring(); 1248 if (jarFile.startsWith("jar:file:")) { 1240 if (device instanceof Pathname) { //Loading from a jar 1241 URL url = null; 1242 String jar = ((Pathname)device).getNamestring(); 1243 if(jar.startsWith("jar:")) { 1244 try { 1245 url = new URL(jar + "!/" + namestring); 1246 } catch (MalformedURLException ex) { 1247 Debug.trace(ex); 1248 } 1249 } else { 1250 url = Lisp.class.getResource(namestring); 1251 } 1252 if (url != null) { 1249 1253 try { 1250 url = new URL(jarFile + "!/" + namestring); 1251 } catch (MalformedURLException ex) { 1252 Debug.trace(ex); 1253 } 1254 } 1255 } 1256 if (url != null) 1257 { 1258 try 1259 { 1260 String s = url.toString(); 1261 String zipFileName; 1262 String entryName; 1263 if (s.startsWith("jar:file:")) 1264 { 1265 s = s.substring(9); 1266 int index = s.lastIndexOf('!'); 1267 if (index >= 0) 1268 { 1269 zipFileName = s.substring(0, index); 1270 entryName = s.substring(index + 1); 1271 if (entryName.length() > 0 && entryName.charAt(0) == '/') 1272 entryName = entryName.substring(1); 1273 if (Utilities.isPlatformWindows) 1274 { 1275 // "/C:/Documents%20and%20Settings/peter/Desktop/j.jar" 1276 if (zipFileName.length() > 0 && zipFileName.charAt(0) == '/') 1277 zipFileName = zipFileName.substring(1); 1278 } 1279 zipFileName = URLDecoder.decode(zipFileName, "UTF-8"); 1280 ZipFile zipFile = ZipCache.getZip(zipFileName); 1281 try 1282 { 1283 ZipEntry entry = zipFile.getEntry(entryName); 1284 if (entry != null) 1285 { 1286 long size = entry.getSize(); 1287 InputStream in = zipFile.getInputStream(entry); 1288 return readFunctionBytes(in, (int) size); 1289 } 1290 else 1291 { 1292 // ASSERT type = "abcl" 1293 entryName 1294 = defaultPathname.name.getStringValue() 1295 + "." + "abcl";//defaultPathname.type.getStringValue(); 1296 return Utilities 1297 .getZippedZipEntryAsByteArray(zipFile, 1298 entryName, 1299 namestring); 1300 } 1301 } 1302 finally 1303 { 1304 ZipCache.removeZip(zipFile.getName()); 1305 } 1306 } 1307 } 1308 } 1309 catch (VerifyError e) 1310 { 1311 error(new LispError("Class verification failed: " + 1312 e.getMessage())); 1313 return null; // not reached 1314 } 1315 catch (IOException e) 1316 { 1254 InputStream input = null; 1255 java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream(); 1256 try { 1257 input = url.openStream(); 1258 byte[] bytes = new byte[4096]; 1259 int n = 0; 1260 while (n >= 0) { 1261 n = input.read(bytes, 0, 4096); 1262 if(n >= 0) { 1263 baos.write(bytes, 0, n); 1264 } 1265 } 1266 bytes = baos.toByteArray(); 1267 return bytes; 1268 } finally { 1269 baos.close(); 1270 if(input != null) { 1271 input.close(); 1272 } 1273 } 1274 } catch (IOException e) { 1317 1275 Debug.trace(e); 1318 1319 1276 } 1277 } 1320 1278 error(new LispError("Unable to load " + namestring)); 1321 1279 return null; // not reached 1322 1280 } 1323 1281 Pathname pathname = new Pathname(namestring); 1324 1282 final File file = Utilities.getFile(pathname, defaultPathname); -
trunk/abcl/src/org/armedbear/lisp/Load.java
r12330 r12331 394 394 try { 395 395 in = url.openStream(); 396 if ("jar".equals(url.getProtocol())) 396 if ("jar".equals(url.getProtocol()) && 397 url.getPath().startsWith("file:")) 397 398 pathname = new Pathname(url); 398 399 truename = getPath(url);
Note: See TracChangeset
for help on using the changeset viewer.