Java Code Examples for org.apache.commons.compress.archivers.cpio.CpioArchiveEntry#setSize()
The following examples show how to use
org.apache.commons.compress.archivers.cpio.CpioArchiveEntry#setSize() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PayloadRecorder.java From packagedrone with Eclipse Public License 1.0 | 6 votes |
public Result addSymbolicLink ( final String targetPath, final String linkTo, final Consumer<CpioArchiveEntry> customizer ) throws IOException { final byte[] bytes = linkTo.getBytes ( StandardCharsets.UTF_8 ); final CpioArchiveEntry entry = new CpioArchiveEntry ( CpioConstants.FORMAT_NEW, targetPath ); entry.setSize ( bytes.length ); if ( customizer != null ) { customizer.accept ( entry ); } this.archiveStream.putArchiveEntry ( entry ); this.archiveStream.write ( bytes ); this.archiveStream.closeArchiveEntry (); return new Result ( bytes.length, null ); }
Example 2
Source File: Cpio.java From gradle-plugins with MIT License | 5 votes |
@Override @SneakyThrows public void processFile(FileCopyDetailsInternal details) { CpioArchiveEntry archiveEntry = new CpioArchiveEntry(format, details.getPath()); archiveEntry.setTime(details.getLastModified()); if (details.isDirectory()) { archiveEntry.setMode(CpioConstants.C_ISDIR); } else { archiveEntry.setMode(CpioConstants.C_ISREG); archiveEntry.setSize(details.getSize()); } try { outputFile.putArchiveEntry(archiveEntry); } catch (IOException e) { log.error(e.getMessage()); throw e; } if (!details.isDirectory()) { details.copyTo(outputFile); } outputFile.closeArchiveEntry(); }
Example 3
Source File: Cpio.java From gradle-plugins with MIT License | 5 votes |
@Override @SneakyThrows public void processFile(FileCopyDetailsInternal details) { CpioArchiveEntry archiveEntry = new CpioArchiveEntry(format, details.getPath()); archiveEntry.setTime(details.getLastModified()); if (details.isDirectory()) { archiveEntry.setMode(CpioConstants.C_ISDIR); } else { archiveEntry.setMode(CpioConstants.C_ISREG); archiveEntry.setSize(details.getSize()); } try { outputFile.putArchiveEntry(archiveEntry); } catch (IOException e) { log.error(e.getMessage()); throw e; } if (!details.isDirectory()) { details.copyTo(outputFile); } outputFile.closeArchiveEntry(); }
Example 4
Source File: PayloadRecorder.java From packagedrone with Eclipse Public License 1.0 | 5 votes |
public Result addFile ( final String targetPath, final Path path, final Consumer<CpioArchiveEntry> customizer ) throws IOException { final long size = Files.size ( path ); final CpioArchiveEntry entry = new CpioArchiveEntry ( CpioConstants.FORMAT_NEW, targetPath ); entry.setSize ( size ); if ( customizer != null ) { customizer.accept ( entry ); } this.archiveStream.putArchiveEntry ( entry ); MessageDigest digest; try { digest = createDigest (); } catch ( final NoSuchAlgorithmException e ) { throw new IOException ( e ); } try ( InputStream in = new BufferedInputStream ( Files.newInputStream ( path ) ) ) { ByteStreams.copy ( new DigestInputStream ( in, digest ), this.archiveStream ); } this.archiveStream.closeArchiveEntry (); return new Result ( size, digest.digest () ); }
Example 5
Source File: PayloadRecorder.java From packagedrone with Eclipse Public License 1.0 | 4 votes |
public Result addFile ( final String targetPath, final ByteBuffer data, final Consumer<CpioArchiveEntry> customizer ) throws IOException { final long size = data.remaining (); final CpioArchiveEntry entry = new CpioArchiveEntry ( CpioConstants.FORMAT_NEW, targetPath ); entry.setSize ( size ); if ( customizer != null ) { customizer.accept ( entry ); } this.archiveStream.putArchiveEntry ( entry ); // record digest MessageDigest digest; try { digest = createDigest (); digest.update ( data.slice () ); } catch ( final NoSuchAlgorithmException e ) { throw new IOException ( e ); } // write data final WritableByteChannel channel = Channels.newChannel ( this.archiveStream ); while ( data.hasRemaining () ) { channel.write ( data ); } // close archive entry this.archiveStream.closeArchiveEntry (); return new Result ( size, digest.digest () ); }