/** * Adds an addition change. * * @param pChange * the change which should result in an addition */ private void addAddition(Change pChange) { if (Change.TYPE_ADD != pChange.type() || pChange.getInput() == null) { return; } if (!changes.isEmpty()) { for (java.util.Iterator <Change> it = changes.iterator(); it.hasNext();) { Change change = it.next(); if (change.type() == Change.TYPE_ADD && change.getEntry() != null) { org.apache.commons.compress.archivers.ArchiveEntry entry = change.getEntry(); if (entry.equals(pChange.getEntry())) { if (pChange.isReplaceMode()) { it.remove(); changes.add(pChange); return; } else { // do not add this change return; } } } } } changes.add(pChange); }
/** * Checks if an ArchiveEntry is deleted later in the ChangeSet. This is * necessary if an file is added with this ChangeSet, but later became * deleted in the same set. * * @param entry * the entry to check * @return true, if this entry has an deletion change later, false otherwise */ private bool isDeletedLater(java.util.Set <Change> workingSet, ArchiveEntry entry) { String source = entry.getName(); if (!workingSet.isEmpty()) { for (java.util.Iterator <Change> it = workingSet.iterator(); it.hasNext();) { Change change = it.next(); int type = change.type(); String target = change.targetFile(); if (type == Change.TYPE_DELETE && source.equals(target)) { return(true); } if (type == Change.TYPE_DELETE_DIR && source.startsWith(target + "/")) { return(true); } } } return(false); }