예제 #1
0
 /**
  * Fill simple reports in during compassion ZIP file.
  *
  * @param reportZip1 the report of the first ZIP file
  * @param infoZip1 the ZipInputStream of the first ZIP file
  * @param reportZip2 the report of the second ZIP file
  * @param infoZip2 the ZipInputStream of the second ZIP file
  */
 private static void compareDirectoryInfo(
     FileReport reportZip1,
     DirectoryInfo infoZip1,
     FileReport reportZip2,
     DirectoryInfo infoZip2) {
   for (FileInfo info : infoZip1) {
     FileState state = infoZip2.compareToObject(info);
     FileInfo info2 = infoZip2.getComparedObject();
     switch (state) {
       case CHANGED:
         reportZip1.fileChanged(info.name);
         reportZip2.fileChanged(info2.name);
         infoZip2.remove(info2);
         break;
       case RENAMED:
         reportZip1.fileRenamed(info.name);
         reportZip2.fileRenamed(info2.name);
         infoZip2.remove(info2);
         break;
       case NOT_EQUALS:
         reportZip1.fileRemoved(info.name);
         reportZip2.addMessage(" ");
         break;
       case EQUALS:
         infoZip2.remove(info2);
     }
   }
   for (FileInfo info : infoZip2) {
     reportZip2.fileAdd(info.name);
     reportZip1.addMessage(" ");
   }
 }
예제 #2
0
 /**
  * Finds all information files are in ZIP file
  *
  * @param zip is open ZipInputStream
  * @return collection FileInfo files
  * @throws IOException if zip stream isn't opened
  */
 public static DirectoryInfo getContentsZip(ZipFile zip) throws IOException {
   DirectoryInfo directoryInfo = new DirectoryInfo();
   Enumeration<? extends ZipEntry> entryEnumeration = zip.entries();
   for (ZipEntry zipEntry; entryEnumeration.hasMoreElements(); ) {
     zipEntry = entryEnumeration.nextElement();
     directoryInfo.add(new ZipFileInfo(zipEntry));
   }
   return directoryInfo;
 }