• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements.  See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership.  The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License.  You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied.  See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 package org.apache.commons.compress.archivers.tar;
20 
21 /**
22  * This interface contains all the definitions used in the package.
23  *
24  * For tar formats (FORMAT_OLDGNU, FORMAT_POSIX, etc.) see GNU tar
25  * <I>tar.h</I> type <I>enum archive_format</I>
26  */
27 // CheckStyle:InterfaceIsTypeCheck OFF (bc)
28 public interface TarConstants {
29 
30     /** Default record size */
31     int DEFAULT_RCDSIZE = 512;
32 
33     /** Default block size */
34     int DEFAULT_BLKSIZE = DEFAULT_RCDSIZE * 20;
35 
36     /**
37      * GNU format as per before tar 1.12.
38      */
39     int    FORMAT_OLDGNU = 2;
40 
41     /**
42      * Pure Posix format.
43      */
44     int    FORMAT_POSIX = 3;
45 
46     /**
47      * xstar format used by Jörg Schilling's star.
48      */
49     int    FORMAT_XSTAR = 4;
50 
51     /**
52      * The length of the name field in a header buffer.
53      */
54     int    NAMELEN = 100;
55 
56     /**
57      * The length of the mode field in a header buffer.
58      */
59     int    MODELEN = 8;
60 
61     /**
62      * The length of the user id field in a header buffer.
63      */
64     int    UIDLEN = 8;
65 
66     /**
67      * The length of the group id field in a header buffer.
68      */
69     int    GIDLEN = 8;
70 
71     /**
72      * The maximum value of gid/uid in a tar archive which can
73      * be expressed in octal char notation (that's 7 sevens, octal).
74      */
75     long    MAXID = 07777777L;
76 
77     /**
78      * The length of the checksum field in a header buffer.
79      */
80     int    CHKSUMLEN = 8;
81 
82     /**
83      * Offset of the checksum field within header record.
84      * @since 1.5
85      */
86     int    CHKSUM_OFFSET = 148;
87 
88     /**
89      * The length of the size field in a header buffer.
90      * Includes the trailing space or NUL.
91      */
92     int    SIZELEN = 12;
93 
94     /**
95      * The maximum size of a file in a tar archive
96      * which can be expressed in octal char notation (that's 11 sevens, octal).
97      */
98     long   MAXSIZE = 077777777777L;
99 
100     /** Offset of start of magic field within header record */
101     int    MAGIC_OFFSET = 257;
102     /**
103      * The length of the magic field in a header buffer.
104      */
105     int    MAGICLEN = 6;
106 
107     /** Offset of start of magic field within header record */
108     int    VERSION_OFFSET = 263;
109     /**
110      * Previously this was regarded as part of "magic" field, but it is separate.
111      */
112     int    VERSIONLEN = 2;
113 
114     /**
115      * The length of the modification time field in a header buffer.
116      */
117     int    MODTIMELEN = 12;
118 
119     /**
120      * The length of the user name field in a header buffer.
121      */
122     int    UNAMELEN = 32;
123 
124     /**
125      * The length of the group name field in a header buffer.
126      */
127     int    GNAMELEN = 32;
128 
129     /**
130      * The length of each of the device fields (major and minor) in a header buffer.
131      */
132     int    DEVLEN = 8;
133 
134     /**
135      * Length of the prefix field.
136      *
137      */
138     int    PREFIXLEN = 155;
139 
140     /**
141      * The length of the access time field in an old GNU header buffer.
142      *
143      */
144     int    ATIMELEN_GNU = 12;
145 
146     /**
147      * The length of the created time field in an old GNU header buffer.
148      *
149      */
150     int    CTIMELEN_GNU = 12;
151 
152     /**
153      * The length of the multivolume start offset field in an old GNU header buffer.
154      *
155      */
156     int    OFFSETLEN_GNU = 12;
157 
158     /**
159      * The length of the long names field in an old GNU header buffer.
160      *
161      */
162     int    LONGNAMESLEN_GNU = 4;
163 
164     /**
165      * The length of the padding field in an old GNU header buffer.
166      *
167      */
168     int    PAD2LEN_GNU = 1;
169 
170     /**
171      * The sum of the length of all sparse headers in an old GNU header buffer.
172      *
173      */
174     int    SPARSELEN_GNU = 96;
175 
176     /**
177      * The length of the is extension field in an old GNU header buffer.
178      *
179      */
180     int    ISEXTENDEDLEN_GNU = 1;
181 
182     /**
183      * The length of the real size field in an old GNU header buffer.
184      *
185      */
186     int    REALSIZELEN_GNU = 12;
187 
188     /**
189      * The sum of the length of all sparse headers in a sparse header buffer.
190      *
191      */
192     int    SPARSELEN_GNU_SPARSE = 504;
193 
194     /**
195      * The length of the is extension field in a sparse header buffer.
196      *
197      */
198     int    ISEXTENDEDLEN_GNU_SPARSE = 1;
199 
200     /**
201      * LF_ constants represent the "link flag" of an entry, or more commonly,
202      * the "entry type". This is the "old way" of indicating a normal file.
203      */
204     byte   LF_OLDNORM = 0;
205 
206     /**
207      * Normal file type.
208      */
209     byte   LF_NORMAL = (byte) '0';
210 
211     /**
212      * Link file type.
213      */
214     byte   LF_LINK = (byte) '1';
215 
216     /**
217      * Symbolic link file type.
218      */
219     byte   LF_SYMLINK = (byte) '2';
220 
221     /**
222      * Character device file type.
223      */
224     byte   LF_CHR = (byte) '3';
225 
226     /**
227      * Block device file type.
228      */
229     byte   LF_BLK = (byte) '4';
230 
231     /**
232      * Directory file type.
233      */
234     byte   LF_DIR = (byte) '5';
235 
236     /**
237      * FIFO (pipe) file type.
238      */
239     byte   LF_FIFO = (byte) '6';
240 
241     /**
242      * Contiguous file type.
243      */
244     byte   LF_CONTIG = (byte) '7';
245 
246     /**
247      * Identifies the *next* file on the tape as having a long linkname.
248      */
249     byte LF_GNUTYPE_LONGLINK = (byte) 'K';
250 
251     /**
252      * Identifies the *next* file on the tape as having a long name.
253      */
254     byte LF_GNUTYPE_LONGNAME = (byte) 'L';
255 
256     /**
257      * Sparse file type.
258      * @since 1.1.1
259      */
260     byte LF_GNUTYPE_SPARSE = (byte) 'S';
261 
262     // See "http://www.opengroup.org/onlinepubs/009695399/utilities/pax.html#tag_04_100_13_02"
263 
264     /**
265      * Identifies the entry as a Pax extended header.
266      * @since 1.1
267      */
268     byte LF_PAX_EXTENDED_HEADER_LC = (byte) 'x';
269 
270     /**
271      * Identifies the entry as a Pax extended header (SunOS tar -E).
272      *
273      * @since 1.1
274      */
275     byte LF_PAX_EXTENDED_HEADER_UC = (byte) 'X';
276 
277     /**
278      * Identifies the entry as a Pax global extended header.
279      *
280      * @since 1.1
281      */
282     byte LF_PAX_GLOBAL_EXTENDED_HEADER = (byte) 'g';
283 
284     /**
285      * The magic tag representing a POSIX tar archive.
286      */
287     String MAGIC_POSIX = "ustar\0";
288     String VERSION_POSIX = "00";
289 
290     /**
291      * The magic tag representing a GNU tar archive.
292      */
293     String MAGIC_GNU = "ustar ";
294     // Appear to be two possible GNU versions
295     String VERSION_GNU_SPACE = " \0";
296     String VERSION_GNU_ZERO  = "0\0";
297 
298     /**
299      * The magic tag representing an Ant tar archive.
300      *
301      * @since 1.1
302      */
303     String MAGIC_ANT = "ustar\0";
304 
305     /**
306      * The "version" representing an Ant tar archive.
307      *
308      * @since 1.1
309      */
310     // Does not appear to have a version, however Ant does write 8 bytes,
311     // so assume the version is 2 nulls
312     String VERSION_ANT = "\0\0";
313 
314     /**
315      * The name of the GNU tar entry which contains a long name.
316      */
317     String GNU_LONGLINK = "././@LongLink"; // TODO rename as LONGLINK_GNU ?
318 
319     /**
320      * The magix string used in the last four bytes of the header to
321      * identify the xstar format.
322      * @since 1.11
323      */
324     String MAGIC_XSTAR = "tar\0";
325 
326     /**
327      * Offset inside the header for the xstar magic bytes.
328      * @since 1.11
329      */
330     int XSTAR_MAGIC_OFFSET = 508;
331 
332     /**
333      * Length of the XSTAR magic.
334      * @since 1.11
335      */
336     int XSTAR_MAGIC_LEN = 4;
337 
338     /**
339      * Length of the prefix field in xstar archives.
340      *
341      * @since 1.11
342      */
343     int PREFIXLEN_XSTAR = 131;
344 
345     /**
346      * The length of the access time field in a xstar header buffer.
347      *
348      * @since 1.11
349      */
350     int ATIMELEN_XSTAR = 12;
351 
352     /**
353      * The length of the created time field in a xstar header buffer.
354      *
355      * @since 1.11
356      */
357     int CTIMELEN_XSTAR = 12;
358 }
359