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 * xstar format used by Jörg Schilling's star. 048 */ 049 int FORMAT_XSTAR = 4; 050 051 /** 052 * The length of the name field in a header buffer. 053 */ 054 int NAMELEN = 100; 055 056 /** 057 * The length of the mode field in a header buffer. 058 */ 059 int MODELEN = 8; 060 061 /** 062 * The length of the user id field in a header buffer. 063 */ 064 int UIDLEN = 8; 065 066 /** 067 * The length of the group id field in a header buffer. 068 */ 069 int GIDLEN = 8; 070 071 /** 072 * The maximum value of gid/uid in a tar archive which can be expressed in octal char notation (that's 7 sevens, octal). 073 */ 074 long MAXID = 07777777L; 075 076 /** 077 * The length of the checksum field in a header buffer. 078 */ 079 int CHKSUMLEN = 8; 080 081 /** 082 * Offset of the checksum field within header record. 083 * 084 * @since 1.5 085 */ 086 int CHKSUM_OFFSET = 148; 087 088 /** 089 * The length of the size field in a header buffer. Includes the trailing space or NUL. 090 */ 091 int SIZELEN = 12; 092 093 /** 094 * The maximum size of a file in a tar archive which can be expressed in octal char notation (that's 11 sevens, octal). 095 */ 096 long MAXSIZE = 077777777777L; 097 098 /** Offset of start of magic field within header record */ 099 int MAGIC_OFFSET = 257; 100 /** 101 * The length of the magic field in a header buffer. 102 */ 103 int MAGICLEN = 6; 104 105 /** Offset of start of magic field within header record */ 106 int VERSION_OFFSET = 263; 107 /** 108 * Previously this was regarded as part of "magic" field, but it is separate. 109 */ 110 int VERSIONLEN = 2; 111 112 /** 113 * The length of the modification time field in a header buffer. 114 */ 115 int MODTIMELEN = 12; 116 117 /** 118 * The length of the user name field in a header buffer. 119 */ 120 int UNAMELEN = 32; 121 122 /** 123 * The length of the group name field in a header buffer. 124 */ 125 int GNAMELEN = 32; 126 127 /** 128 * The length of each of the device fields (major and minor) in a header buffer. 129 */ 130 int DEVLEN = 8; 131 132 /** 133 * Length of the prefix field. 134 * 135 */ 136 int PREFIXLEN = 155; 137 138 /** 139 * The length of the access time field in an old GNU header buffer. 140 * 141 */ 142 int ATIMELEN_GNU = 12; 143 144 /** 145 * The length of the created time field in an old GNU header buffer. 146 * 147 */ 148 int CTIMELEN_GNU = 12; 149 150 /** 151 * The length of the multivolume start offset field in an old GNU header buffer. 152 * 153 */ 154 int OFFSETLEN_GNU = 12; 155 156 /** 157 * The length of the long names field in an old GNU header buffer. 158 * 159 */ 160 int LONGNAMESLEN_GNU = 4; 161 162 /** 163 * The length of the padding field in an old GNU header buffer. 164 * 165 */ 166 int PAD2LEN_GNU = 1; 167 168 /** 169 * The sum of the length of all sparse headers in an old GNU header buffer. 170 * 171 */ 172 int SPARSELEN_GNU = 96; 173 174 /** 175 * The length of the is extension field in an old GNU header buffer. 176 * 177 */ 178 int ISEXTENDEDLEN_GNU = 1; 179 180 /** 181 * The length of the real size field in an old GNU header buffer. 182 * 183 */ 184 int REALSIZELEN_GNU = 12; 185 186 /** 187 * The length of offset in struct sparse 188 * 189 * @since 1.20 190 */ 191 int SPARSE_OFFSET_LEN = 12; 192 193 /** 194 * The length of numbytes in struct sparse 195 * 196 * @since 1.20 197 */ 198 int SPARSE_NUMBYTES_LEN = 12; 199 200 /** 201 * The number of sparse headers in an old GNU header 202 * 203 * @since 1.20 204 */ 205 int SPARSE_HEADERS_IN_OLDGNU_HEADER = 4; 206 207 /** 208 * The number of sparse headers in an extension header 209 * 210 * @since 1.20 211 */ 212 int SPARSE_HEADERS_IN_EXTENSION_HEADER = 21; 213 214 /** 215 * The sum of the length of all sparse headers in a sparse header buffer. 216 * 217 */ 218 int SPARSELEN_GNU_SPARSE = 504; 219 220 /** 221 * The length of the is extension field in a sparse header buffer. 222 * 223 */ 224 int ISEXTENDEDLEN_GNU_SPARSE = 1; 225 226 /** 227 * LF_ constants represent the "link flag" of an entry, or more commonly, the "entry type". This is the "old way" of 228 * indicating a normal file. 229 */ 230 byte LF_OLDNORM = 0; 231 232 /** 233 * Offset inside the header for the "link flag" field. 234 * 235 * @since 1.22 236 * @see TarArchiveEntry 237 */ 238 int LF_OFFSET = 156; 239 240 /** 241 * Normal file type. 242 */ 243 byte LF_NORMAL = (byte) '0'; 244 245 /** 246 * Link file type. 247 */ 248 byte LF_LINK = (byte) '1'; 249 250 /** 251 * Symbolic link file type. 252 */ 253 byte LF_SYMLINK = (byte) '2'; 254 255 /** 256 * Character device file type. 257 */ 258 byte LF_CHR = (byte) '3'; 259 260 /** 261 * Block device file type. 262 */ 263 byte LF_BLK = (byte) '4'; 264 265 /** 266 * Directory file type. 267 */ 268 byte LF_DIR = (byte) '5'; 269 270 /** 271 * FIFO (pipe) file type. 272 */ 273 byte LF_FIFO = (byte) '6'; 274 275 /** 276 * Contiguous file type. 277 */ 278 byte LF_CONTIG = (byte) '7'; 279 280 /** 281 * Identifies the *next* file on the tape as having a long linkname. 282 */ 283 byte LF_GNUTYPE_LONGLINK = (byte) 'K'; 284 285 /** 286 * Identifies the *next* file on the tape as having a long name. 287 */ 288 byte LF_GNUTYPE_LONGNAME = (byte) 'L'; 289 290 /** 291 * Sparse file type. 292 * @since 1.1.1 293 */ 294 byte LF_GNUTYPE_SPARSE = (byte) 'S'; 295 296 // See "http://www.opengroup.org/onlinepubs/009695399/utilities/pax.html#tag_04_100_13_02" 297 298 /** 299 * Identifies the entry as a Pax extended header. 300 * @since 1.1 301 */ 302 byte LF_PAX_EXTENDED_HEADER_LC = (byte) 'x'; 303 304 /** 305 * Identifies the entry as a Pax extended header (SunOS tar -E). 306 * 307 * @since 1.1 308 */ 309 byte LF_PAX_EXTENDED_HEADER_UC = (byte) 'X'; 310 311 /** 312 * Identifies the entry as a Pax global extended header. 313 * 314 * @since 1.1 315 */ 316 byte LF_PAX_GLOBAL_EXTENDED_HEADER = (byte) 'g'; 317 318 /** 319 * Identifies the entry as a multi-volume past volume #0 320 * 321 * @since 1.22 322 */ 323 byte LF_MULTIVOLUME = (byte) 'M'; 324 325 /** 326 * The magic tag representing a POSIX tar archive. 327 */ 328 String MAGIC_POSIX = "ustar\0"; 329 String VERSION_POSIX = "00"; 330 331 /** 332 * The magic tag representing a GNU tar archive. 333 */ 334 String MAGIC_GNU = "ustar "; 335 336 /** 337 * One of two two possible GNU versions 338 */ 339 String VERSION_GNU_SPACE = " \0"; 340 341 /** 342 * One of two two possible GNU versions 343 */ 344 String VERSION_GNU_ZERO = "0\0"; 345 346 /** 347 * The magic tag representing an Ant tar archive. 348 * 349 * @since 1.1 350 */ 351 String MAGIC_ANT = "ustar\0"; 352 353 /** 354 * The "version" representing an Ant tar archive. 355 * 356 * @since 1.1 357 */ 358 // Does not appear to have a version, however Ant does write 8 bytes, 359 // so assume the version is 2 nulls 360 String VERSION_ANT = "\0\0"; 361 362 /** 363 * The name of the GNU tar entry which contains a long name. 364 */ 365 String GNU_LONGLINK = "././@LongLink"; // TODO rename as LONGLINK_GNU ? 366 367 /** 368 * The magix string used in the last four bytes of the header to 369 * identify the xstar format. 370 * @since 1.11 371 */ 372 String MAGIC_XSTAR = "tar\0"; 373 374 /** 375 * Offset inside the header for the xtar multivolume data 376 * 377 * @since 1.22 378 * @see TarArchiveEntry 379 */ 380 int XSTAR_MULTIVOLUME_OFFSET = 464; 381 382 /** 383 * Offset inside the header for the xstar magic bytes. 384 * @since 1.11 385 */ 386 int XSTAR_MAGIC_OFFSET = 508; 387 388 /** 389 * Length of the XSTAR magic. 390 * @since 1.11 391 */ 392 int XSTAR_MAGIC_LEN = 4; 393 394 /** 395 * Length of the prefix field in xstar archives. 396 * 397 * @since 1.11 398 */ 399 int PREFIXLEN_XSTAR = 131; 400 401 /** 402 * Offset inside the header for the prefix field in xstar archives. 403 * 404 * @since 1.22 405 * @see TarArchiveEntry 406 */ 407 int XSTAR_PREFIX_OFFSET = 345; 408 409 /** 410 * Offset inside the header for the atime field in xstar archives. 411 * 412 * @since 1.22 413 * @see TarArchiveEntry 414 */ 415 int XSTAR_ATIME_OFFSET = 476; 416 417 /** 418 * The length of the access time field in a xstar header buffer. 419 * 420 * @since 1.11 421 */ 422 int ATIMELEN_XSTAR = 12; 423 424 /** 425 * Offset inside the header for the ctime field in xstar archives. 426 * 427 * @since 1.22 428 * @see TarArchiveEntry 429 */ 430 int XSTAR_CTIME_OFFSET = 488; 431 432 /** 433 * The length of the created time field in a xstar header buffer. 434 * 435 * @since 1.11 436 */ 437 int CTIMELEN_XSTAR = 12; 438}