    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     * For tar formats (FORMAT_OLDGNU, FORMAT_POSIX, etc.) see GNU tar
    025     * <I>tar.h</I> type <I>enum archive_format</I>
    026     */
    027    // CheckStyle:InterfaceIsTypeCheck OFF (bc)
    028    public interface TarConstants {
    029
    030        /**
    031         * GNU format as per before tar 1.12.
    032         */
    033        int    FORMAT_OLDGNU = 2;
    034
    035        /**
    036         * Pure Posix format.
    037         */
    038        int    FORMAT_POSIX = 3;
    039
    040        /**
    041         * The length of the name field in a header buffer.
    042         */
    043        int    NAMELEN = 100;
    044
    045        /**
    046         * The length of the mode field in a header buffer.
    047         */
    048        int    MODELEN = 8;
    049
    050        /**
    051         * The length of the user id field in a header buffer.
    052         */
    053        int    UIDLEN = 8;
    054
    055        /**
    056         * The length of the group id field in a header buffer.
    057         */
    058        int    GIDLEN = 8;
    059
    060        /**
    061         * The length of the checksum field in a header buffer.
    062         */
    063        int    CHKSUMLEN = 8;
    064
    065        /**
    066         * The length of the size field in a header buffer.
    067         * Includes the trailing space or NUL.
    068         */
    069        int    SIZELEN = 12;
    070
    071        /**
    072         * The maximum size of a file in a tar archive (That's 11 sevens, octal).
    073         */
    074        long   MAXSIZE = 077777777777L;
    075
    076        /** Offset of start of magic field within header record */
    077        int    MAGIC_OFFSET = 257;
    078        /**
    079         * The length of the magic field in a header buffer.
    080         */
    081        int    MAGICLEN = 6;
    082
    083        /** Offset of start of magic field within header record */
    084        int    VERSION_OFFSET = 263;
    085        /**
    086         * Previously this was regarded as part of "magic" field, but it is separate.
    087         */
    088        int    VERSIONLEN = 2;
    089
    090        /**
    091         * The length of the modification time field in a header buffer.
    092         */
    093        int    MODTIMELEN = 12;
    094
    095        /**
    096         * The length of the user name field in a header buffer.
    097         */
    098        int    UNAMELEN = 32;
    099
    100        /**
    101         * The length of the group name field in a header buffer.
    102         */
    103        int    GNAMELEN = 32;
    104
    105        /**
    106         * The length of each of the device fields (major and minor) in a header buffer.
    107         */
    108        int    DEVLEN = 8;
    109
    110        /**
    111         * Length of the prefix field.
    112         *
    113         */
    114        int    PREFIXLEN = 155;
    115
    116        /**
    117         * The length of the access time field in an old GNU header buffer.
    118         *
    119         */
    120        int    ATIMELEN_GNU = 12;
    121
    122        /**
    123         * The length of the created time field in an old GNU header buffer.
    124         *
    125         */
    126        int    CTIMELEN_GNU = 12;
    127
    128        /**
    129         * The length of the multivolume start offset field in an old GNU header buffer.
    130         *
    131         */
    132        int    OFFSETLEN_GNU = 12;
    133
    134        /**
    135         * The length of the long names field in an old GNU header buffer.
    136         *
    137         */
    138        int    LONGNAMESLEN_GNU = 4;
    139
    140        /**
    141         * The length of the padding field in an old GNU header buffer.
    142         *
    143         */
    144        int    PAD2LEN_GNU = 1;
    145
    146        /**
    147         * The sum of the length of all sparse headers in an old GNU header buffer.
    148         *
    149         */
    150        int    SPARSELEN_GNU = 96;
    151
    152        /**
    153         * The length of the is extension field in an old GNU header buffer.
    154         *
    155         */
    156        int    ISEXTENDEDLEN_GNU = 1;
    157
    158        /**
    159         * The length of the real size field in an old GNU header buffer.
    160         *
    161         */
    162        int    REALSIZELEN_GNU = 12;
    163
    164        /**
    165         * The sum of the length of all sparse headers in a sparse header buffer.
    166         *
    167         */
    168        int    SPARSELEN_GNU_SPARSE = 504;
    169
    170        /**
    171         * The length of the is extension field in a sparse header buffer.
    172         *
    173         */
    174        int    ISEXTENDEDLEN_GNU_SPARSE = 1;
    175
    176        /**
    177         * LF_ constants represent the "link flag" of an entry, or more commonly,
    178         * the "entry type". This is the "old way" of indicating a normal file.
    179         */
    180        byte   LF_OLDNORM = 0;
    181
    182        /**
    183         * Normal file type.
    184         */
    185        byte   LF_NORMAL = (byte) '0';
    186
    187        /**
    188         * Link file type.
    189         */
    190        byte   LF_LINK = (byte) '1';
    191
    192        /**
    193         * Symbolic link file type.
    194         */
    195        byte   LF_SYMLINK = (byte) '2';
    196
    197        /**
    198         * Character device file type.
    199         */
    200        byte   LF_CHR = (byte) '3';
    201
    202        /**
    203         * Block device file type.
    204         */
    205        byte   LF_BLK = (byte) '4';
    206
    207        /**
    208         * Directory file type.
    209         */
    210        byte   LF_DIR = (byte) '5';
    211
    212        /**
    213         * FIFO (pipe) file type.
    214         */
    215        byte   LF_FIFO = (byte) '6';
    216
    217        /**
    218         * Contiguous file type.
    219         */
    220        byte   LF_CONTIG = (byte) '7';
    221
    222        /**
    223         * Identifies the *next* file on the tape as having a long name.
    224         */
    225        byte LF_GNUTYPE_LONGNAME = (byte) 'L';
    226
    227        /**
    228         * Sparse file type.
    229         * @since Apache Commons Compress 1.1.1
    230         */
    231        byte LF_GNUTYPE_SPARSE = (byte) 'S';
    232
    233        // See "http://www.opengroup.org/onlinepubs/009695399/utilities/pax.html#tag_04_100_13_02"
    234
    235        /**
    236         * Identifies the entry as a Pax extended header.
    237         * @since Apache Commons Compress 1.1
    238         */
    239        byte LF_PAX_EXTENDED_HEADER_LC = (byte) 'x';
    240
    241        /**
    242         * Identifies the entry as a Pax extended header (SunOS tar -E).
    243         *
    244         * @since Apache Commons Compress 1.1
    245         */
    246        byte LF_PAX_EXTENDED_HEADER_UC = (byte) 'X';
    247
    248        /**
    249         * Identifies the entry as a Pax global extended header.
    250         *
    251         * @since Apache Commons Compress 1.1
    252         */
    253        byte LF_PAX_GLOBAL_EXTENDED_HEADER = (byte) 'g';
    254
    255        /**
    256         * The magic tag representing a POSIX tar archive.
    257         */
    258        String MAGIC_POSIX = "ustar\0";
    259        String VERSION_POSIX = "00";
    260
    261        /**
    262         * The magic tag representing a GNU tar archive.
    263         */
    264        String MAGIC_GNU = "ustar ";
    265        // Appear to be two possible GNU versions
    266        String VERSION_GNU_SPACE = " \0";
    267        String VERSION_GNU_ZERO  = "0\0";
    268
    269        /**
    270         * The magic tag representing an Ant tar archive.
    271         *
    272         * @since Apache Commons Compress 1.1
    273         */
    274        String MAGIC_ANT = "ustar\0";
    275
    276        /**
    277         * The "version" representing an Ant tar archive.
    278         *
    279         * @since Apache Commons Compress 1.1
    280         */
    281        // Does not appear to have a version, however Ant does write 8 bytes,
    282        // so assume the version is 2 nulls
    283        String VERSION_ANT = "\0\0";
    284
    285        /**
    286         * The name of the GNU tar entry which contains a long name.
    287         */
    288        String GNU_LONGLINK = "././@LongLink"; // TODO rename as LONGLINK_GNU ?
    289
    290    }