public static void main ( String [ ] args ) throws Exception { InputStream fios = new FileInputStream ( args [ 0 ] ) ; ReadableChannelWrapper in = new ReadableChannelWrapper ( Channels . newChannel ( fios ) ) ; Scanner scanner = new Scanner ( System . out ) ; Format format = scanner . run ( in ) ; scanner . log ( format . toString ( ) ) ; Header rpmHeader = format . getHeader ( ) ; scanner . log ( "Payload compression: " + rpmHeader . getEntry ( HeaderTag . PAYLOADCOMPRESSOR ) ) ; InputStream uncompressed = Util . openPayloadStream ( rpmHeader , fios ) ; in = new ReadableChannelWrapper ( Channels . newChannel ( uncompressed ) ) ; CpioHeader header ; int total = 0 ; do { header = new CpioHeader ( ) ; total = header . read ( in , total ) ; scanner . log ( header . toString ( ) ) ; final int skip = header . getFileSize ( ) ; if ( uncompressed . skip ( skip ) != skip ) throw new RuntimeException ( "Skip failed." ) ; total += header . getFileSize ( ) ; } while ( ! header . isLast ( ) ) ; }
Scans a file and prints out useful information . This utility reads from standard input and parses the binary contents of the RPM file .