    001    /*
    002     * Licensed to the Apache Software Foundation (ASF) under one
    003     * or more contributor license agreements.  See the NOTICE file
    004     * distributed with this work for additional information
    005     * regarding copyright ownership.  The ASF licenses this file
    006     * to you under the Apache License, Version 2.0 (the
    007     * "License"); you may not use this file except in compliance
    008     * with the License.  You may obtain a copy of the License at
    009     *
    010     * http://www.apache.org/licenses/LICENSE-2.0
    011     *
    012     * Unless required by applicable law or agreed to in writing,
    013     * software distributed under the License is distributed on an
    014     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    015     * KIND, either express or implied.  See the License for the
    016     * specific language governing permissions and limitations
    017     * under the License.
    018     */
    019    package org.apache.commons.compress.archivers.tar;
    020
    021    /**
    022     * This interface contains all the definitions used in the package.
    023     *
    024     */
    025    // CheckStyle:InterfaceIsTypeCheck OFF (bc)
    026    public interface TarConstants {
    027
    028        /**
    029         * The length of the name field in a header buffer.
    030         */
    031        int    NAMELEN = 100;
    032
    033        /**
    034         * The length of the mode field in a header buffer.
    035         */
    036        int    MODELEN = 8;
    037
    038        /**
    039         * The length of the user id field in a header buffer.
    040         */
    041        int    UIDLEN = 8;
    042
    043        /**
    044         * The length of the group id field in a header buffer.
    045         */
    046        int    GIDLEN = 8;
    047
    048        /**
    049         * The length of the checksum field in a header buffer.
    050         */
    051        int    CHKSUMLEN = 8;
    052
    053        /**
    054         * The length of the size field in a header buffer.
    055         */
    056        int    SIZELEN = 12;
    057
    058        /**
    059         * The maximum size of a file in a tar archive (That's 11 sevens, octal).
    060         */
    061        long   MAXSIZE = 077777777777L;
    062
    063        /** Offset of start of magic field within header record */
    064        int    MAGIC_OFFSET = 257;
    065        /**
    066         * The length of the magic field in a header buffer.
    067         */
    068        int    MAGICLEN = 6;
    069
    070        /** Offset of start of magic field within header record */
    071        int    VERSION_OFFSET = 263;
    072        /**
    073         * Previously this was regarded as part of "magic" field, but it is separate.
    074         */
    075        int    VERSIONLEN = 2;
    076
    077        /**
    078         * The length of the modification time field in a header buffer.
    079         */
    080        int    MODTIMELEN = 12;
    081
    082        /**
    083         * The length of the user name field in a header buffer.
    084         */
    085        int    UNAMELEN = 32;
    086
    087        /**
    088         * The length of the group name field in a header buffer.
    089         */
    090        int    GNAMELEN = 32;
    091
    092        /**
    093         * The length of each of the device fields (major and minor) in a header buffer.
    094         */
    095        int    DEVLEN = 8;
    096
    097        /**
    098         * Length of the prefix field.
    099         *
    100         */
    101        int    PREFIXLEN = 155;
    102
    103        /**
    104         * LF_ constants represent the "link flag" of an entry, or more commonly,
    105         * the "entry type". This is the "old way" of indicating a normal file.
    106         */
    107        byte   LF_OLDNORM = 0;
    108
    109        /**
    110         * Normal file type.
    111         */
    112        byte   LF_NORMAL = (byte) '0';
    113
    114        /**
    115         * Link file type.
    116         */
    117        byte   LF_LINK = (byte) '1';
    118
    119        /**
    120         * Symbolic link file type.
    121         */
    122        byte   LF_SYMLINK = (byte) '2';
    123
    124        /**
    125         * Character device file type.
    126         */
    127        byte   LF_CHR = (byte) '3';
    128
    129        /**
    130         * Block device file type.
    131         */
    132        byte   LF_BLK = (byte) '4';
    133
    134        /**
    135         * Directory file type.
    136         */
    137        byte   LF_DIR = (byte) '5';
    138
    139        /**
    140         * FIFO (pipe) file type.
    141         */
    142        byte   LF_FIFO = (byte) '6';
    143
    144        /**
    145         * Contiguous file type.
    146         */
    147        byte   LF_CONTIG = (byte) '7';
    148
    149        /**
    150         * The magic tag representing a POSIX tar archive.
    151         */
    152        String MAGIC_POSIX = "ustar\0";
    153        String VERSION_POSIX = "00";
    154
    155        /**
    156         * The magic tag representing a GNU tar archive.
    157         */
    158        String MAGIC_GNU = "ustar ";
    159        // Appear to be two possible GNU versions
    160        String VERSION_GNU_SPACE = " \0";
    161        String VERSION_GNU_ZERO  = "0\0";
    162
    163        /**
    164         * The name of the GNU tar entry which contains a long name.
    165         */
    166        String GNU_LONGLINK = "././@LongLink"; // TODO rename as LONGLINK_GNU ?
    167
    168        /**
    169         * Identifies the *next* file on the tape as having a long name.
    170         */
    171        byte LF_GNUTYPE_LONGNAME = (byte) 'L';
    172    }