public static void Main(String[] args) //throws Exception { if (args.Length == 0) { usage(); return; } java.lang.SystemJ.outJ.println("Analysing " + args[0]); java.io.File f = new java.io.File(args[0]); if (!f.isFile()) { java.lang.SystemJ.err.println(f + " doesn't exist or is a directory"); } java.io.InputStream fis = new java.io.BufferedInputStream(new java.io.FileInputStream(f)); ArchiveInputStream ais; if (args.Length > 1) { ais = factory.createArchiveInputStream(args[1], fis); } else { ais = factory.createArchiveInputStream(fis); } java.lang.SystemJ.outJ.println("Created " + ais.toString()); ArchiveEntry ae; while ((ae = ais.getNextEntry()) != null) { java.lang.SystemJ.outJ.println(ae.getName()); } ais.close(); fis.close(); }
/** * Create a new instance using the attributes of the given file */ public ArArchiveEntry(java.io.File inputFile, String entryName) { // TODO sort out mode this.name = entryName; this.length = inputFile.isFile() ? inputFile.length() : 0; this.userId = 0; this.groupId = 0; this.mode = DEFAULT_MODE; this.lastModified = inputFile.lastModified() / 1000; }
/** * Creates a new zip entry taking some information from the given * file and using the provided name. * * <p />The name will be adjusted to end with a forward slash "/" if * the file is a directory. If the file is not a directory a * potential trailing forward slash will be stripped from the * entry name. */ public ZipArchiveEntry(java.io.File inputFile, String entryName) : base(inputFile.isDirectory() && !entryName.EndsWith("/") ? entryName + "/" : entryName) { setName(inputFile.isDirectory() && !entryName.EndsWith("/") ? entryName + "/" : entryName); if (inputFile.isFile()) { setSize(inputFile.length()); } setTime(inputFile.lastModified()); // TODO are there any other fields we can set here? }
/** * Creates a CPIOArchiveEntry with a specified name for a * specified file. * * @param format * The cpio format for this entry. * @param inputFile * The file to gather information from. * @param entryName * The name of this entry. * <br/> * Possible format values are: * <p> * CpioConstants.FORMAT_NEW<br/> * CpioConstants.FORMAT_NEW_CRC<br/> * CpioConstants.FORMAT_OLD_BINARY<br/> * CpioConstants.FORMAT_OLD_ASCII<br/> * * @since Apache Commons Compress 1.1 */ public CpioArchiveEntry(short format, java.io.File inputFile, String entryName) { this.setFileFormat(format); this.name = entryName; this.setSize(inputFile.isFile() ? inputFile.length() : 0); long mode = 0; if (inputFile.isDirectory()) { mode |= CpioConstants.C_ISDIR; } else if (inputFile.isFile()) { mode |= CpioConstants.C_ISREG; } else { throw new java.lang.IllegalArgumentException("Cannot determine type of file " + inputFile.getName()); } // TODO set other fields as needed setMode(mode); setTime(inputFile.lastModified() / 1000); }