/** * Indicate that this entry is a symbolic link to the given filename. * * @param name Name of the file this entry links to, empty String * if it is not a symbolic link. */ public void setLinkedFile(final String name) { link = name; mode = getMode(mode); }
/** * Is this entry a symbolic link? * @return true if this is a symbolic link */ public boolean isLink() { return getLinkedFile().length() != 0; }
/** * Delegate to local file data. * @return the local file data */ @Override public byte[] getCentralDirectoryData() { return getLocalFileDataData(); }
/** * Get the file mode for given permissions with the correct file type. * @param mode the mode * @return the type with the mode */ protected int getMode(final int mode) { int type = FILE_FLAG; if (isLink()) { type = LINK_FLAG; } else if (isDirectory()) { type = DIR_FLAG; } return type | (mode & PERM_MASK); }
/** * The actual data to put into local file data - without Header-ID * or length specifier. * @return get the data */ @Override public byte[] getLocalFileDataData() { // CRC will be added later final byte[] data = new byte[getLocalFileDataLength().getValue() - WORD]; System.arraycopy(ZipShort.getBytes(getMode()), 0, data, 0, 2); final byte[] linkArray = getLinkedFile().getBytes(); // Uses default charset - see class Javadoc // CheckStyle:MagicNumber OFF System.arraycopy(ZipLong.getBytes(linkArray.length), 0, data, 2, WORD); System.arraycopy(ZipShort.getBytes(getUserId()), 0, data, 6, 2); System.arraycopy(ZipShort.getBytes(getGroupId()), 0, data, 8, 2); System.arraycopy(linkArray, 0, data, 10, linkArray.length); // CheckStyle:MagicNumber ON crc.reset(); crc.update(data); final long checksum = crc.getValue(); final byte[] result = new byte[data.length + WORD]; System.arraycopy(ZipLong.getBytes(checksum), 0, result, 0, WORD); System.arraycopy(data, 0, result, WORD, data.length); return result; }
setDirectory((newMode & DIR_FLAG) != 0); setMode(newMode);
/** * Is this entry a directory? * @return true if this entry is a directory */ public boolean isDirectory() { return dirFlag && !isLink(); }
/** * Delegate to local file data. * @return the centralDirectory length */ @Override public ZipShort getCentralDirectoryLength() { return getLocalFileDataLength(); }
/** * Doesn't do anything special since this class always uses the * same data in central directory and local file data. */ @Override public void parseFromCentralDirectoryData(final byte[] buffer, final int offset, final int length) throws ZipException { parseFromLocalFileData(buffer, offset, length); }
/** * The actual data to put into local file data - without Header-ID * or length specifier. * @return get the data */ @Override public byte[] getLocalFileDataData() { // CRC will be added later final byte[] data = new byte[getLocalFileDataLength().getValue() - WORD]; System.arraycopy(ZipShort.getBytes(getMode()), 0, data, 0, 2); final byte[] linkArray = getLinkedFile().getBytes(); // Uses default charset - see class Javadoc // CheckStyle:MagicNumber OFF System.arraycopy(ZipLong.getBytes(linkArray.length), 0, data, 2, WORD); System.arraycopy(ZipShort.getBytes(getUserId()), 0, data, 6, 2); System.arraycopy(ZipShort.getBytes(getGroupId()), 0, data, 8, 2); System.arraycopy(linkArray, 0, data, 10, linkArray.length); // CheckStyle:MagicNumber ON crc.reset(); crc.update(data); final long checksum = crc.getValue(); final byte[] result = new byte[data.length + WORD]; System.arraycopy(ZipLong.getBytes(checksum), 0, result, 0, WORD); System.arraycopy(data, 0, result, WORD, data.length); return result; }
/** * Get the file mode for given permissions with the correct file type. * @param mode the mode * @return the type with the mode */ protected int getMode(final int mode) { int type = FILE_FLAG; if (isLink()) { type = LINK_FLAG; } else if (isDirectory()) { type = DIR_FLAG; } return type | (mode & PERM_MASK); }
setDirectory((newMode & DIR_FLAG) != 0); setMode(newMode);
/** * Is this entry a directory? * @return true if this entry is a directory */ public boolean isDirectory() { return dirFlag && !isLink(); }
/** * Delegate to local file data. * @return the centralDirectory length */ @Override public ZipShort getCentralDirectoryLength() { return getLocalFileDataLength(); }
/** * Doesn't do anything special since this class always uses the * same data in central directory and local file data. */ @Override public void parseFromCentralDirectoryData(final byte[] buffer, final int offset, final int length) throws ZipException { parseFromLocalFileData(buffer, offset, length); }
/** * File mode of this file. * @param mode the file mode */ public void setMode(final int mode) { this.mode = getMode(mode); }
/** * Length of the extra field in the local file data - without * Header-ID or length specifier. * @return a <code>ZipShort</code> for the length of the data of this extra field */ @Override public ZipShort getLocalFileDataLength() { return new ZipShort(WORD // CRC + 2 // Mode + WORD // SizDev + 2 // UID + 2 // GID + getLinkedFile().getBytes().length); // Uses default charset - see class Javadoc }
/** * Delegate to local file data. * @return the local file data */ @Override public byte[] getCentralDirectoryData() { return getLocalFileDataData(); }
/** * Indicate whether this entry is a directory. * @param dirFlag if true, this entry is a directory */ public void setDirectory(final boolean dirFlag) { this.dirFlag = dirFlag; mode = getMode(mode); }
/** * Is this entry a symbolic link? * @return true if this is a symbolic link */ public boolean isLink() { return getLinkedFile().length() != 0; }