X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2FResources.java;h=a152bf80b4b745ff18ddde34682269ca6b1c5434;hb=69ecee0bc41e6bd410572817e7c59d51f1b5b629;hp=eebef059ec12bde85691f6feb7d7a9eef366867a;hpb=41046cea8b3f3129f18ea9bbb34927202b391c88;p=org.ibex.core.git
diff --git a/src/org/xwt/Resources.java b/src/org/xwt/Resources.java
index eebef05..a152bf8 100644
--- a/src/org/xwt/Resources.java
+++ b/src/org/xwt/Resources.java
@@ -4,10 +4,10 @@ package org.xwt;
import java.io.*;
import java.net.*;
import java.util.*;
-import jazz.*;
+import java.util.zip.*;
import java.lang.*;
import java.applet.*;
-import org.mozilla.javascript.*;
+import org.xwt.js.*;
import org.xwt.util.*;
/**
@@ -25,12 +25,12 @@ public class Resources {
/** Holds resources added at runtime. Initialized to hold 2000 to work around a NetscapeJVM bug. */
private static Hash bytes = new Hash(2000, 3);
- /** The number of bytes read from the initial-xwar stream; used to display a progress bar on the splash screen */
- public static int bytesDownloaded = 0;
+ /** keeps track of which archive loaded templates into which package */
+ private static Hash usedPackages = new Hash();
/** Returns true iff name is a valid resource name */
private static boolean validResourceName(String name) {
- if (name == null || name.equals("")) return false;
+ if (name == null || name.equals("")) return true;
if (name.endsWith("/box.xwt") || name.endsWith("/svg.xwt")) return false;
if (name.equals("box.xwt") || name.equals("svg.xwt")) return false;
if (!((name.charAt(0) >= 'A' && name.charAt(0) <= 'Z') ||
@@ -39,9 +39,8 @@ public class Resources {
char c = name.charAt(i);
if (!((c >= 'A' && c <= 'Z') ||
(c >= 'a' && c <= 'z') ||
- c == '_' ||
- (c >= '0' && c <= '9') ||
- (c == '.' && i == name.length() - 4))) return false;
+ c == '_' || c == '.' ||
+ (c >= '0' && c <= '9'))) return false;
}
return true;
}
@@ -49,48 +48,79 @@ public class Resources {
/** Load a directory as if it were an archive */
public static synchronized void loadDirectory(File dir) throws IOException { loadDirectory(dir, ""); }
private static synchronized void loadDirectory(File dir, String prefix) throws IOException {
- new Static(prefix.replace(File.separatorChar, '.'));
+ String n = prefix.replace(File.separatorChar, '.');
+ if (n.endsWith(".")) n = n.substring(0, n.length() - 1);
+ new Static(n);
String[] subfiles = dir.list();
for(int i=0; i