org.eclipse.osgi_3.8.2.v20130124-134944

  return lastGenerations;
          }
        }
      }
    }
    int[] generations = null;
    try
    {
      String name = file.getName();
      String prefix = name + '.';
      int prefixLen = prefix.length();
      File parent = new File(file.getParent());
      String[] files = parent.list();
      if (files == null) {
        return null;
      }
      String[] files;
      File parent;
      int prefixLen;
      String prefix;
      String name;
      List<Integer> list = new ArrayList(defaultMaxGenerations);
      if (file.exists()) {
        list.add(new Integer(0));
      }
      for (int i = 0; i < files.length; i++) {
        if (files[i].startsWith(prefix)) {
          try
          {
            int id = Integer.parseInt(files[i].substring(prefixLen));
            list.add(new Integer(id));
          }
          catch (NumberFormatException localNumberFormatException) {}
        }
      }
      if (list.size() == 0) {
        return null;
      }
      List<Integer> list;
      String[] files;
      File parent;
      int prefixLen;
      String prefix;
      String name;
      Object[] array = list.toArray();
      Arrays.sort(array);
      generations = new int[array.length];
      int i = 0;
      for (int j = array.length - 1; i < array.length; j--)
      {
        generations[i] = ((Integer)array[j]).intValue();i++;
      }
      return generations;
    }
    finally
    {
      if (!fileSharing) {
        synchronized (lastGenerationLock)
        {
          lastGenerationFile = file;
          lastGenerations = generations;
        }
      }
    }
  }
  
  /* Error */
  InputStream getInputStream(int generation, int openMask)
    throws IOException
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 417	org/eclipse/osgi/framework/internal/reliablefile/ReliableFile:inputFile	Ljava/io/File;
    //   4: ifnull +13 -> 17
    //   7: new 249	java/io/IOException
    //   10: dup
    //   11: ldc 4
    //   13: invokespecial 445	java/io/IOException:<init>	(Ljava/lang/String;)V
    //   16: athrow
    //   17: aload_0
    //   18: getfield 420	org/eclipse/osgi/framework/internal/reliablefile/ReliableFile:referenceFile	Ljava/io/File;
    //   21: invokestatic 488	org/eclipse/osgi/framework/internal/reliablefile/ReliableFile:getFileGenerations	(Ljava/io/File;)[I
    //   24: astore_3
    //   25: aload_3
    //   26: ifnonnull +13 -> 39
    //   29: new 247	java/io/FileNotFoundException
    //   32: dup
    //   33: ldc 3
    //   35: invokespecial 443	java/io/FileNotFoundException:<init>	(Ljava/lang/String;)V
    //   38: athrow
    //   39: aload_0
    //   40: getfield 420	org/eclipse/osgi/framework/internal/reliablefile/ReliableFile:referenceFile	Ljava/io/File;
    //   43: invokevirtual 436	java/io/File:getName	()Ljava/lang/String;
    //   46: astore 4
    //   48: new 245	java/io/File
    //   51: dup
    //   52: aload_0
    //   53: getfield 420	org/eclipse/osgi/framework/internal/reliablefile/ReliableFile:referenceFile	Ljava/io/File;
    //   56: invokevirtual 437	java/io/File:getParent	()Ljava/lang/String;
    //   59: invokespecial 439	java/io/File:<init>	(Ljava/lang/String;)V
    //   62: astore 5
    //   64: iload_2
    //   65: iconst_1
    //   66: iand
    //   67: ifeq +7 -> 74
    //   70: iconst_1
    //   71: goto +4 -> 75
    //   74: iconst_0
    //   75: istore 6
    //   77: iload 6
    //   79: ifeq +11 -> 90
    //   82: iload_1
    //   83: ifne +7 -> 90
    //   86: aload_3
    //   87: iconst_0
    //   88: iaload
    //   89: istore_1
    //   90: aconst_null
    //   91: astore 7
    //   93: aconst_null
    //   94: astore 8
    //   96: iconst_0
    //   97: istore 9
    //   99: goto +421 -> 520
    //   102: iload_1
    //   103: ifeq +27 -> 130
    //   106: aload_3
    //   107: iload 9
    //   109: iaload
    //   110: iload_1
    //   111: if_icmpgt +406 -> 517
    //   114: iload 6
    //   116: ifeq +14 -> 130
    //   119: aload_3
    //   120: iload 9
    //   122: iaload
    //   123: iload_1
    //   124: if_icmpeq +6 -> 130
    //   127: goto +390 -> 517
    //   130: aload_3
    //   131: iload 9
    //   133: iaload
    //   134: ifeq +44 -> 178
    //   137: new 245	java/io/File
    //   140: dup
    //   141: aload 5
    //   143: new 258	java/lang/StringBuffer
    //   146: dup
    //   147: aload 4
    //   149: invokestatic 469	java/lang/String:valueOf	(Ljava/lang/Object;)Ljava/lang/String;
    //   152: invokespecial 471	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   155: bipush 46
    //   157: invokevirtual 472	java/lang/StringBuffer:append	(C)Ljava/lang/StringBuffer;
    //   160: aload_3
    //   161: iload 9
    //   163: iaload
    //   164: invokevirtual 473	java/lang/StringBuffer:append	(I)Ljava/lang/StringBuffer;
    //   167: invokevirtual 470	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   170: invokespecial 440	java/io/File:<init>	(Ljava/io/File;Ljava/lang/String;)V
    //   173: astore 10
    //   175: goto +9 -> 184
    //   178: aload_0
    //   179: getfield 420	org/eclipse/osgi/framework/internal/reliablefile/ReliableFile:referenceFile	Ljava/io/File;
    //   182: astore 10
    //   184: aconst_null
    //   185: astore 11
    //   187: getstatic 422	org/eclipse/osgi/framework/internal/reliablefile/ReliableFile:cacheFiles	Ljava/util/Hashtable;
    //   190: dup
    //   191: astore 13
    //   193: monitorenter
    //   194: getstatic 422	org/eclipse/osgi/framework/internal/reliablefile/ReliableFile:cacheFiles	Ljava/util/Hashtable;
    //   197: aload 10
    //   199: invokevirtual 479	java/util/Hashtable:get	(Ljava/lang/Object;)Ljava/lang/Object;
    //   202: checkcast 270	org/eclipse/osgi/framework/internal/reliablefile/ReliableFile$CacheInfo
    //   205: astore 12
    //   207: aload 10
    //   209: invokevirtual 429	java/io/File:lastModified	()J
    //   212: lstore 14
    //   214: aload 12
    //   216: ifnull +14 -> 230
    //   219: lload 14
    //   221: aload 12
    //   223: getfield 426	org/eclipse/osgi/framework/internal/reliablefile/ReliableFile$CacheInfo:timeStamp	J
    //   226: lcmp
    //   227: ifeq +150 -> 377
    //   230: new 246	java/io/FileInputStream
    //   233: dup
    //   234: aload 10
    //   236: invokespecial 442	java/io/FileInputStream:<init>	(Ljava/io/File;)V
    //   239: astore 16
    //   241: aload 10
    //   243: invokevirtual 430	java/io/File:length	()J
    //   246: lstore 17
    //   248: lload 17
    //   250: getstatic 412	org/eclipse/osgi/framework/internal/reliablefile/ReliableFile:maxInputStreamBuffer	I
    //   253: i2l
    //   254: lcmp
    //   255: ifge +21 -> 276
    //   258: new 244	java/io/BufferedInputStream
    //   261: dup
    //   262: aload 16
    //   264: lload 17
    //   266: l2i
    //   267: invokespecial 428	java/io/BufferedInputStream:<init>	(Ljava/io/InputStream;I)V
    //   270: astore 16
    //   272: aload 16
    //   274: astore 11
    //   276: aload_0
    //   277: invokevirtual 490	org/eclipse/osgi/framework/internal/reliablefile/ReliableFile:getChecksumCalculator	()Ljava/util/zip/Checksum;
    //   280: astore 19
    //   282: aload_0
    //   283: aload 16
    //   285: aload 19
    //   287: lload 17
    //   289: invokespecial 493	org/eclipse/osgi/framework/internal/reliablefile/ReliableFile:getStreamType	(Ljava/io/InputStream;Ljava/util/zip/Checksum;J)I
    //   292: istore 20
    //   294: new 270	org/eclipse/osgi/framework/internal/reliablefile/ReliableFile$CacheInfo
    //   297: dup
    //   298: aload_0
    //   299: iload 20
    //   301: aload 19
    //   303: lload 14
    //   305: lload 17
    //   307: invokespecial 495	org/eclipse/osgi/framework/internal/reliablefile/ReliableFile$CacheInfo:<init>	(Lorg/eclipse/osgi/framework/internal/reliablefile/ReliableFile;ILjava/util/zip/Checksum;JJ)V
    //   310: astore 12
    //   312: getstatic 422	org/eclipse/osgi/framework/internal/reliablefile/ReliableFile:cacheFiles	Ljava/util/Hashtable;
    //   315: aload 10
    //   317: aload 12
    //   319: invokevirtual 481	java/util/Hashtable:put	(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    //   322: pop
    //   323: goto +40 -> 363
    //   326: pop
    //   327: aload 11
    //   329: ifnonnull +48 -> 377
    //   332: aload 16
    //   334: invokevirtual 446	java/io/InputStream:close	()V
    //   337: goto +40 -> 377
    //   340: pop
    //   341: goto +36 -> 377
    //   344: astore 21
    //   346: aload 11
    //   348: ifnonnull +12 -> 360
    //   351: aload 16
    //   353: invokevirtual 446	java/io/InputStream:close	()V
    //   356: goto +4 -> 360
    //   359: pop
    //   360: aload 21
    //   362: athrow
    //   363: aload 11
    //   365: ifnonnull +12 -> 377
    //   368: aload 16
    //   370: invokevirtual 446	java/io/InputStream:close	()V
    //   373: goto +4 -> 377
    //   376: pop
    //   377: aload 13
    //   379: monitorexit
    //   380: goto +7 -> 387
    //   383: aload 13
    //   385: monitorexit
    //   386: athrow
    //   387: iload 6
    //   389: ifeq +51 -> 440
    //   392: aload 12
    //   394: ifnull +35 -> 429
    //   397: aload 12
    //   399: getfield 424	org/eclipse/osgi/framework/internal/reliablefile/ReliableFile$CacheInfo:filetype	I
    //   402: ifne +27 -> 429
    //   405: aload_0
    //   406: aload 10
    //   408: putfield 417	org/eclipse/osgi/framework/internal/reliablefile/ReliableFile:inputFile	Ljava/io/File;
    //   411: aload 11
    //   413: ifnull +6 -> 419
    //   416: aload 11
    //   418: areturn
    //   419: new 246	java/io/FileInputStream
    //   422: dup
    //   423: aload 10
    //   425: invokespecial 442	java/io/FileInputStream:<init>	(Ljava/io/File;)V
    //   428: areturn
    //   429: new 249	java/io/IOException
    //   432: dup
    //   433: ldc_w 238
    //   436: invokespecial 445	java/io/IOException:<init>	(Ljava/lang/String;)V
    //   439: athrow
    //   440: aload 12
    //   442: ifnonnull +6 -> 448
    //   445: goto +72 -> 517
    //   448: aload 12
    //   450: getfield 424	org/eclipse/osgi/framework/internal/reliablefile/ReliableFile$CacheInfo:filetype	I
    //   453: tableswitch	default:+64->517, 0:+27->480, 1:+64->517, 2:+51->504
    //   480: aload_0
    //   481: aload 10
    //   483: putfield 417	org/eclipse/osgi/framework/internal/reliablefile/ReliableFile:inputFile	Ljava/io/File;
    //   486: aload 11
    //   488: ifnull +6 -> 494
    //   491: aload 11
    //   493: areturn
    //   494: new 246	java/io/FileInputStream
    //   497: dup
    //   498: aload 10
    //   500: invokespecial 442	java/io/FileInputStream:<init>	(Ljava/io/File;)V
    //   503: areturn
    //   504: aload 7
    //   506: ifnonnull +11 -> 517
    //   509: aload 10
    //   511: astore 7
    //   513: aload 11
    //   515: astore 8
    //   517: iinc 9 1
    //   520: iload 9
    //   522: aload_3
    //   523: arraylength
    //   524: if_icmplt -422 -> 102
    //   527: aload 7
    //   529: ifnull +27 -> 556
    //   532: aload_0
    //   533: aload 7
    //   535: putfield 417	org/eclipse/osgi/framework/internal/reliablefile/ReliableFile:inputFile	Ljava/io/File;
    //   538: aload 8
    //   540: ifnull +6 -> 546
    //   543: aload 8
    //   545: areturn
    //   546: new 246	java/io/FileInputStream
    //   549: dup
    //   550: aload 7
    //   552: invokespecial 442	java/io/FileInputStream:<init>	(Ljava/io/File;)V
    //   555: areturn
    //   556: new 249	java/io/IOException
    //   559: dup
    //   560: ldc_w 238
    //   563: invokespecial 445	java/io/IOException:<init>	(Ljava/lang/String;)V
    //   566: athrow
    // Line number table:
    //   Java source line #237	-> byte code offset #0
    //   Java source line #238	-> byte code offset #7
    //   Java source line #240	-> byte code offset #17
    //   Java source line #241	-> byte code offset #25
    //   Java source line #242	-> byte code offset #29
    //   Java source line #244	-> byte code offset #39
    //   Java source line #245	-> byte code offset #48
    //   Java source line #247	-> byte code offset #64
    //   Java source line #248	-> byte code offset #77
    //   Java source line #249	-> byte code offset #86
    //   Java source line #251	-> byte code offset #90
    //   Java source line #252	-> byte code offset #93
    //   Java source line #253	-> byte code offset #96
    //   Java source line #254	-> byte code offset #102
    //   Java source line #255	-> byte code offset #106
    //   Java source line #256	-> byte code offset #127
    //   Java source line #259	-> byte code offset #130
    //   Java source line #260	-> byte code offset #137
    //   Java source line #262	-> byte code offset #178
    //   Java source line #263	-> byte code offset #184
    //   Java source line #265	-> byte code offset #187
    //   Java source line #266	-> byte code offset #194
    //   Java source line #267	-> byte code offset #207
    //   Java source line #268	-> byte code offset #214
    //   Java source line #269	-> byte code offset #230
    //   Java source line #271	-> byte code offset #241
    //   Java source line #272	-> byte code offset #248
    //   Java source line #273	-> byte code offset #258
    //   Java source line #275	-> byte code offset #272
    //   Java source line #277	-> byte code offset #276
    //   Java source line #278	-> byte code offset #282
    //   Java source line #279	-> byte code offset #294
    //   Java source line #280	-> byte code offset #312
    //   Java source line #281	-> byte code offset #323
    //   Java source line #283	-> byte code offset #327
    //   Java source line #286	-> byte code offset #332
    //   Java source line #287	-> byte code offset #337
    //   Java source line #282	-> byte code offset #344
    //   Java source line #283	-> byte code offset #346
    //   Java source line #286	-> byte code offset #351
    //   Java source line #287	-> byte code offset #356
    //   Java source line #290	-> byte code offset #360
    //   Java source line #283	-> byte code offset #363
    //   Java source line #286	-> byte code offset #368
    //   Java source line #287	-> byte code offset #373
    //   Java source line #265	-> byte code offset #377
    //   Java source line #296	-> byte code offset #387
    //   Java source line #297	-> byte code offset #392
    //   Java source line #298	-> byte code offset #405
    //   Java source line #299	-> byte code offset #411
    //   Java source line #300	-> byte code offset #416
    //   Java source line #301	-> byte code offset #419
    //   Java source line #303	-> byte code offset #429
    //   Java source line #307	-> byte code offset #440
    //   Java source line #308	-> byte code offset #445
    //   Java source line #311	-> byte code offset #448
    //   Java source line #313	-> byte code offset #480
    //   Java source line #314	-> byte code offset #486
    //   Java source line #315	-> byte code offset #491
    //   Java source line #316	-> byte code offset #494
    //   Java source line #319	-> byte code offset #504
    //   Java source line #320	-> byte code offset #509
    //   Java source line #321	-> byte code offset #513
    //   Java source line #253	-> byte code offset #517
    //   Java source line #329	-> byte code offset #527
    //   Java source line #330	-> byte code offset #532
    //   Java source line #331	-> byte code offset #538
    //   Java source line #332	-> byte code offset #543
    //   Java source line #333	-> byte code offset #546
    //   Java source line #335	-> byte code offset #556
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	567	0	this	ReliableFile
    //   0	567	1	generation	int
    //   0	567	2	openMask	int
    //   24	499	3	generations	int[]
    //   46	102	4	name	String
    //   62	80	5	parent	File
    //   75	313	6	failOnPrimary	boolean
    //   91	460	7	textFile	File
    //   94	450	8	textIS	InputStream
    //   97	424	9	idx	int
    //   173	3	10	file	File
    //   182	328	10	file	File
    //   185	329	11	is	InputStream
    //   205	113	12	info	CacheInfo
    //   387	62	12	info	CacheInfo
    //   191	193	13	Ljava/lang/Object;	Object
    //   212	92	14	timeStamp	long
    //   239	130	16	tempIS	InputStream
    //   246	60	17	fileSize	long
    //   280	22	19	cksum	Checksum
    //   292	8	20	filetype	int
    //   344	17	21	localObject1	Object
    //   326	1	22	localIOException1	IOException
    //   340	1	23	localIOException2	IOException
    //   359	1	24	localIOException3	IOException
    //   376	1	25	localIOException4	IOException
    // Exception table:
    //   from	to	target	type
    //   241	323	326	java/io/IOException
    //   332	337	340	java/io/IOException
    //   241	327	344	finally
    //   351	356	359	java/io/IOException
    //   368	373	376	java/io/IOException
    //   194	380	383	finally
    //   383	386	383	finally
  }
  
  OutputStream getOutputStream(boolean append, int appendGeneration)
    throws IOException
  {
    if (outputFile != null) {
      throw new IOException("Output stream is already open");
    }
    String name = referenceFile.getName();
    File parent = new File(referenceFile.getParent());
    File tmpFile = File.createTempFile(name, ".tmp", parent);
    if (!append)
    {
      OutputStream os = new FileOutputStream(tmpFile);
      outputFile = tmpFile;
      return os;
    }
    try
    {
      is = getInputStream(appendGeneration, 0);
    }
    catch (FileNotFoundException localFileNotFoundException)
    {
      InputStream is;
      OutputStream os = new FileOutputStream(tmpFile);
      outputFile = tmpFile;
      return os;
    }
    try
    {
      InputStream is;
      CacheInfo info = (CacheInfo)cacheFiles.get(inputFile);
      appendChecksum = checksum;
      OutputStream os = new FileOutputStream(tmpFile);
      if (filetype == 2) {
        cp(is, os, 0, length);
      } else {
        cp(is, os, 16, length);
      }
      outputFile = tmpFile;
      return os;
    }
    finally
    {
      closeInputFile();
    }
  }
  
  void closeOutputFile(Checksum checksum)
    throws IOException
  {
    if (outputFile == null) {
      throw new IOException("Output stream is not open");
    }
    int[] generations = getFileGenerations(referenceFile);
    String name = referenceFile.getName();
    File parent = new File(referenceFile.getParent());
    File newFile;
    File newFile;
    if (generations == null) {
      newFile = new File(parent, name + ".1");
    } else {
      newFile = new File(parent, name + '.' + (generations[0] + 1));
    }
    mv(outputFile, newFile);
    outputFile = null;
    appendChecksum = null;
    CacheInfo info = new CacheInfo(0, checksum, newFile.lastModified(), newFile.length());
    cacheFiles.put(newFile, info);
    cleanup(generations, true);
    lastGenerationFile = null;
    lastGenerations = null;
  }
  
  void abortOutputFile()
  {
    if (outputFile == null) {
      return;
    }
    outputFile.delete();
    outputFile = null;
    appendChecksum = null;
  }
  
  File getOutputFile()
  {
    return outputFile;
  }
  
  void closeInputFile()
  {
    inputFile = null;
  }
  
  private void cleanup(int[] generations, boolean generationAdded)
  {
    if (generations == null) {
      return;
    }
    String name = referenceFile.getName();
    File parent = new File(referenceFile.getParent());
    int generationCount = generations.length;
    if (generations[(generationCount - 1)] == 0) {
      generationCount--;
    }
    int rmCount = generationCount - defaultMaxGenerations;
    if (generationAdded) {
      rmCount++;
    }
    if (rmCount < 1) {
      return;
    }
    synchronized (cacheFiles)
    {
      int idx = 0;
      for (int count = generationCount - rmCount; idx < count; idx++)
      {
        File file = new File(parent, name + '.' + generations[idx]);
        CacheInfo info = (CacheInfo)cacheFiles.get(file);
        if ((info != null) && 
          (filetype == 1)) {
          rmCount--;
        }
      }
      for (int idx = generationCount - 1; rmCount > 0; rmCount--)
      {
        File rmFile = new File(parent, name + '.' + generations[idx]);
        rmFile.delete();
        cacheFiles.remove(rmFile);idx--;
      }
    }
  }
  
  private static void mv(File from, File to)
    throws IOException
  {
    if (!from.renameTo(to)) {
      throw new IOException("rename failed");
    }
  }
  
  /* Error */
  private static void cp(InputStream in, OutputStream out, int truncateSize, long length)
    throws IOException
  {
    // Byte code:
    //   0: iload_2
    //   1: i2l
    //   2: lload_3
    //   3: lcmp
    //   4: ifle +8 -> 12
    //   7: lconst_0
    //   8: lstore_3
    //   9: goto +8 -> 17
    //   12: lload_3
    //   13: iload_2
    //   14: i2l
    //   15: lsub
    //   16: lstore_3
    //   17: lload_3
    //   18: lconst_0
    //   19: lcmp
    //   20: ifle +105 -> 125
    //   23: lload_3
    //   24: ldc2_w 229
    //   27: lcmp
    //   28: ifle +11 -> 39
    //   31: sipush 4096
    //   34: istore 5
    //   36: goto +7 -> 43
    //   39: lload_3
    //   40: l2i
    //   41: istore 5
    //   43: iload 5
    //   45: newarray <illegal type>
    //   47: astore 6
    //   49: lconst_0
    //   50: lstore 7
    //   52: goto +38 -> 90
    //   55: lload 7
    //   57: iload 9
    //   59: i2l
    //   60: ladd
    //   61: lload_3
    //   62: lcmp
    //   63: iflt +10 -> 73
    //   66: lload_3
    //   67: lload 7
    //   69: lsub
    //   70: l2i
    //   71: istore 9
    //   73: aload_1
    //   74: aload 6
    //   76: iconst_0
    //   77: iload 9
    //   79: invokevirtual 454	java/io/OutputStream:write	([BII)V
    //   82: lload 7
    //   84: iload 9
    //   86: i2l
    //   87: ladd
    //   88: lstore 7
    //   90: aload_0
    //   91: aload 6
    //   93: iconst_0
    //   94: iload 5
    //   96: invokevirtual 451	java/io/InputStream:read	([BII)I
    //   99: dup
    //   100: istore 9
    //   102: ifgt -47 -> 55
    //   105: goto +20 -> 125
    //   108: astore 10
    //   110: aload_0
    //   111: invokevirtual 446	java/io/InputStream:close	()V
    //   114: goto +4 -> 118
    //   117: pop
    //   118: aload_1
    //   119: invokevirtual 452	java/io/OutputStream:close	()V
    //   122: aload 10
    //   124: athrow
    //   125: aload_0
    //   126: invokevirtual 446	java/io/InputStream:close	()V
    //   129: goto +4 -> 133
    //   132: pop
    //   133: aload_1
    //   134: invokevirtual 452	java/io/OutputStream:close	()V
    //   137: return
    // Line number table:
    //   Java source line #492	-> byte code offset #0
    //   Java source line #493	-> byte code offset #7
    //   Java source line #495	-> byte code offset #12
    //   Java source line #496	-> byte code offset #17
    //   Java source line #498	-> byte code offset #23
    //   Java source line #499	-> byte code offset #31
    //   Java source line #500	-> byte code offset #36
    //   Java source line #501	-> byte code offset #39
    //   Java source line #504	-> byte code offset #43
    //   Java source line #505	-> byte code offset #49
    //   Java source line #507	-> byte code offset #52
    //   Java source line #508	-> byte code offset #55
    //   Java source line #509	-> byte code offset #66
    //   Java source line #510	-> byte code offset #73
    //   Java source line #511	-> byte code offset #82
    //   Java source line #507	-> byte code offset #90
    //   Java source line #514	-> byte code offset #105
    //   Java source line #516	-> byte code offset #110
    //   Java source line #517	-> byte code offset #114
    //   Java source line #519	-> byte code offset #118
    //   Java source line #520	-> byte code offset #122
    //   Java source line #516	-> byte code offset #125
    //   Java source line #517	-> byte code offset #129
    //   Java source line #519	-> byte code offset #133
    //   Java source line #521	-> byte code offset #137
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	138	0	in	InputStream
    //   0	138	1	out	OutputStream
    //   0	138	2	truncateSize	int
    //   0	138	3	length	long
    //   34	3	5	bufferSize	int
    //   41	54	5	bufferSize	int
    //   47	45	6	buffer	byte[]
    //   50	39	7	size	long
    //   55	30	9	count	int
    //   100	3	9	count	int
    //   108	15	10	localObject	Object
    //   117	1	11	localIOException1	IOException
    //   132	1	12	localIOException2	IOException
    // Exception table:
    //   from	to	target	type
    //   0	108	108	finally
    //   110	114	117	java/io/IOException
    //   125	129	132	java/io/IOException
  }
  
  public static boolean exists(File file)
  {
    String prefix = file.getName() + '.';
    File parent = new File(file.getParent());
    int prefixLen = prefix.length();
    String[] files = parent.list();
    if (files == null) {
      return false;
    }
    for (int i = 0; i < files.length; i++) {
      if (files[i].startsWith(prefix)) {
        try
        {
          Integer.parseInt(files[i].substring(prefixLen));
          return true;
        }
        catch (NumberFormatException localNumberFormatException) {}
      }
    }
    return file.exists();
  }
  
  public static long lastModified(File file)
  {
    int[] generations = getFileGenerations(file);
    if (generations == null) {
      return 0L;
    }
    if (generations[0] == 0) {
      return file.lastModified();
    }
    String name = file.getName();
    File parent = new File(file.getParent());
    File newFile = new File(parent, name + '.' + generations[0]);
    return newFile.lastModified();
  }
  
  public long lastModified()
  {
    if (inputFile != null) {
      return inputFile.lastModified();
    }
    return 0L;
  }
  
  public static int lastModifiedVersion(File file)
  {
    int[] generations = getFileGenerations(file);
    if (generations == null) {
      return -1;
    }
    return generations[0];
  }
  
  public static boolean delete(File deleteFile)
  {
    int[] generations = getFileGenerations(deleteFile);
    if (generations == null) {
      return false;
    }
    String name = deleteFile.getName();
    File parent = new File(deleteFile.getParent());
    synchronized (cacheFiles)
    {
      for (int idx = 0; idx < generations.length; idx++) {
        if (generations[idx] != 0)
        {
          File file = new File(parent, name + '.' + generations[idx]);
          if (file.exists()) {
            file.delete();
          }
          cacheFiles.remove(file);
        }
      }
    }
    return true;
  }
  
  public static String[] getBaseFiles(File directory)
    throws IOException
  {
    if (!directory.isDirectory()) {
      throw new IOException("Not a valid directory");
    }
    String[] files = directory.list();
    Set<String> list = new HashSet(files.length / 2);
    for (int idx = 0; idx < files.length; idx++)
    {
      String file = files[idx];
      int pos = file.lastIndexOf('.');
      if (pos != -1)
      {
        String ext = file.substring(pos + 1);
        int generation = 0;
        try
        {
          generation = Integer.parseInt(ext);
        }
        catch (NumberFormatException localNumberFormatException) {}
        if (generation != 0)
        {
          String base = file.substring(0, pos);
          list.add(base);
        }
      }
    }
    files = new String[list.size()];
    int idx = 0;
    for (Iterator<String> iter = list.iterator(); iter.hasNext();) {
      files[(idx++)] = ((String)iter.next());
    }
    return files;
  }
  
  public static void cleanupGenerations(File base)
  {
    ReliableFile rf = new ReliableFile(base);
    int[] generations = getFileGenerations(base);
    rf.cleanup(generations, false);
    lastGenerationFile = null;
    lastGenerations = null;
  }
  
  public static void fileUpdated(File file)
  {
    lastGenerationFile = null;
    lastGenerations = null;
  }
  
  void writeChecksumSignature(OutputStream out, Checksum checksum)
    throws IOException
  {
    out.write(identifier1);
    out.write(intToHex((int)checksum.getValue()));
    out.write(identifier2);
  }
  
  int getSignatureSize()
    throws IOException
  {
    if (inputFile != null)
    {
      CacheInfo info = (CacheInfo)cacheFiles.get(inputFile);
      if (info != null) {
        switch (filetype)
        {
        case 0: 
        case 1: 
          return 16;
        case 2: 
          return 0;
        }
      }
    }
    throw new IOException("ReliableFile signature size is unknown");
  }
  
  long getInputLength()
    throws IOException
  {
    if (inputFile != null)
    {
      CacheInfo info = (CacheInfo)cacheFiles.get(inputFile);
      if (info != null) {
        return length;
      }
    }
    throw new IOException("ReliableFile length is unknown");
  }
  
  Checksum getFileChecksum()
    throws IOException
  {
    if (appendChecksum == null) {
      throw new IOException("Checksum is invalid!");
    }
    return appendChecksum;
  }
  
  Checksum getChecksumCalculator()
  {
    return new CRC32();
  }
  
  private int getStreamType(InputStream is, Checksum crc, long len)
    throws IOException
  {
    boolean markSupported = (len < 2147483647L) && (is.markSupported());
    if (markSupported) {
      is.mark((int)len);
    }
    try
    {
      if (len < 16L)
      {
        if (crc != null)
        {
          byte[] data = new byte[16];
          int num = is.read(data);
          if (num > 0) {
            crc.update(data, 0, num);
          }
        }
        return 2;
      }
      len -= 16L;
      
      int pos = 0;
      byte[] data = new byte['?'];
      while (pos < len)
      {
        int read = data.length;
        if (pos + read > len) {
          read = (int)(len - pos);
        }
        int num = is.read(data, 0, read);
        if (num == -1) {
          throw new IOException("Unable to read entire file.");
        }
        crc.update(data, 0, num);
        pos += num;
      }
      int num = is.read(data);
      if (num != 16) {
        throw new IOException("Unable to read entire file.");
      }
      int num;
      byte[] data;
      int pos;
      for (int i = 0; i < 4; i++) {
        if (identifier1[i] != data[i])
        {
          crc.update(data, 0, 16);
          return 2;
        }
      }
      int i = 0;
      int j;
      int i;
      byte[] data;
      for (int j = 12; i < 4; j++)
      {
        if (identifier2[i] != data[j])
        {
          crc.update(data, 0, 16);
          return 2;
        }
        int num;
        int pos;
        i++;
      }
      long crccmp;
      try
      {
        crccmp = Long.valueOf(new String(data, 4, 8, "UTF-8"), 16).longValue();
      }
      catch (UnsupportedEncodingException localUnsupportedEncodingException)
      {
        long crccmp;
        crccmp = Long.valueOf(new String(data, 4, 8), 16).longValue();
      }
      if (crccmp == crc.getValue()) {
        return 0;
      }
      long crccmp;
      int j;
      int i;
      int num;
      byte[] data;
      int pos;
      return 1;
    }
    finally
    {
      if (markSupported) {
        is.reset();
      }
    }
  }
  
  private static byte[] intToHex(int l)
  {
    byte[] buffer = new byte[8];
    int count = 8;
    do
    {
      int ch = l & 0xF;
      if (ch > 9) {
        ch = ch - 10 + 97;
      } else {
        ch += 48;
      }
      buffer[(--count)] = ((byte)ch);
      l >>= 4;
    } while (
    
      count > 0);
    return buffer;
  }
  
  private class CacheInfo
  {
    int filetype;
    Checksum checksum;
    long timeStamp;
    long length;
    
    CacheInfo(int filetype, Checksum checksum, long timeStamp, long length)
    {
      this.filetype = filetype;
      this.checksum = checksum;
      this.timeStamp = timeStamp;
      this.length = length;
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.framework.internal.reliablefile.ReliableFile
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.framework.internal.reliablefile;

import java.io.File;
import java.io.FilterInputStream;
import java.io.IOException;

public class ReliableFileInputStream
  extends FilterInputStream
{
  private ReliableFile reliable;
  private int sigSize;
  private long readPos;
  private long length;
  
  public ReliableFileInputStream(String name)
    throws IOException
  {
    this(ReliableFile.getReliableFile(name), 0, 0);
  }
  
  public ReliableFileInputStream(File file)
    throws IOException
  {
    this(ReliableFile.getReliableFile(file), 0, 0);
  }
  
  public ReliableFileInputStream(File file, int generation, int openMask)
    throws IOException
  {
    this(ReliableFile.getReliableFile(file), generation, openMask);
  }
  
  private ReliableFileInputStream(ReliableFile reliable, int generation, int openMask)
    throws IOException
  {
    super(reliable.getInputStream(generation, openMask));
    
    this.reliable = reliable;
    sigSize = reliable.getSignatureSize();
    readPos = 0L;
    length = reliable.getInputLength();
    if (sigSize > length) {
      length = 0L;
    } else {
      length -= sigSize;
    }
  }
  
  /* Error */
  public synchronized void close()
    throws IOException
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 82	org/eclipse/osgi/framework/internal/reliablefile/ReliableFileInputStream:reliable	Lorg/eclipse/osgi/framework/internal/reliablefile/ReliableFile;
    //   4: ifnull +37 -> 41
    //   7: aload_0
    //   8: invokespecial 84	java/io/FilterInputStream:close	()V
    //   11: goto +18 -> 29
    //   14: astore_1
    //   15: aload_0
    //   16: getfield 82	org/eclipse/osgi/framework/internal/reliablefile/ReliableFileInputStream:reliable	Lorg/eclipse/osgi/framework/internal/reliablefile/ReliableFile;
    //   19: invokevirtual 91	org/eclipse/osgi/framework/internal/reliablefile/ReliableFile:closeInputFile	()V
    //   22: aload_0
    //   23: aconst_null
    //   24: putfield 82	org/eclipse/osgi/framework/internal/reliablefile/ReliableFileInputStream:reliable	Lorg/eclipse/osgi/framework/internal/reliablefile/ReliableFile;
    //   27: aload_1
    //   28: athrow
    //   29: aload_0
    //   30: getfield 82	org/eclipse/osgi/framework/internal/reliablefile/ReliableFileInputStream:reliable	Lorg/eclipse/osgi/framework/internal/reliablefile/ReliableFile;
    //   33: invokevirtual 91	org/eclipse/osgi/framework/internal/reliablefile/ReliableFile:closeInputFile	()V
    //   36: aload_0
    //   37: aconst_null
    //   38: putfield 82	org/eclipse/osgi/framework/internal/reliablefile/ReliableFileInputStream:reliable	Lorg/eclipse/osgi/framework/internal/reliablefile/ReliableFile;
    //   41: return
    // Line number table:
    //   Java source line #111	-> byte code offset #0
    //   Java source line #113	-> byte code offset #7
    //   Java source line #114	-> byte code offset #11
    //   Java source line #115	-> byte code offset #15
    //   Java source line #116	-> byte code offset #22
    //   Java source line #117	-> byte code offset #27
    //   Java source line #115	-> byte code offset #29
    //   Java source line #116	-> byte code offset #36
    //   Java source line #119	-> byte code offset #41
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	42	0	this	ReliableFileInputStream
    //   14	14	1	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   7	14	14	finally
  }
  
  public synchronized int read(byte[] b, int off, int len)
    throws IOException
  {
    if (readPos >= length) {
      return -1;
    }
    int num = super.read(b, off, len);
    if (num != -1)
    {
      if (num + readPos > length) {
        num = (int)(length - readPos);
      }
      readPos += num;
    }
    return num;
  }
  
  public synchronized int read(byte[] b)
    throws IOException
  {
    return read(b, 0, b.length);
  }
  
  public synchronized int read()
    throws IOException
  {
    if (readPos >= length) {
      return -1;
    }
    int num = super.read();
    if (num != -1) {
      readPos += 1L;
    }
    return num;
  }
  
  public synchronized int available()
    throws IOException
  {
    if (readPos < length) {
      return (int)(length - readPos);
    }
    return 0;
  }
  
  public synchronized long skip(long n)
    throws IOException
  {
    long len = super.skip(n);
    if (readPos + len > length) {
      len = length - readPos;
    }
    readPos += len;
    return len;
  }
  
  public boolean markSupported()
  {
    return false;
  }
  
  public void mark(int readlimit) {}
  
  public void reset()
    throws IOException
  {
    throw new IOException("reset not supported.");
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.framework.internal.reliablefile.ReliableFileInputStream
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.framework.internal.reliablefile;

import java.io.File;
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.zip.Checksum;

public class ReliableFileOutputStream
  extends FilterOutputStream
{
  private ReliableFile reliable;
  private Checksum crc;
  private boolean outputOpen = false;
  
  public ReliableFileOutputStream(File file)
    throws IOException
  {
    this(ReliableFile.getReliableFile(file), false);
  }
  
  public ReliableFileOutputStream(File file, boolean append)
    throws IOException
  {
    this(ReliableFile.getReliableFile(file), append);
  }
  
  public ReliableFileOutputStream(String name)
    throws IOException
  {
    this(ReliableFile.getReliableFile(name), false);
  }
  
  public ReliableFileOutputStream(String name, boolean append)
    throws IOException
  {
    this(ReliableFile.getReliableFile(name), append);
  }
  
  private ReliableFileOutputStream(ReliableFile reliable, boolean append)
    throws IOException
  {
    super(reliable.getOutputStream(append, 0));
    
    this.reliable = reliable;
    outputOpen = true;
    if (append) {
      crc = reliable.getFileChecksum();
    } else {
      crc = reliable.getChecksumCalculator();
    }
  }
  
  public synchronized void close()
    throws IOException
  {
    closeIntermediateFile();
    reliable.closeOutputFile(crc);
    
    reliable = null;
  }
  
  public File closeIntermediateFile()
    throws IOException
  {
    if (reliable == null) {
      throw new IOException("ReliableFile stream not open");
    }
    if (outputOpen)
    {
      reliable.writeChecksumSignature(out, crc);
      out.flush();
      try
      {
        ((FileOutputStream)out).getFD().sync();
      }
      catch (IOException e)
      {
        e.printStackTrace();
      }
      out.close();
      outputOpen = false;
    }
    return reliable.getOutputFile();
  }
  
  public void write(byte[] b)
    throws IOException
  {
    write(b, 0, b.length);
  }
  
  public void write(byte[] b, int off, int len)
    throws IOException
  {
    out.write(b, off, len);
    crc.update(b, off, len);
  }
  
  public void write(int b)
    throws IOException
  {
    out.write(b);
    crc.update((byte)b);
  }
  
  public void abort()
  {
    if (reliable == null) {
      return;
    }
    if (outputOpen)
    {
      try
      {
        out.close();
      }
      catch (IOException localIOException) {}
      outputOpen = false;
    }
    reliable.abortOutputFile();
    reliable = null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.framework.internal.reliablefile.ReliableFileOutputStream
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.framework.log;

import java.io.File;
import java.io.IOException;
import java.io.Writer;
import org.osgi.framework.FrameworkEvent;

public abstract interface FrameworkLog
{
  public static final String SERVICE_PERFORMANCE = "performance";
  
  public abstract void log(FrameworkEvent paramFrameworkEvent);
  
  public abstract
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd