diff options
| author | Fuwn <[email protected]> | 2021-05-03 16:38:41 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-05-03 16:38:41 -0700 |
| commit | e1e781bb2135ef78592226f1a3eaba4925702f1f (patch) | |
| tree | 8a5b590463ed413e1c6eabb719130e701b95ca63 /NET/worlds/network/Cache.java | |
| download | worlds.jar-main.tar.xz worlds.jar-main.zip | |
Diffstat (limited to 'NET/worlds/network/Cache.java')
| -rw-r--r-- | NET/worlds/network/Cache.java | 955 |
1 files changed, 955 insertions, 0 deletions
diff --git a/NET/worlds/network/Cache.java b/NET/worlds/network/Cache.java new file mode 100644 index 0000000..7a2f3e9 --- /dev/null +++ b/NET/worlds/network/Cache.java @@ -0,0 +1,955 @@ +/* */ package NET.worlds.network; +/* */ +/* */ import NET.worlds.console.Gamma; +/* */ import NET.worlds.console.Main; +/* */ import NET.worlds.console.MainCallback; +/* */ import NET.worlds.console.MainTerminalCallback; +/* */ import NET.worlds.core.IniFile; +/* */ import NET.worlds.core.Std; +/* */ import java.io.File; +/* */ import java.io.FileOutputStream; +/* */ import java.io.IOException; +/* */ import java.io.InputStream; +/* */ import java.io.ObjectOutputStream; +/* */ import java.io.PrintStream; +/* */ import java.io.Serializable; +/* */ import java.util.Collection; +/* */ import java.util.Date; +/* */ import java.util.Enumeration; +/* */ import java.util.Hashtable; +/* */ import java.util.Iterator; +/* */ import java.util.Vector; +/* */ import java.util.zip.ZipEntry; +/* */ import java.util.zip.ZipFile; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public class Cache +/* */ implements MainCallback, MainTerminalCallback, Serializable +/* */ { +/* */ private static final long serialVersionUID = -7557149391688293661L; +/* */ private static final long CACHE_VERSION = 0L; +/* 56 */ private static String CACHE_DIR = Gamma.earlyURLUnalias("home:cachedir/") +/* 57 */ .replace('/', '\\'); +/* */ +/* */ +/* */ +/* */ +/* */ +/* 63 */ static final int CACHE_MIN_CHANGE = IniFile.gamma().getIniInt("NetCacheMinChange", 50); +/* */ +/* */ +/* 66 */ static final long CACHE_MAX_DELAY = IniFile.gamma().getIniInt("NetCacheMaxDelay", 5) * 1000L * 60L; +/* 67 */ private Date lastCacheSave = new Date(); +/* */ +/* */ +/* 70 */ static transient Cache cache = initLoad(); +/* */ +/* 72 */ private transient Hashtable<Object, CacheEntry> table = new Hashtable(); +/* */ +/* */ +/* */ +/* 76 */ private transient CacheEntry terminator = new CacheEntry(); +/* */ +/* */ transient long totalBytes; +/* */ +/* */ transient int hasChanged; +/* */ +/* 82 */ private int nextAvailable = 1; +/* */ +/* */ public static void ClearCustomAvatars() +/* */ { +/* 86 */ Collection<CacheEntry> c = cache.table.values(); +/* */ +/* 88 */ Iterator<CacheEntry> it = c.iterator(); +/* */ +/* 90 */ Vector<CacheEntry> tmp = new Vector(); +/* */ +/* 92 */ while (it.hasNext()) +/* */ { +/* 94 */ CacheEntry ce = (CacheEntry)it.next(); +/* 95 */ if ((ce != null) && (ce.url.toString().contains("custom"))) +/* */ { +/* 97 */ tmp.add(ce); +/* */ } +/* */ } +/* */ +/* 101 */ for (int i = 0; i < tmp.size(); i++) { +/* 102 */ removeEntry((CacheEntry)tmp.get(i)); +/* */ } +/* */ } +/* */ +/* */ /* Error */ +/* */ static Cache initLoad() +/* */ { +/* */ // Byte code: +/* */ // 0: getstatic 163 java/lang/System:out Ljava/io/PrintStream; +/* */ // 3: ldc -87 +/* */ // 5: invokevirtual 171 java/io/PrintStream:println (Ljava/lang/String;)V +/* */ // 8: new 1 NET/worlds/network/Cache +/* */ // 11: dup +/* */ // 12: invokespecial 177 NET/worlds/network/Cache:<init> ()V +/* */ // 15: astore_0 +/* */ // 16: aconst_null +/* */ // 17: astore_1 +/* */ // 18: aconst_null +/* */ // 19: astore_2 +/* */ // 20: getstatic 163 java/lang/System:out Ljava/io/PrintStream; +/* */ // 23: ldc -78 +/* */ // 25: invokevirtual 171 java/io/PrintStream:println (Ljava/lang/String;)V +/* */ // 28: new 180 java/io/File +/* */ // 31: dup +/* */ // 32: new 182 java/lang/StringBuilder +/* */ // 35: dup +/* */ // 36: getstatic 54 NET/worlds/network/Cache:CACHE_DIR Ljava/lang/String; +/* */ // 39: invokestatic 184 java/lang/String:valueOf (Ljava/lang/Object;)Ljava/lang/String; +/* */ // 42: invokespecial 188 java/lang/StringBuilder:<init> (Ljava/lang/String;)V +/* */ // 45: ldc -66 +/* */ // 47: invokevirtual 192 java/lang/StringBuilder:append (Ljava/lang/String;)Ljava/lang/StringBuilder; +/* */ // 50: invokevirtual 196 java/lang/StringBuilder:toString ()Ljava/lang/String; +/* */ // 53: invokespecial 197 java/io/File:<init> (Ljava/lang/String;)V +/* */ // 56: astore_3 +/* */ // 57: aload_3 +/* */ // 58: invokevirtual 198 java/io/File:exists ()Z +/* */ // 61: ifne +68 -> 129 +/* */ // 64: new 180 java/io/File +/* */ // 67: dup +/* */ // 68: new 182 java/lang/StringBuilder +/* */ // 71: dup +/* */ // 72: getstatic 54 NET/worlds/network/Cache:CACHE_DIR Ljava/lang/String; +/* */ // 75: invokestatic 184 java/lang/String:valueOf (Ljava/lang/Object;)Ljava/lang/String; +/* */ // 78: invokespecial 188 java/lang/StringBuilder:<init> (Ljava/lang/String;)V +/* */ // 81: ldc -55 +/* */ // 83: invokevirtual 192 java/lang/StringBuilder:append (Ljava/lang/String;)Ljava/lang/StringBuilder; +/* */ // 86: invokevirtual 196 java/lang/StringBuilder:toString ()Ljava/lang/String; +/* */ // 89: invokespecial 197 java/io/File:<init> (Ljava/lang/String;)V +/* */ // 92: astore_3 +/* */ // 93: aload_3 +/* */ // 94: invokevirtual 198 java/io/File:exists ()Z +/* */ // 97: ifne +32 -> 129 +/* */ // 100: new 180 java/io/File +/* */ // 103: dup +/* */ // 104: new 182 java/lang/StringBuilder +/* */ // 107: dup +/* */ // 108: getstatic 54 NET/worlds/network/Cache:CACHE_DIR Ljava/lang/String; +/* */ // 111: invokestatic 184 java/lang/String:valueOf (Ljava/lang/Object;)Ljava/lang/String; +/* */ // 114: invokespecial 188 java/lang/StringBuilder:<init> (Ljava/lang/String;)V +/* */ // 117: ldc -53 +/* */ // 119: invokevirtual 192 java/lang/StringBuilder:append (Ljava/lang/String;)Ljava/lang/StringBuilder; +/* */ // 122: invokevirtual 196 java/lang/StringBuilder:toString ()Ljava/lang/String; +/* */ // 125: invokespecial 197 java/io/File:<init> (Ljava/lang/String;)V +/* */ // 128: astore_3 +/* */ // 129: new 205 java/io/FileInputStream +/* */ // 132: dup +/* */ // 133: aload_3 +/* */ // 134: invokespecial 207 java/io/FileInputStream:<init> (Ljava/io/File;)V +/* */ // 137: astore_1 +/* */ // 138: new 210 java/io/ObjectInputStream +/* */ // 141: dup +/* */ // 142: aload_1 +/* */ // 143: invokespecial 212 java/io/ObjectInputStream:<init> (Ljava/io/InputStream;)V +/* */ // 146: astore_2 +/* */ // 147: aload_2 +/* */ // 148: invokevirtual 215 java/io/ObjectInputStream:readLong ()J +/* */ // 151: lstore 4 +/* */ // 153: lload 4 +/* */ // 155: lconst_0 +/* */ // 156: lcmp +/* */ // 157: ifeq +13 -> 170 +/* */ // 160: new 219 java/lang/Exception +/* */ // 163: dup +/* */ // 164: ldc -35 +/* */ // 166: invokespecial 223 java/lang/Exception:<init> (Ljava/lang/String;)V +/* */ // 169: athrow +/* */ // 170: aload_2 +/* */ // 171: invokevirtual 224 java/io/ObjectInputStream:readObject ()Ljava/lang/Object; +/* */ // 174: checkcast 1 NET/worlds/network/Cache +/* */ // 177: astore_0 +/* */ // 178: aload_0 +/* */ // 179: new 112 NET/worlds/network/CacheEntry +/* */ // 182: dup +/* */ // 183: invokespecial 227 NET/worlds/network/CacheEntry:<init> ()V +/* */ // 186: putfield 228 NET/worlds/network/Cache:terminator LNET/worlds/network/CacheEntry; +/* */ // 189: aload_0 +/* */ // 190: new 90 java/util/Hashtable +/* */ // 193: dup +/* */ // 194: invokespecial 230 java/util/Hashtable:<init> ()V +/* */ // 197: putfield 87 NET/worlds/network/Cache:table Ljava/util/Hashtable; +/* */ // 200: goto +55 -> 255 +/* */ // 203: aload 6 +/* */ // 205: instanceof 112 +/* */ // 208: ifeq +57 -> 265 +/* */ // 211: aload 6 +/* */ // 213: checkcast 112 NET/worlds/network/CacheEntry +/* */ // 216: getfield 114 NET/worlds/network/CacheEntry:url LNET/worlds/network/URL; +/* */ // 219: ifnull +36 -> 255 +/* */ // 222: aload 6 +/* */ // 224: checkcast 112 NET/worlds/network/CacheEntry +/* */ // 227: getfield 231 NET/worlds/network/CacheEntry:localName Ljava/lang/String; +/* */ // 230: ifnull +25 -> 255 +/* */ // 233: aload 6 +/* */ // 235: checkcast 112 NET/worlds/network/CacheEntry +/* */ // 238: getfield 234 NET/worlds/network/CacheEntry:state I +/* */ // 241: bipush 7 +/* */ // 243: if_icmplt +12 -> 255 +/* */ // 246: aload_0 +/* */ // 247: aload 6 +/* */ // 249: checkcast 112 NET/worlds/network/CacheEntry +/* */ // 252: invokevirtual 237 NET/worlds/network/Cache:add (LNET/worlds/network/CacheEntry;)V +/* */ // 255: aload_2 +/* */ // 256: invokevirtual 224 java/io/ObjectInputStream:readObject ()Ljava/lang/Object; +/* */ // 259: dup +/* */ // 260: astore 6 +/* */ // 262: ifnonnull -59 -> 203 +/* */ // 265: aload_2 +/* */ // 266: invokevirtual 239 java/io/ObjectInputStream:close ()V +/* */ // 269: aconst_null +/* */ // 270: astore_2 +/* */ // 271: aload_1 +/* */ // 272: invokevirtual 242 java/io/FileInputStream:close ()V +/* */ // 275: aconst_null +/* */ // 276: astore_1 +/* */ // 277: getstatic 163 java/lang/System:out Ljava/io/PrintStream; +/* */ // 280: ldc -13 +/* */ // 282: invokevirtual 171 java/io/PrintStream:println (Ljava/lang/String;)V +/* */ // 285: goto +163 -> 448 +/* */ // 288: astore_3 +/* */ // 289: aload_2 +/* */ // 290: ifnull +14 -> 304 +/* */ // 293: aload_2 +/* */ // 294: invokevirtual 239 java/io/ObjectInputStream:close ()V +/* */ // 297: goto +5 -> 302 +/* */ // 300: astore 8 +/* */ // 302: aconst_null +/* */ // 303: astore_2 +/* */ // 304: aload_1 +/* */ // 305: ifnull +173 -> 478 +/* */ // 308: aload_1 +/* */ // 309: invokevirtual 242 java/io/FileInputStream:close ()V +/* */ // 312: goto +5 -> 317 +/* */ // 315: astore 8 +/* */ // 317: aconst_null +/* */ // 318: astore_1 +/* */ // 319: goto +159 -> 478 +/* */ // 322: astore_3 +/* */ // 323: getstatic 163 java/lang/System:out Ljava/io/PrintStream; +/* */ // 326: aload_3 +/* */ // 327: invokevirtual 245 java/io/PrintStream:println (Ljava/lang/Object;)V +/* */ // 330: getstatic 163 java/lang/System:out Ljava/io/PrintStream; +/* */ // 333: ldc -8 +/* */ // 335: invokevirtual 171 java/io/PrintStream:println (Ljava/lang/String;)V +/* */ // 338: new 180 java/io/File +/* */ // 341: dup +/* */ // 342: new 182 java/lang/StringBuilder +/* */ // 345: dup +/* */ // 346: getstatic 54 NET/worlds/network/Cache:CACHE_DIR Ljava/lang/String; +/* */ // 349: invokestatic 184 java/lang/String:valueOf (Ljava/lang/Object;)Ljava/lang/String; +/* */ // 352: invokespecial 188 java/lang/StringBuilder:<init> (Ljava/lang/String;)V +/* */ // 355: ldc -66 +/* */ // 357: invokevirtual 192 java/lang/StringBuilder:append (Ljava/lang/String;)Ljava/lang/StringBuilder; +/* */ // 360: invokevirtual 196 java/lang/StringBuilder:toString ()Ljava/lang/String; +/* */ // 363: invokespecial 197 java/io/File:<init> (Ljava/lang/String;)V +/* */ // 366: astore 4 +/* */ // 368: aload 4 +/* */ // 370: invokevirtual 250 java/io/File:mkdirs ()Z +/* */ // 373: pop +/* */ // 374: aload 4 +/* */ // 376: invokevirtual 253 java/io/File:delete ()Z +/* */ // 379: pop +/* */ // 380: aload_2 +/* */ // 381: ifnull +14 -> 395 +/* */ // 384: aload_2 +/* */ // 385: invokevirtual 239 java/io/ObjectInputStream:close ()V +/* */ // 388: goto +5 -> 393 +/* */ // 391: astore 8 +/* */ // 393: aconst_null +/* */ // 394: astore_2 +/* */ // 395: aload_1 +/* */ // 396: ifnull +82 -> 478 +/* */ // 399: aload_1 +/* */ // 400: invokevirtual 242 java/io/FileInputStream:close ()V +/* */ // 403: goto +5 -> 408 +/* */ // 406: astore 8 +/* */ // 408: aconst_null +/* */ // 409: astore_1 +/* */ // 410: goto +68 -> 478 +/* */ // 413: astore 7 +/* */ // 415: aload_2 +/* */ // 416: ifnull +14 -> 430 +/* */ // 419: aload_2 +/* */ // 420: invokevirtual 239 java/io/ObjectInputStream:close ()V +/* */ // 423: goto +5 -> 428 +/* */ // 426: astore 8 +/* */ // 428: aconst_null +/* */ // 429: astore_2 +/* */ // 430: aload_1 +/* */ // 431: ifnull +14 -> 445 +/* */ // 434: aload_1 +/* */ // 435: invokevirtual 242 java/io/FileInputStream:close ()V +/* */ // 438: goto +5 -> 443 +/* */ // 441: astore 8 +/* */ // 443: aconst_null +/* */ // 444: astore_1 +/* */ // 445: aload 7 +/* */ // 447: athrow +/* */ // 448: aload_2 +/* */ // 449: ifnull +14 -> 463 +/* */ // 452: aload_2 +/* */ // 453: invokevirtual 239 java/io/ObjectInputStream:close ()V +/* */ // 456: goto +5 -> 461 +/* */ // 459: astore 8 +/* */ // 461: aconst_null +/* */ // 462: astore_2 +/* */ // 463: aload_1 +/* */ // 464: ifnull +14 -> 478 +/* */ // 467: aload_1 +/* */ // 468: invokevirtual 242 java/io/FileInputStream:close ()V +/* */ // 471: goto +5 -> 476 +/* */ // 474: astore 8 +/* */ // 476: aconst_null +/* */ // 477: astore_1 +/* */ // 478: new 180 java/io/File +/* */ // 481: dup +/* */ // 482: getstatic 54 NET/worlds/network/Cache:CACHE_DIR Ljava/lang/String; +/* */ // 485: invokespecial 197 java/io/File:<init> (Ljava/lang/String;)V +/* */ // 488: invokevirtual 256 java/io/File:list ()[Ljava/lang/String; +/* */ // 491: astore_3 +/* */ // 492: new 90 java/util/Hashtable +/* */ // 495: dup +/* */ // 496: invokespecial 230 java/util/Hashtable:<init> ()V +/* */ // 499: astore 4 +/* */ // 501: aload_3 +/* */ // 502: ifnull +84 -> 586 +/* */ // 505: iconst_0 +/* */ // 506: istore 5 +/* */ // 508: goto +41 -> 549 +/* */ // 511: aload 4 +/* */ // 513: new 182 java/lang/StringBuilder +/* */ // 516: dup +/* */ // 517: getstatic 54 NET/worlds/network/Cache:CACHE_DIR Ljava/lang/String; +/* */ // 520: invokestatic 184 java/lang/String:valueOf (Ljava/lang/Object;)Ljava/lang/String; +/* */ // 523: invokespecial 188 java/lang/StringBuilder:<init> (Ljava/lang/String;)V +/* */ // 526: aload_3 +/* */ // 527: iload 5 +/* */ // 529: aaload +/* */ // 530: invokevirtual 192 java/lang/StringBuilder:append (Ljava/lang/String;)Ljava/lang/StringBuilder; +/* */ // 533: invokevirtual 196 java/lang/StringBuilder:toString ()Ljava/lang/String; +/* */ // 536: invokevirtual 260 java/lang/String:toUpperCase ()Ljava/lang/String; +/* */ // 539: ldc_w 263 +/* */ // 542: invokevirtual 265 java/util/Hashtable:put (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; +/* */ // 545: pop +/* */ // 546: iinc 5 1 +/* */ // 549: iload 5 +/* */ // 551: aload_3 +/* */ // 552: arraylength +/* */ // 553: if_icmplt -42 -> 511 +/* */ // 556: aload 4 +/* */ // 558: new 182 java/lang/StringBuilder +/* */ // 561: dup +/* */ // 562: getstatic 54 NET/worlds/network/Cache:CACHE_DIR Ljava/lang/String; +/* */ // 565: invokestatic 184 java/lang/String:valueOf (Ljava/lang/Object;)Ljava/lang/String; +/* */ // 568: invokespecial 188 java/lang/StringBuilder:<init> (Ljava/lang/String;)V +/* */ // 571: ldc -66 +/* */ // 573: invokevirtual 192 java/lang/StringBuilder:append (Ljava/lang/String;)Ljava/lang/StringBuilder; +/* */ // 576: invokevirtual 196 java/lang/StringBuilder:toString ()Ljava/lang/String; +/* */ // 579: invokevirtual 260 java/lang/String:toUpperCase ()Ljava/lang/String; +/* */ // 582: invokevirtual 269 java/util/Hashtable:remove (Ljava/lang/Object;)Ljava/lang/Object; +/* */ // 585: pop +/* */ // 586: aload_0 +/* */ // 587: lconst_0 +/* */ // 588: putfield 273 NET/worlds/network/Cache:totalBytes J +/* */ // 591: aload_0 +/* */ // 592: iconst_0 +/* */ // 593: putfield 275 NET/worlds/network/Cache:hasChanged I +/* */ // 596: aload_0 +/* */ // 597: getfield 228 NET/worlds/network/Cache:terminator LNET/worlds/network/CacheEntry; +/* */ // 600: getfield 277 NET/worlds/network/CacheEntry:next LNET/worlds/network/CacheEntry; +/* */ // 603: astore 5 +/* */ // 605: goto +101 -> 706 +/* */ // 608: aload 5 +/* */ // 610: astore 6 +/* */ // 612: aload 5 +/* */ // 614: getfield 277 NET/worlds/network/CacheEntry:next LNET/worlds/network/CacheEntry; +/* */ // 617: astore 5 +/* */ // 619: aload 6 +/* */ // 621: getfield 231 NET/worlds/network/CacheEntry:localName Ljava/lang/String; +/* */ // 624: invokevirtual 260 java/lang/String:toUpperCase ()Ljava/lang/String; +/* */ // 627: astore 7 +/* */ // 629: aload 4 +/* */ // 631: aload 7 +/* */ // 633: invokevirtual 279 java/util/Hashtable:get (Ljava/lang/Object;)Ljava/lang/Object; +/* */ // 636: ifnull +7 -> 643 +/* */ // 639: iconst_1 +/* */ // 640: goto +4 -> 644 +/* */ // 643: iconst_0 +/* */ // 644: istore 8 +/* */ // 646: aload 4 +/* */ // 648: aload 7 +/* */ // 650: invokevirtual 269 java/util/Hashtable:remove (Ljava/lang/Object;)Ljava/lang/Object; +/* */ // 653: pop +/* */ // 654: aload_0 +/* */ // 655: dup +/* */ // 656: getfield 273 NET/worlds/network/Cache:totalBytes J +/* */ // 659: aload 6 +/* */ // 661: getfield 281 NET/worlds/network/CacheEntry:bytes I +/* */ // 664: i2l +/* */ // 665: ladd +/* */ // 666: putfield 273 NET/worlds/network/Cache:totalBytes J +/* */ // 669: aload 6 +/* */ // 671: invokevirtual 284 NET/worlds/network/CacheEntry:done ()Z +/* */ // 674: ifeq +8 -> 682 +/* */ // 677: iload 8 +/* */ // 679: ifne +27 -> 706 +/* */ // 682: aload_0 +/* */ // 683: aload 6 +/* */ // 685: invokevirtual 287 NET/worlds/network/Cache:remove (LNET/worlds/network/CacheEntry;)V +/* */ // 688: iload 8 +/* */ // 690: ifeq +16 -> 706 +/* */ // 693: new 180 java/io/File +/* */ // 696: dup +/* */ // 697: aload 7 +/* */ // 699: invokespecial 197 java/io/File:<init> (Ljava/lang/String;)V +/* */ // 702: invokevirtual 253 java/io/File:delete ()Z +/* */ // 705: pop +/* */ // 706: aload 5 +/* */ // 708: aload_0 +/* */ // 709: getfield 228 NET/worlds/network/Cache:terminator LNET/worlds/network/CacheEntry; +/* */ // 712: if_acmpne -104 -> 608 +/* */ // 715: aload 4 +/* */ // 717: invokevirtual 289 java/util/Hashtable:keys ()Ljava/util/Enumeration; +/* */ // 720: astore 5 +/* */ // 722: goto +24 -> 746 +/* */ // 725: new 180 java/io/File +/* */ // 728: dup +/* */ // 729: aload 5 +/* */ // 731: invokeinterface 293 1 0 +/* */ // 736: checkcast 49 java/lang/String +/* */ // 739: invokespecial 197 java/io/File:<init> (Ljava/lang/String;)V +/* */ // 742: invokevirtual 253 java/io/File:delete ()Z +/* */ // 745: pop +/* */ // 746: aload 5 +/* */ // 748: invokeinterface 298 1 0 +/* */ // 753: ifne -28 -> 725 +/* */ // 756: new 180 java/io/File +/* */ // 759: dup +/* */ // 760: ldc_w 301 +/* */ // 763: invokespecial 197 java/io/File:<init> (Ljava/lang/String;)V +/* */ // 766: astore 5 +/* */ // 768: aload 5 +/* */ // 770: invokevirtual 198 java/io/File:exists ()Z +/* */ // 773: ifeq +15 -> 788 +/* */ // 776: aload_0 +/* */ // 777: putstatic 82 NET/worlds/network/Cache:cache LNET/worlds/network/Cache; +/* */ // 780: aload 5 +/* */ // 782: ldc_w 303 +/* */ // 785: invokestatic 305 NET/worlds/network/Cache:InjectZipFile (Ljava/io/File;Ljava/lang/String;)V +/* */ // 788: aload_0 +/* */ // 789: new 309 java/util/Date +/* */ // 792: dup +/* */ // 793: invokespecial 311 java/util/Date:<init> ()V +/* */ // 796: putfield 312 NET/worlds/network/Cache:lastCacheSave Ljava/util/Date; +/* */ // 799: aload_0 +/* */ // 800: invokestatic 314 NET/worlds/console/Main:register (LNET/worlds/console/MainCallback;)V +/* */ // 803: aload_0 +/* */ // 804: areturn +/* */ // Line number table: +/* */ // Java source line #109 -> byte code offset #0 +/* */ // Java source line #111 -> byte code offset #8 +/* */ // Java source line #112 -> byte code offset #16 +/* */ // Java source line #113 -> byte code offset #18 +/* */ // Java source line #130 -> byte code offset #20 +/* */ // Java source line #132 -> byte code offset #28 +/* */ // Java source line #133 -> byte code offset #57 +/* */ // Java source line #134 -> byte code offset #64 +/* */ // Java source line #135 -> byte code offset #93 +/* */ // Java source line #136 -> byte code offset #100 +/* */ // Java source line #139 -> byte code offset #129 +/* */ // Java source line #140 -> byte code offset #138 +/* */ // Java source line #141 -> byte code offset #147 +/* */ // Java source line #142 -> byte code offset #153 +/* */ // Java source line #143 -> byte code offset #160 +/* */ // Java source line #145 -> byte code offset #170 +/* */ // Java source line #147 -> byte code offset #178 +/* */ // Java source line #148 -> byte code offset #189 +/* */ // Java source line #152 -> byte code offset #200 +/* */ // Java source line #153 -> byte code offset #203 +/* */ // Java source line #155 -> byte code offset #211 +/* */ // Java source line #158 -> byte code offset #246 +/* */ // Java source line #152 -> byte code offset #255 +/* */ // Java source line #167 -> byte code offset #265 +/* */ // Java source line #168 -> byte code offset #269 +/* */ // Java source line #169 -> byte code offset #271 +/* */ // Java source line #170 -> byte code offset #275 +/* */ // Java source line #188 -> byte code offset #277 +/* */ // Java source line #191 -> byte code offset #285 +/* */ // Java source line #207 -> byte code offset #289 +/* */ // Java source line #209 -> byte code offset #293 +/* */ // Java source line #210 -> byte code offset #297 +/* */ // Java source line #213 -> byte code offset #302 +/* */ // Java source line #215 -> byte code offset #304 +/* */ // Java source line #217 -> byte code offset #308 +/* */ // Java source line #218 -> byte code offset #312 +/* */ // Java source line #221 -> byte code offset #317 +/* */ // Java source line #196 -> byte code offset #322 +/* */ // Java source line #197 -> byte code offset #323 +/* */ // Java source line #198 -> byte code offset #330 +/* */ // Java source line #203 -> byte code offset #338 +/* */ // Java source line #204 -> byte code offset #368 +/* */ // Java source line #205 -> byte code offset #374 +/* */ // Java source line #207 -> byte code offset #380 +/* */ // Java source line #209 -> byte code offset #384 +/* */ // Java source line #210 -> byte code offset #388 +/* */ // Java source line #213 -> byte code offset #393 +/* */ // Java source line #215 -> byte code offset #395 +/* */ // Java source line #217 -> byte code offset #399 +/* */ // Java source line #218 -> byte code offset #403 +/* */ // Java source line #221 -> byte code offset #408 +/* */ // Java source line #206 -> byte code offset #413 +/* */ // Java source line #207 -> byte code offset #415 +/* */ // Java source line #209 -> byte code offset #419 +/* */ // Java source line #210 -> byte code offset #423 +/* */ // Java source line #213 -> byte code offset #428 +/* */ // Java source line #215 -> byte code offset #430 +/* */ // Java source line #217 -> byte code offset #434 +/* */ // Java source line #218 -> byte code offset #438 +/* */ // Java source line #221 -> byte code offset #443 +/* */ // Java source line #223 -> byte code offset #445 +/* */ // Java source line #207 -> byte code offset #448 +/* */ // Java source line #209 -> byte code offset #452 +/* */ // Java source line #210 -> byte code offset #456 +/* */ // Java source line #213 -> byte code offset #461 +/* */ // Java source line #215 -> byte code offset #463 +/* */ // Java source line #217 -> byte code offset #467 +/* */ // Java source line #218 -> byte code offset #471 +/* */ // Java source line #221 -> byte code offset #476 +/* */ // Java source line #230 -> byte code offset #478 +/* */ // Java source line #231 -> byte code offset #492 +/* */ // Java source line #232 -> byte code offset #501 +/* */ // Java source line #233 -> byte code offset #505 +/* */ // Java source line #234 -> byte code offset #511 +/* */ // Java source line #233 -> byte code offset #546 +/* */ // Java source line #236 -> byte code offset #556 +/* */ // Java source line #242 -> byte code offset #586 +/* */ // Java source line #243 -> byte code offset #591 +/* */ // Java source line #244 -> byte code offset #596 +/* */ // Java source line #245 -> byte code offset #608 +/* */ // Java source line #246 -> byte code offset #612 +/* */ // Java source line #248 -> byte code offset #619 +/* */ // Java source line #249 -> byte code offset #629 +/* */ // Java source line #250 -> byte code offset #646 +/* */ // Java source line #252 -> byte code offset #654 +/* */ // Java source line #254 -> byte code offset #669 +/* */ // Java source line #255 -> byte code offset #682 +/* */ // Java source line #256 -> byte code offset #688 +/* */ // Java source line #257 -> byte code offset #693 +/* */ // Java source line #244 -> byte code offset #706 +/* */ // Java source line #263 -> byte code offset #715 +/* */ // Java source line #264 -> byte code offset #725 +/* */ // Java source line #263 -> byte code offset #746 +/* */ // Java source line #268 -> byte code offset #756 +/* */ // Java source line #269 -> byte code offset #768 +/* */ // Java source line #270 -> byte code offset #776 +/* */ // Java source line #271 -> byte code offset #780 +/* */ // Java source line #274 -> byte code offset #788 +/* */ // Java source line #275 -> byte code offset #799 +/* */ // Java source line #276 -> byte code offset #803 +/* */ // Local variable table: +/* */ // start length slot name signature +/* */ // 15 789 0 c Cache +/* */ // 17 461 1 in java.io.FileInputStream +/* */ // 19 444 2 s java.io.ObjectInputStream +/* */ // 56 78 3 fi File +/* */ // 288 1 3 localOptionalDataException java.io.OptionalDataException +/* */ // 322 5 3 e Exception +/* */ // 491 61 3 names String[] +/* */ // 151 3 4 version long +/* */ // 366 9 4 findex File +/* */ // 499 217 4 files Hashtable<String, String> +/* */ // 506 44 5 i int +/* */ // 603 104 5 p CacheEntry +/* */ // 720 27 5 e Enumeration<String> +/* */ // 766 15 5 f File +/* */ // 203 45 6 obj Object +/* */ // 260 3 6 obj Object +/* */ // 610 74 6 e CacheEntry +/* */ // 413 33 7 localObject1 Object +/* */ // 627 71 7 name String +/* */ // 300 1 8 localException1 Exception +/* */ // 315 1 8 localException2 Exception +/* */ // 391 1 8 localException3 Exception +/* */ // 406 1 8 localException4 Exception +/* */ // 426 1 8 localException5 Exception +/* */ // 441 1 8 localException6 Exception +/* */ // 459 1 8 localException7 Exception +/* */ // 474 1 8 localException8 Exception +/* */ // 644 45 8 isFile boolean +/* */ // Exception table: +/* */ // from to target type +/* */ // 20 285 288 java/io/OptionalDataException +/* */ // 293 297 300 java/lang/Exception +/* */ // 308 312 315 java/lang/Exception +/* */ // 20 285 322 java/lang/Exception +/* */ // 384 388 391 java/lang/Exception +/* */ // 399 403 406 java/lang/Exception +/* */ // 20 289 413 finally +/* */ // 322 380 413 finally +/* */ // 419 423 426 java/lang/Exception +/* */ // 434 438 441 java/lang/Exception +/* */ // 452 456 459 java/lang/Exception +/* */ // 467 471 474 java/lang/Exception +/* */ } +/* */ +/* */ public static CacheFile getFile(URL url, boolean forceRecheck) +/* */ { +/* 287 */ return cache.getAFile(url, forceRecheck); +/* */ } +/* */ +/* */ public static CacheFile getFile(URL url) { +/* 291 */ return cache.getAFile(url, false); +/* */ } +/* */ +/* */ public static CacheFile getFile(String url) { +/* 295 */ return cache.getAFile(URL.make(url), false); +/* */ } +/* */ +/* */ public static CacheEntry getEntry(URL url) { +/* 299 */ return cache.get(url); +/* */ } +/* */ +/* */ public static void removeEntry(CacheEntry ce) { +/* 303 */ cache.remove(ce); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public static void InjectZipFile(File zipFile, String urlPrefix) +/* */ { +/* 313 */ long timeStamp = zipFile.lastModified(); +/* */ try +/* */ { +/* 316 */ ZipFile zf = new ZipFile(zipFile); +/* 317 */ System.out.println("Adding " + zf.size() + " entries from " + +/* 318 */ zipFile); +/* 319 */ Enumeration<?> e = zf.entries(); +/* 320 */ InputStream is; while (e.hasMoreElements()) { +/* 321 */ ZipEntry ze = (ZipEntry)e.nextElement(); +/* 322 */ is = zf.getInputStream(ze); +/* 323 */ URL remoteName = URL.make(urlPrefix + ze.getName()); +/* */ +/* */ +/* 326 */ CacheEntry ce = cache.get(remoteName); +/* 327 */ if (ce == null) +/* */ { +/* 329 */ String localName = assignLocalName(remoteName); +/* 330 */ FileOutputStream fos = new FileOutputStream(localName); +/* 331 */ byte[] buffer = new byte['က']; +/* */ try { +/* */ for (;;) { +/* 334 */ int bytesRead = is.read(buffer); +/* 335 */ if (bytesRead == -1) { +/* */ break; +/* */ } +/* 338 */ fos.write(buffer, 0, bytesRead); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* 354 */ is.close(); +/* */ } +/* */ catch (IOException localIOException) +/* */ { +/* 343 */ fos.close(); +/* */ +/* */ +/* 346 */ ce = new CacheEntry(); +/* 347 */ ce.localName = new String(localName); +/* 348 */ ce.url = remoteName; +/* 349 */ ce.state = 4; +/* 350 */ ce.remoteTime = timeStamp; +/* 351 */ ce.checkTime = new Date(); +/* 352 */ cache.add(ce); +/* */ } +/* */ } +/* */ } +/* */ +/* 357 */ zf.close(); +/* */ +/* */ } +/* */ catch (Exception e) +/* */ { +/* */ +/* 363 */ System.out.println("Error processing cache zip file: " + e); +/* */ } +/* */ } +/* */ +/* */ private synchronized CacheFile getAFile(URL url, boolean forceRecheck) { +/* 368 */ CacheEntry e = null; +/* */ +/* */ +/* */ +/* 372 */ if (url.isRemote()) +/* */ { +/* 374 */ e = cache.get(url); +/* 375 */ if (e == null) +/* */ { +/* */ +/* 378 */ e = new CacheEntry(url); +/* 379 */ cache.add(e); +/* 380 */ } else if (forceRecheck) { +/* 381 */ e.forceRecheck(); +/* */ } +/* */ } +/* 384 */ return new CacheFile(url, e); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void mainCallback() {} +/* */ +/* */ +/* */ +/* */ +/* */ public synchronized void resyncIndex() +/* */ { +/* 398 */ if ((this.hasChanged >= CACHE_MIN_CHANGE) || (this.lastCacheSave.before(new Date(new Date().getTime() - CACHE_MAX_DELAY)))) { +/* 399 */ saveIndex(); +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ public void saveIndex() +/* */ { +/* */ try +/* */ { +/* 409 */ System.out.println("Marking cache as open..."); +/* */ +/* */ +/* */ +/* 413 */ File fin = new File(CACHE_DIR + "cache.index.new"); +/* 414 */ FileOutputStream o = new FileOutputStream(fin); +/* 415 */ ObjectOutputStream s = new ObjectOutputStream(o); +/* 416 */ s.writeLong(0L); +/* 417 */ s.writeObject(this); +/* */ +/* */ +/* */ +/* 421 */ for (CacheEntry e = this.terminator.next; e != this.terminator; e = e.next) { +/* 422 */ if ((e.url != null) && (e.localName != null)) { +/* 423 */ s.writeObject(e); +/* */ } +/* */ } +/* */ +/* */ +/* 428 */ s.writeInt(0); +/* */ +/* 430 */ s.flush(); +/* 431 */ s.close(); +/* 432 */ o.close(); +/* 433 */ this.lastCacheSave = new Date(); +/* 434 */ this.hasChanged = 0; +/* */ +/* 436 */ System.out.println("Marking cache as closed..."); +/* 437 */ File fi = new File(CACHE_DIR + "cache.index"); +/* 438 */ File fio = new File(CACHE_DIR + "cache.index.old"); +/* 439 */ fi.renameTo(fio); +/* 440 */ fin.renameTo(fi); +/* 441 */ fio.delete(); +/* */ } +/* */ catch (Exception e) { +/* 444 */ System.out.println("Error writing cache index: " + e); +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ public synchronized void terminalCallback() +/* */ { +/* 453 */ Main.unregister(this); +/* */ +/* 455 */ saveIndex(); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ static String assignLocalName(URL url) +/* */ { +/* 466 */ String remoteName = url.unalias(); +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* 473 */ String ext = ".temp"; +/* 474 */ int lastDot = remoteName.lastIndexOf('.'); +/* 475 */ if ((lastDot > remoteName.lastIndexOf('/')) && +/* 476 */ (remoteName.indexOf("?", lastDot) < 0) && +/* 477 */ (remoteName.indexOf("#", lastDot) < 0)) { +/* 478 */ ext = remoteName.substring(lastDot); +/* */ } +/* */ +/* */ +/* 482 */ if (url.endsWith(".gr2")) { +/* 483 */ return CACHE_DIR + url.getBase(); +/* */ } +/* 485 */ return CACHE_DIR + Integer.toString(cache.nextAvailable++, 36) + ext; +/* */ } +/* */ +/* */ public synchronized void add(CacheEntry e) +/* */ { +/* 490 */ this.table.put(e.url, e); +/* 491 */ CacheEntry p = this.terminator.prev; +/* 492 */ p.next = e; +/* 493 */ e.prev = p; +/* 494 */ e.next = this.terminator; +/* 495 */ this.terminator.prev = e; +/* 496 */ this.hasChanged += 1; +/* */ } +/* */ +/* */ public int numEntries() +/* */ { +/* 501 */ return this.table.size(); +/* */ } +/* */ +/* */ +/* */ public synchronized CacheEntry get(URL url) +/* */ { +/* 507 */ CacheEntry e = (CacheEntry)this.table.get(url); +/* */ +/* */ +/* 510 */ if (e != null) { +/* 511 */ markUsed(e); +/* */ } +/* */ +/* 514 */ return e; +/* */ } +/* */ +/* */ +/* */ private void markUsed(CacheEntry e) +/* */ { +/* 520 */ if ((e == null) || (e.next == this.terminator)) +/* */ { +/* 522 */ return; +/* */ } +/* 524 */ e.prev.next = e.next; +/* 525 */ e.next.prev = e.prev; +/* 526 */ this.terminator.prev.next = e; +/* 527 */ e.prev = this.terminator.prev; +/* 528 */ e.next = this.terminator; +/* 529 */ this.terminator.prev = e; +/* */ } +/* */ +/* */ +/* */ public void remove(CacheEntry e) +/* */ { +/* 535 */ this.totalBytes -= e.bytes; +/* 536 */ e.prev.next = e.next; +/* 537 */ e.next.prev = e.prev; +/* 538 */ e.prev = null; +/* 539 */ e.next = null; +/* 540 */ this.table.remove(e.url); +/* 541 */ this.hasChanged += 1; +/* */ +/* 543 */ new File(e.localName.toUpperCase()).delete(); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ private CacheEntry freeLRU() +/* */ { +/* 554 */ for (CacheEntry e = this.terminator.next; e != this.terminator; e = e.next) { +/* 555 */ if (!e.inUse()) { +/* 556 */ remove(e); +/* 557 */ return e; +/* */ } +/* */ } +/* 560 */ return null; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public synchronized void makeSpaceFor(int incomingSize) +/* */ { +/* 570 */ while (cache.numEntries() > CacheEntry.CACHE_MAX_ENTRIES) { +/* 571 */ if (freeLRU() == null) { +/* */ break; +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* 580 */ while ((this.totalBytes + 2L * incomingSize) / 1024L > +/* 581 */ Std.GetDiskFreeSpace()) +/* */ { +/* 583 */ if (Std.GetDiskFreeSpace() <= -1L) { +/* */ break; +/* */ } +/* */ +/* 587 */ CacheEntry freed = freeLRU(); +/* 588 */ if (freed == null) { +/* */ break; +/* */ } +/* */ } +/* */ } +/* */ } + + +/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\network\Cache.class + * Java compiler version: 6 (50.0) + * JD-Core Version: 0.7.1 + */
\ No newline at end of file |