Package ch.enterag.utils.zip

Examples of ch.enterag.utils.zip.FileEntry


      log.info("[createZip] Normalizing paths...");
      List<String> normalizedPaths = normalizePaths(srcFolder);
     
      for(int i=0;i<normalizedPaths.size();i++) {
        String currentZipEntryPath = normalizedPaths.get(i);
        FileEntry entry = new FileEntry(currentZipEntryPath);
        File currentFile = new File(listOfFiles.get(i));
       
        writeEntry(zipFile, entry, currentFile, compress);
      }
      log.info("[createZip] All Files written to zip file: " + zipFile.getDiskFile().getFileName());
View Full Code Here


    currentFolder.mkdirs();
    List<String> containedFiles = getFileEntryChildren(zip64File, folderEntry);
   
    if(containedFiles.size()>0) {
      for (String currentFilePath : containedFiles) {
        FileEntry currentEntry = zip64File.getFileEntry(currentFilePath);
        File destination = new File(dest, currentEntry.getName());
        if(!currentEntry.isDirectory()) {
          readFileEntry(zip64File, currentEntry, dest);
        }
        else {
          destination.mkdirs();
          log.info("[readFolderEntry] Created folder in file system: " + destination.getAbsolutePath());
View Full Code Here

   */
  public static File getFileFrom(File zip, String targetPathInZipfile, File destFolder) {
    File target = null;
    try {
      Zip64File zip64File = new Zip64File(zip);
      FileEntry targetEntry = getFileEntry(zip64File, targetPathInZipfile);
     
      if(targetEntry!=null) {
        target = readEntry(zip64File, targetEntry, destFolder);
      }
      else {
View Full Code Here

    try {
      boolean compress = false;
     
      zip64File = new Zip64File(zipFile);
     
      FileEntry testEntry = getFileEntry(zip64File, targetPath);
     
      if(testEntry!= null && testEntry.getMethod() == FileEntry.iMETHOD_DEFLATED) {
        compress = true;
      }
     
      processAndCreateFolderEntries(zip64File, parseTargetPath(targetPath, toInsert), compress);
     
      if(testEntry!=null) {
        log.info("[insertFileInto] Entry exists: " + testEntry.getName());
        log.info("[insertFileInto] Will delete this entry before inserting: " + toInsert.getName());
        if(!testEntry.isDirectory()) {
          zip64File.delete(testEntry.getName());
        }
        else {
          log.info("[insertFileInto] Entry is a directory. " +
              "Will delete all files contained in this entry and insert " + toInsert.getName()
              "and all nested files.");
View Full Code Here

  private static void processAndCreateFolderEntries(Zip64File zip64File, List<String> pathParts, boolean compress) {
    if(pathParts==null) {
      return;
    }
    for (String string : pathParts) {
      FileEntry currentEntry = zip64File.getFileEntry(string);
      if(currentEntry!=null) {
        continue;
      }
      else {
        currentEntry = zip64File.getFileEntry(string + "/");
View Full Code Here

  public static File removeFileFrom(File zipFile, String fileToRemove) {
    Zip64File zip64File = null;
    try {
      zip64File = new Zip64File(zipFile);
     
      FileEntry testEntry = getFileEntry(zip64File, fileToRemove);
     
      if(testEntry==null) {
        log.info("File not found: " + fileToRemove);
        log.info("Nothing has been deleted...");
      }
      else {
        if(testEntry.isDirectory()) {
          deleteFileEntry(zip64File, testEntry);
        }
        else {
          FileEntry deletedEntry = zip64File.delete(fileToRemove);
          log.info("Deleted entry from zip: " + deletedEntry.getName());
          zip64File.close();
        }
      }
     
      zip64File.close();
View Full Code Here

  }
 
 
  @SuppressWarnings("unused")
  private static FileEntry testFileEntry(Zip64File zip64File, String targetPath) {
    FileEntry fileEntry = zip64File.getFileEntry(targetPath);
    return fileEntry;
  }
View Full Code Here

    return fileEntry;
  }
 
  @SuppressWarnings("unused")
  private static FileEntry testFolderEntry(Zip64File zip64File, String targetPath) {
    FileEntry folderEntry = zip64File.getFileEntry(targetPath + "/");
    return folderEntry;
  }
View Full Code Here

        log.info("[deleteEntriesRecursively] The FileEntry to delete is a folder. Deleting all nested entries: ");
        List<String> containedFiles = getFileEntryChildren(zip, toDelete);
       
        if(containedFiles.size()>0) {
          for (String currentEntryPath : containedFiles) {
            FileEntry current = zip.getFileEntry(currentEntryPath);
            if(current!=null) {
              deleteEntriesRecursively(zip, current, deletedEntries);
            }
          }
          log.info("[deleteEntriesRecursively] Deleted entry: " + toDelete.getName());
          deletedEntries.add(zip.delete(toDelete.getName()));
        }
        else {
          log.info("[deleteEntriesRecursively] Deleted entry: " + toDelete.getName());
          deletedEntries.add(zip.delete(toDelete.getName()));
        }
      }
      else {
        FileEntry current = zip.delete(toDelete.getName());
        log.info("[deleteEntriesRecursively] Deleted entry: " + toDelete.getName());
        deletedEntries.add(current);
      }
    } catch (IOException e) {
      e.printStackTrace();
View Full Code Here

   * @param zip the zip file to search.
   * @param entryPath the FileEntry to find
   * @return the found FileEntry or null, if entryPath is not a valid location.
   */
  private static FileEntry getFileEntry(Zip64File zip64File, String entryPath) {
    FileEntry testEntry = null;
    testEntry = zip64File.getFileEntry(entryPath);
    if(testEntry==null) {
      testEntry = zip64File.getFileEntry(entryPath + "/");
    }
    if(testEntry!=null) {
      log.info("[getFileEntry] Found entry: " + testEntry.getName());
    }
    else {
      log.severe("[getFileEntry] Entry NOT found: " + entryPath);
    }
    return testEntry;
View Full Code Here

TOP

Related Classes of ch.enterag.utils.zip.FileEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.