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 /**
31 * GNU format as per before tar 1.12.
32 */
33 int FORMAT_OLDGNU = 2;
34
35 /**
36 * Pure Posix format.
37 */
38 int FORMAT_POSIX = 3;
39
40 /**
41 * The length of the name field in a header buffer.
42 */
43 int NAMELEN = 100;
44
45 /**
46 * The length of the mode field in a header buffer.
47 */
48 int MODELEN = 8;
49
50 /**
51 * The length of the user id field in a header buffer.
52 */
53 int UIDLEN = 8;
54
55 /**
56 * The length of the group id field in a header buffer.
57 */
58 int GIDLEN = 8;
59
60 /**
61 * The maximum value of gid/uid in a tar archive which can
62 * be expressed in octal char notation (that's 7 sevens, octal).
63 */
64 long MAXID = 07777777L;
65
66 /**
67 * The length of the checksum field in a header buffer.
68 */
69 int CHKSUMLEN = 8;
70
71 /**
72 * Offset of the checksum field within header record.
73 * @since 1.5
74 */
75 int CHKSUM_OFFSET = 148;
76
77 /**
78 * The length of the size field in a header buffer.
79 * Includes the trailing space or NUL.
80 */
81 int SIZELEN = 12;
82
83 /**
84 * The maximum size of a file in a tar archive
85 * which can be expressed in octal char notation (that's 11 sevens, octal).
86 */
87 long MAXSIZE = 077777777777L;
88
89 /** Offset of start of magic field within header record */
90 int MAGIC_OFFSET = 257;
91 /**
92 * The length of the magic field in a header buffer.
93 */
94 int MAGICLEN = 6;
95
96 /** Offset of start of magic field within header record */
97 int VERSION_OFFSET = 263;
98 /**
99 * 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 linkname.
237 */
238 byte LF_GNUTYPE_LONGLINK = (byte) 'K';
239
240 /**
241 * Identifies the *next* file on the tape as having a long name.
242 */
243 byte LF_GNUTYPE_LONGNAME = (byte) 'L';
244
245 /**
246 * Sparse file type.
247 * @since 1.1.1
248 */
249 byte LF_GNUTYPE_SPARSE = (byte) 'S';
250
251 // See "http://www.opengroup.org/onlinepubs/009695399/utilities/pax.html#tag_04_100_13_02"
252
253 /**
254 * Identifies the entry as a Pax extended header.
255 * @since 1.1
256 */
257 byte LF_PAX_EXTENDED_HEADER_LC = (byte) 'x';
258
259 /**
260 * Identifies the entry as a Pax extended header (SunOS tar -E).
261 *
262 * @since 1.1
263 */
264 byte LF_PAX_EXTENDED_HEADER_UC = (byte) 'X';
265
266 /**
267 * Identifies the entry as a Pax global extended header.
268 *
269 * @since 1.1
270 */
271 byte LF_PAX_GLOBAL_EXTENDED_HEADER = (byte) 'g';
272
273 /**
274 * The magic tag representing a POSIX tar archive.
275 */
276 String MAGIC_POSIX = "ustar\0";
277 String VERSION_POSIX = "00";
278
279 /**
280 * The magic tag representing a GNU tar archive.
281 */
282 String MAGIC_GNU = "ustar ";
283 // Appear to be two possible GNU versions
284 String VERSION_GNU_SPACE = " \0";
285 String VERSION_GNU_ZERO = "0\0";
286
287 /**
288 * The magic tag representing an Ant tar archive.
289 *
290 * @since 1.1
291 */
292 String MAGIC_ANT = "ustar\0";
293
294 /**
295 * The "version" representing an Ant tar archive.
296 *
297 * @since 1.1
298 */
299 // Does not appear to have a version, however Ant does write 8 bytes,
300 // so assume the version is 2 nulls
301 String VERSION_ANT = "\0\0";
302
303 /**
304 * The name of the GNU tar entry which contains a long name.
305 */
306 String GNU_LONGLINK = "././@LongLink"; // TODO rename as LONGLINK_GNU ?
307
308 }