private void parse(Set<JarEntry> entries) { folders.put("", new Folder()); // root folder for (JarEntry entry : entries) { String name = entry.getName(); boolean isFolder = false; // work only with slashes name = name.replace('\\', '/'); if (name.startsWith("/")) { name = name.substring(1); // NOI18N } if (name.endsWith("/")) { name = name.substring(0, name.length() - 1); // NOI18N isFolder = true; } int lastSlash = name.lastIndexOf('/'); String dirName = ""; // root String realName = name; if (lastSlash > 0) { dirName = name.substring(0, lastSlash); // or folder realName = name.substring(lastSlash + 1); } if (isFolder) { getFolder(name); // will create the folder item } else { Folder fl = getFolder(dirName); fl.addChild(realName); } } }
public String[] getChildrenOf(String folder) { Folder fol = folders.get(folder); if (fol != null) { return fol.getNames(); } return new String[] { }; }
private void trunc() { // strip the name array: byte[] newNames = new byte[nameOffset]; System.arraycopy(names, 0, newNames, 0, nameOffset); names = newNames; // strip all the indices arrays: for (Iterator it = folders.values().iterator(); it.hasNext();) { ((Folder) it.next()).trunc(); } }
private Folder getFolder(String name) { Folder fl = (Folder)folders.get(name); if (fl == null) { // add all the superfolders on the way to the root int lastSlash = name.lastIndexOf('/'); String dirName = ""; // root String realName = name; if (lastSlash > 0) { dirName = name.substring(0, lastSlash); // or folder realName = name.substring(lastSlash+1); } getFolder(dirName).addChild(realName); fl = new Folder(); folders.put(name, fl); } return fl; }
private Folder getFolder(String name) { Folder fl = (Folder)folders.get(name); if (fl == null) { // add all the superfolders on the way to the root int lastSlash = name.lastIndexOf('/'); String dirName = ""; // root String realName = name; if (lastSlash > 0) { dirName = name.substring(0, lastSlash); // or folder realName = name.substring(lastSlash+1); } getFolder(dirName).addChild(realName); fl = new Folder(); folders.put(name, fl); } return fl; }
public String[] getChildrenOf(String folder) { Folder fol = (Folder)folders.get(folder); if (fol != null) return fol.getNames(); return new String [] {}; }
private void trunc() { // strip the name array: byte[] newNames = new byte[nameOffset]; System.arraycopy(names, 0, newNames, 0, nameOffset); names = newNames; // strip all the indices arrays: for (Iterator it = folders.values().iterator(); it.hasNext(); ) { ((Folder)it.next()).trunc(); } }
private void trunc() { // strip the name array: byte[] newNames = new byte[nameOffset]; System.arraycopy(names, 0, newNames, 0, nameOffset); names = newNames; // strip all the indices arrays: for (Iterator it = folders.values().iterator(); it.hasNext(); ) { ((Folder)it.next()).trunc(); } }
public String[] getChildrenOf(String folder) { Folder fol = (Folder)folders.get(folder); if (fol != null) return fol.getNames(); return new String [] {}; }
private Folder getFolder(String name) { Folder fl = folders.get(name); if (fl == null) { // add all the superfolders on the way to the root int lastSlash = name.lastIndexOf('/'); String dirName = ""; // root String realName = name; if (lastSlash > 0) { dirName = name.substring(0, lastSlash); // or folder realName = name.substring(lastSlash + 1); } getFolder(dirName).addChild(realName); fl = new Folder(); folders.put(name, fl); } return fl; }