summaryrefslogtreecommitdiff
path: root/NET/worlds/network/DirTimeStamp.java
diff options
context:
space:
mode:
Diffstat (limited to 'NET/worlds/network/DirTimeStamp.java')
-rw-r--r--NET/worlds/network/DirTimeStamp.java196
1 files changed, 196 insertions, 0 deletions
diff --git a/NET/worlds/network/DirTimeStamp.java b/NET/worlds/network/DirTimeStamp.java
new file mode 100644
index 0000000..d9ab2e6
--- /dev/null
+++ b/NET/worlds/network/DirTimeStamp.java
@@ -0,0 +1,196 @@
+/* */ package NET.worlds.network;
+/* */
+/* */ import NET.worlds.core.IniFile;
+/* */ import java.io.FileNotFoundException;
+/* */ import java.io.IOException;
+/* */ import java.io.PrintStream;
+/* */ import java.net.URLConnection;
+/* */ import java.util.Hashtable;
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public class DirTimeStamp
+/* */ {
+/* 70 */ private static Hashtable<URL, DirTimeStamp> _tsEntries = new Hashtable();
+/* */
+/* */ private URL _name;
+/* */ private long _mtime;
+/* 74 */ private boolean _loaded = false;
+/* */
+/* */ private DirTimeStamp(URL url) {
+/* 77 */ this._name = url;
+/* */
+/* */
+/* 80 */ assert (url.isRemote());
+/* */ }
+/* */
+/* */ private static synchronized DirTimeStamp lookup(URL url) {
+/* 84 */ DirTimeStamp t = (DirTimeStamp)_tsEntries.get(url);
+/* */
+/* 86 */ if (t == null) {
+/* 87 */ t = new DirTimeStamp(url);
+/* 88 */ _tsEntries.put(url, t);
+/* */ }
+/* */
+/* 91 */ return t;
+/* */ }
+/* */
+/* */ private void getMTime() {
+/* 95 */ this._mtime = 0L;
+/* */ try
+/* */ {
+/* 98 */ int r = (int)(Math.random() * 1000000.0D);
+/* */
+/* 100 */ int retryCount = IniFile.gamma().getIniInt("NetCacheRetries", 1);
+/* */
+/* 102 */ boolean offline = CacheEntry.getOffline();
+/* 103 */ boolean stopOnHttpFault = offline;
+/* */
+/* 105 */ if (offline) {
+/* 106 */ this._loaded = true;
+/* 107 */ return;
+/* */ }
+/* */
+/* 110 */ if (stopOnHttpFault) {
+/* 111 */ retryCount = 1;
+/* */ }
+/* */
+/* 114 */ java.net.URL u = DNSLookup.lookup(new java.net.URL(this._name.unalias() +
+/* 115 */ "?" + r));
+/* */ for (;;)
+/* */ {
+/* */ try {
+/* 119 */ URLConnection uc = u.openConnection();
+/* 120 */ this._mtime = uc.getLastModified();
+/* */ }
+/* */ catch (IOException e) {
+/* 123 */ retryCount--;
+/* */
+/* 125 */ if ((retryCount <= 0) || ((e instanceof FileNotFoundException))) {
+/* 126 */ throw e;
+/* */ }
+/* 128 */ System.out.println("Exception " + e + " querying " +
+/* 129 */ this._name + ", retrying...");
+/* */ }
+/* */ }
+/* 132 */ this._loaded = true;
+/* */ } catch (FileNotFoundException e) {
+/* 134 */ System.out.println("Warning: timestamp " + this._name + " not found.");
+/* 135 */ this._loaded = true;
+/* */ } catch (Exception e) {
+/* 137 */ System.out.println("Timestamp query error: " + e + " accessing " +
+/* 138 */ this._name);
+/* 139 */ this._loaded = true;
+/* */ }
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public static long request(URL url)
+/* */ {
+/* 152 */ URL tsURL = URL.make(url, "timestamp.dir");
+/* */
+/* 154 */ String u = url.getInternal();
+/* */
+/* 156 */ int i = u.lastIndexOf('/');
+/* */
+/* 158 */ if (i > 0) {
+/* 159 */ int j = u.lastIndexOf('/', i - 1) + 1;
+/* 160 */ if (j > 11)
+/* */ {
+/* 162 */ String par = u.substring(j, i);
+/* */
+/* */
+/* */
+/* */
+/* 167 */ if (url.endsWith("upgrades.lst")) {
+/* 168 */ if ((!par.equals("gdkup")) && (!par.equals("newup")) &&
+/* 169 */ (!par.equals("3DCDup"))) {
+/* 170 */ tsURL = URL.make(u.substring(0, j) +
+/* 171 */ "timestamp.upgrades");
+/* */ } else {
+/* 173 */ tsURL = URL.make(url, "timestamp.upgrades");
+/* */ }
+/* 175 */ } else if (par.equals("cgi-bin")) {
+/* 176 */ return 0L;
+/* */ }
+/* */ }
+/* */ }
+/* */
+/* */
+/* 182 */ DirTimeStamp t = lookup(tsURL);
+/* */
+/* 184 */ synchronized (t) {
+/* 185 */ if (!t._loaded)
+/* 186 */ t.getMTime();
+/* */ }
+/* 188 */ return t._mtime;
+/* */ }
+/* */ }
+
+
+/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\network\DirTimeStamp.class
+ * Java compiler version: 6 (50.0)
+ * JD-Core Version: 0.7.1
+ */ \ No newline at end of file