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