Example #1
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);
      */
    }
  }
Example #2
0
  private void buildChildren(ZipFileAndURLUnion composite) {
    // if (composite.)

    String foldername = getQualifiedName();

    if ("com/neosapiens/plugins/codegen/simplecsharp/".equals(foldername)) {
      int i = 0;
      i++;
    }

    Enumeration<? extends ZipEntry> entries = composite.entries();
    while (entries.hasMoreElements()) {
      ZipEntry entry = entries.nextElement();
      String entryName = entry.getName();

      // if entry part of folder
      if (entryName.startsWith(foldername) && !entryName.equals(foldername)) {
        FsEntry element = m_children.get(entryName);
        if (element == null) {
          element = FsEntry.createElement(this, composite, entry);
          m_children.put(entryName, element);
        }
      }

      // AbsFolderElement newElement = AbsFolderElement.createElement(this, m_zipfile, entry);
      // String simpleName = newElement.getSimpleName();

      // AbsFolderElement element = m_children.get(simpleName);
      // if (element == null) {
      //  m_children.put(simpleName, newElement);
      // }
    } // end while

    long size = m_entry.getSize();
    size++;
  }
Example #3
0
  private void buildChildren(File m_file) {
    if (m_file.isDirectory()) {
      File[] files = m_file.listFiles();
      for (File file : files) {
        FsEntry newElement = FsEntry.createElement(this, file);
        String name = newElement.getSimpleName();
        FsEntry element = m_children.get(name);
        if (element == null) {
          m_children.put(name, newElement);
        }
        // elements.add(element);
      }
    } else {
      try {
        ZipFile zipfile = new ZipFile(m_file);

        Enumeration<? extends ZipEntry> entries = zipfile.entries();
        while (entries.hasMoreElements()) {
          ZipEntry entry = entries.nextElement();

          // get the name of the last element
          String name = entry.getName();
          FsEntry element = getNamedDescendent(name);
          if (element == null) {
            ZipFileAndURLUnion parent = new ZipFileAndURLUnion(zipfile);
            element = FsEntry.createElement(this, parent, entry);

            if (element == null) {
              int i = 0;
              i++;
            }
            String simpleName = element.getSimpleName();

            FsEntry e = m_children.get(simpleName);
            if (e == null) {
              m_children.put(simpleName, element);
            }
          }

          /*
          int len = name.length();
          int idx = name.lastIndexOf('/', len-2);
          String simpleName = (idx == -1) ? name : name.substring(idx);
          AbsFolderElement element = m_children.get(simpleName);
          if (element == null) {
              element = AbsFolderElement.createElement(this, zipfile, entry);
              m_children.put(simpleName, element);
          }
          */
          boolean dir = entry.isDirectory();

          // AbsFolderElement newElement = AbsFolderElement.createElement(this, zipfile, entry);
          // String simpleName = newElement.getSimpleName();

          // elements.add(element);
        } // end while

      } catch (IOException ex) {
      }
    }
  }