/** * Encodes the given string using the configured encoding. * * @param str the String to write * @throws IOException if the string couldn't be written * @return result of encoding the string */ private byte[] encode(final String str) throws IOException { final ByteBuffer buf = zipEncoding.encode(str); final int len = buf.limit() - buf.position(); return Arrays.copyOfRange(buf.array(), buf.arrayOffset(), buf.arrayOffset() + len); }
private ByteBuffer getName(final ZipArchiveEntry ze) throws IOException { return getEntryEncoding(ze).encode(ze.getName()); }
final ByteBuffer commentB = getEntryEncoding(ze).encode(comm); ze.addExtraField(new UnicodeCommentExtraField(comm, commentB.array(),
final String paxHeaderName, final byte linkType, final String fieldName) throws IOException { final ByteBuffer encodedName = zipEncoding.encode(name); final int len = encodedName.limit() - encodedName.position(); if (len >= TarConstants.NAMELEN) {
final ByteBuffer data = this.zipEncoding.encode(comment); final int dataLen = data.limit() - data.position(); writeCounted(ZipShort.getBytes(dataLen));
final ByteBuffer commentB = getEntryEncoding(ze).encode(comm); final int nameLen = name.limit() - name.position(); final int commentLen = commentB.limit() - commentB.position();
private byte[] encodeArchiveEntry( String payload, String encoding ) throws IOException { ZipEncoding enc = ZipEncodingHelper.getZipEncoding( encoding ); ByteBuffer encodedPayloadByteBuffer = enc.encode( payload ); byte[] encodedPayloadBytes = new byte[encodedPayloadByteBuffer.limit()]; encodedPayloadByteBuffer.get( encodedPayloadBytes ); return encodedPayloadBytes; }
/** * Writes an ASCII string to the stream followed by \0 * @param str the String to write * @throws IOException if the string couldn't be written */ private void writeCString(final String str) throws IOException { final ByteBuffer buf = zipEncoding.encode(str); final int len = buf.limit() - buf.position(); out.write(buf.array(), buf.arrayOffset(), len); out.write('\0'); count(len + 1); }
private ByteBuffer getName(final ZipArchiveEntry ze) throws IOException { return getEntryEncoding(ze).encode(ze.getName()); }
final ByteBuffer commentB = getEntryEncoding(ze).encode(comm); ze.addExtraField(new UnicodeCommentExtraField(comm, commentB.array(),
final String paxHeaderName, final byte linkType, final String fieldName) throws IOException { final ByteBuffer encodedName = zipEncoding.encode(name); final int len = encodedName.limit() - encodedName.position(); if (len >= TarConstants.NAMELEN) {
final ByteBuffer data = this.zipEncoding.encode(comment); final int dataLen = data.limit() - data.position(); writeCounted(ZipShort.getBytes(dataLen));
final ByteBuffer commentB = getEntryEncoding(ze).encode(comm); final int nameLen = name.limit() - name.position(); final int commentLen = commentB.limit() - commentB.position();