예제 #1
0
        /**
         * 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);
        }