2003/12/22 05:14:36
[org.ibex.core.git] / src / org / xwt / Res.java
index 5639080..32f812c 100644 (file)
@@ -1,4 +1,4 @@
-// FIXME
+// FIXEME
 // Copyright 2003 Adam Megacz, see the COPYING file for licensing [GPL]
 package org.xwt;
 
@@ -78,18 +78,13 @@ public abstract class Res extends JS {
         public InputStream getInputStream(String path) throws IOException {
             CachedInputStream cis = (CachedInputStream)cachedInputStreams.get(path);
             if (cis == null) {
-                java.io.File f = null;
                 if (disk) {
-                    f = new java.io.File(System.getProperty("user.home") +
-                                         java.io.File.separatorChar + ".xwt" +
-                                         java.io.File.separatorChar + "caches" +
-                                         java.io.File.separatorChar +
-                                         new String(Base64.encode(key.getBytes())));
-                    Log.log(this, "caching resource in " + f);
-                    new java.io.File(f.getParent()).mkdirs();
+                    java.io.File f = LocalStorage.Cache.getCacheFileForKey(key);
                     if (f.exists()) return new FileInputStream(f);
+                    cis = new CachedInputStream(parent.getInputStream(path), f);
+                } else {
+                    cis = new CachedInputStream(parent.getInputStream(path));
                 }
-                cis = new CachedInputStream(parent.getInputStream(path), f);
                 cachedInputStreams.put(path, cis);
             }
             return cis.getInputStream();