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