/** * Get the file or dir mode for this Resource. * @return integer representation of Unix permission mask. */ public int getMode() { if (isReference()) { return getCheckedRef().getMode(); } checkEntry(); return mode; }
/** * Construct a ArchiveResource representing the specified * entry in the specified archive. * @param a the archive as Resource. * @param withEntry if the entry has been specified. */ protected ArchiveResource(Resource a, boolean withEntry) { addConfigured(a); haveEntry = withEntry; }
/** * Sets the file or dir mode for this resource. * @param mode integer representation of Unix permission mask. */ public void setMode(int mode) { checkAttributesAllowed(); this.mode = mode; modeSet = true; }
/** * Get the archive that holds this Resource. * @return the archive as a Resource. */ public Resource getArchive() { return isReference() ? getCheckedRef().getArchive() : archive; }
/** * Format this Resource as a String. * @return String representation of this Resource. */ @Override public String toString() { return isReference() ? getCheckedRef().toString() : getArchive().toString() + ':' + getName(); }
/** * Compare another Object to this ArchiveResource for equality. * @param another the other Object to compare. * @return true if another is a Resource representing * the same entry in the same archive. */ @Override public boolean equals(Object another) { if (this == another) { return true; } if (isReference()) { return getCheckedRef().equals(another); } if (another == null || !another.getClass().equals(getClass())) { return false; } ArchiveResource r = (ArchiveResource) another; return getArchive().equals(r.getArchive()) && getName().equals(r.getName()); }
/** * Validate settings and ensure that the represented "archive entry" * has been established. */ protected final synchronized void checkEntry() throws BuildException { dieOnCircularReference(); if (haveEntry) { return; } String name = getName(); if (name == null) { throw new BuildException("entry name not set"); } Resource r = getArchive(); if (r == null) { throw new BuildException("archive attribute not set"); } if (!r.isExists()) { throw new BuildException("%s does not exist.", r); } if (r.isDirectory()) { throw new BuildException("%s denotes a directory.", r); } fetchEntry(); haveEntry = true; }
/** * Get the last modified date of this Resource. * @return the last modification date. */ @Override public long getLastModified() { if (isReference()) { return getCheckedRef().getLastModified(); } checkEntry(); return super.getLastModified(); }
/** * Find out whether this Resource represents an existing Resource. * @return boolean existence flag. */ @Override public boolean isExists() { if (isReference()) { return getCheckedRef().isExists(); } checkEntry(); return super.isExists(); }
/** * Get the size of this Resource. * @return the long size of this Resource. */ @Override public long getSize() { if (isReference()) { return getCheckedRef().getSize(); } checkEntry(); return super.getSize(); }
/** * Learn whether this Resource represents a directory. * @return boolean flag indicating whether the entry is a directory. */ @Override public boolean isDirectory() { if (isReference()) { return getCheckedRef().isDirectory(); } checkEntry(); return super.isDirectory(); }
/** * Determine a Resource's Unix mode or return the given default * value if not available. */ private int getUnixMode(final Resource r, final ZipFile zf, final int defaultMode) { int unixMode = defaultMode; if (zf != null) { final ZipEntry ze = zf.getEntry(r.getName()); unixMode = ze.getUnixMode(); if ((unixMode == 0 || unixMode == UnixStat.DIR_FLAG) && !preserve0Permissions) { unixMode = defaultMode; } } else if (r instanceof ArchiveResource) { unixMode = ((ArchiveResource) r).getMode(); } return unixMode; }
/** * Overrides the super version. * @param r the Reference to set. */ public void setRefid(Reference r) { if (encoding != null) { throw tooManyAttributes(); } super.setRefid(r); }
/** * Get the hash code for this Resource. * @return hash code as int. */ @Override public int hashCode() { return super.hashCode() * (getArchive() == null ? NULL_ARCHIVE : getArchive().hashCode()); }
/** * Compare this ArchiveResource to another Resource. * @param another the other Resource against which to compare. * @return a negative integer, zero, or a positive integer as this Resource * is less than, equal to, or greater than the specified Resource. */ @Override public int compareTo(Resource another) { return this.equals(another) ? 0 : super.compareTo(another); }
/** * Sets the archive that holds this as a single element Resource * collection. * @param a the archive as a single element Resource collection. */ public void addConfigured(ResourceCollection a) { checkChildrenAllowed(); if (archive != null) { throw new BuildException( "you must not specify more than one archive"); } if (a.size() != 1) { throw new BuildException( "only single argument resource collections are supported as archives"); } archive = a.iterator().next(); }
return permissionsFromMode(((ArchiveResource) r).getMode());
/** * Overrides the super version. * @param r the Reference to set. */ @Override public void setRefid(Reference r) { if (getEncoding() != null) { throw tooManyAttributes(); } super.setRefid(r); }
te.setMode(ar.getMode()); if (r instanceof TarResource) { final TarResource tr = (TarResource) r;
/** * Sets the archive that holds this as a single element Resource * collection. * @param a the archive as a single element Resource collection. */ public void addConfigured(ResourceCollection a) { super.addConfigured(a); if (!a.isFilesystemOnly()) { throw new BuildException("only filesystem resources are supported"); } }