Exemplo n.º 1
0
  public static FsEntry createElement(FsFolder parent, File file) {
    FsEntry element;

    if (file.isDirectory()) {
      element = FsFolder.createFolder(parent, file);
    } else {
      String filename = file.getName();
      int idx = filename.lastIndexOf('.');
      String ext = (idx == -1) ? null : filename.substring(idx + 1);
      boolean zipped = "zip".equals(ext) || "jar".equals(ext);
      element = zipped ? FsFolder.createFolder(parent, file) : FsFile.createFile(parent, file);
    }
    return element;
  }
Exemplo n.º 2
0
  @Override
  public void copyTo(FsFolder destFolder) throws IOException {
    // copy = null;

    // create file
    if (m_file != null) {
      // String foldername = m_file.getName();
      // File target = new File(destFolder.m_file, foldername);
      // copy = createFolder(destFolder, destFolder.m_file);

      List<FsEntry> elements = getFolderElements();
      for (FsEntry element : elements) {
        String foldername = element.getSimpleName();
        File destParent = destFolder.m_file;
        File newFile = new File(destParent, foldername);

        if (element instanceof FsFolder) {
          FsFolder copy = createFolder(destFolder, newFile);
          element.copyTo(copy);
        } else {
          // FileRef copy = FileRef.createFile(destFolder, newFile);
          element.copyTo(destFolder);
        }
      }

    } else if (m_composite != null) {
      // create folder
      String entryName = m_entry.getName();
      int len = entryName.length();
      int idx = entryName.lastIndexOf('/', len - 2);
      String suffix = entryName.substring(idx + 1, len - 1);
      File folder = new File(destFolder.m_file, suffix);
      folder.mkdirs();
      FsFolder copy = FsFolder.createFolder(destFolder, folder);

      // unzip in folder
      List<FsEntry> entries = getFolderElements();
      for (FsEntry entry : entries) {
        entry.copyTo(copy);
      }

      // unzipEntries(folderRef);

      // new ZipInputStream();

      /*
      File f = createTemporaryFile(folderRef, m_zipfile, m_entry);
      f.createNewFile();
      FileRef tempfile = FileRef.createFile(destFolder, f);
      */
    }
  }
Exemplo n.º 3
0
 private static FsFolder createFolder(
     FsFolder parent, String foldername, ZipFileAndURLUnion composite, ZipEntry entry) {
   FsFolder element = FsFolder.createFolder(parent, foldername, composite, entry);
   return element;
 }