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