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 */ 025 // CheckStyle:InterfaceIsTypeCheck OFF (bc) 026 public interface TarConstants { 027 028 /** 029 * The length of the name field in a header buffer. 030 */ 031 int NAMELEN = 100; 032 033 /** 034 * The length of the mode field in a header buffer. 035 */ 036 int MODELEN = 8; 037 038 /** 039 * The length of the user id field in a header buffer. 040 */ 041 int UIDLEN = 8; 042 043 /** 044 * The length of the group id field in a header buffer. 045 */ 046 int GIDLEN = 8; 047 048 /** 049 * The length of the checksum field in a header buffer. 050 */ 051 int CHKSUMLEN = 8; 052 053 /** 054 * The length of the size field in a header buffer. 055 * Includes the trailing space or NUL. 056 */ 057 int SIZELEN = 12; 058 059 /** 060 * The maximum size of a file in a tar archive (That's 11 sevens, octal). 061 */ 062 long MAXSIZE = 077777777777L; 063 064 /** Offset of start of magic field within header record */ 065 int MAGIC_OFFSET = 257; 066 /** 067 * The length of the magic field in a header buffer. 068 */ 069 int MAGICLEN = 6; 070 071 /** Offset of start of magic field within header record */ 072 int VERSION_OFFSET = 263; 073 /** 074 * Previously this was regarded as part of "magic" field, but it is separate. 075 */ 076 int VERSIONLEN = 2; 077 078 /** 079 * The length of the modification time field in a header buffer. 080 */ 081 int MODTIMELEN = 12; 082 083 /** 084 * The length of the user name field in a header buffer. 085 */ 086 int UNAMELEN = 32; 087 088 /** 089 * The length of the group name field in a header buffer. 090 */ 091 int GNAMELEN = 32; 092 093 /** 094 * The length of each of the device fields (major and minor) in a header buffer. 095 */ 096 int DEVLEN = 8; 097 098 /** 099 * Length of the prefix field. 100 * 101 */ 102 int PREFIXLEN = 155; 103 104 /** 105 * LF_ constants represent the "link flag" of an entry, or more commonly, 106 * the "entry type". This is the "old way" of indicating a normal file. 107 */ 108 byte LF_OLDNORM = 0; 109 110 /** 111 * Normal file type. 112 */ 113 byte LF_NORMAL = (byte) '0'; 114 115 /** 116 * Link file type. 117 */ 118 byte LF_LINK = (byte) '1'; 119 120 /** 121 * Symbolic link file type. 122 */ 123 byte LF_SYMLINK = (byte) '2'; 124 125 /** 126 * Character device file type. 127 */ 128 byte LF_CHR = (byte) '3'; 129 130 /** 131 * Block device file type. 132 */ 133 byte LF_BLK = (byte) '4'; 134 135 /** 136 * Directory file type. 137 */ 138 byte LF_DIR = (byte) '5'; 139 140 /** 141 * FIFO (pipe) file type. 142 */ 143 byte LF_FIFO = (byte) '6'; 144 145 /** 146 * Contiguous file type. 147 */ 148 byte LF_CONTIG = (byte) '7'; 149 150 /** 151 * Identifies the *next* file on the tape as having a long name. 152 */ 153 byte LF_GNUTYPE_LONGNAME = (byte) 'L'; 154 155 // See "http://www.opengroup.org/onlinepubs/009695399/utilities/pax.html#tag_04_100_13_02" 156 157 /** 158 * Identifies the entry as a Pax extended header. 159 * @since Apache Commons Compress 1.1 160 */ 161 byte LF_PAX_EXTENDED_HEADER_LC = (byte) 'x'; 162 163 /** 164 * Identifies the entry as a Pax extended header (SunOS tar -E). 165 * 166 * @since Apache Commons Compress 1.1 167 */ 168 byte LF_PAX_EXTENDED_HEADER_UC = (byte) 'X'; 169 170 /** 171 * Identifies the entry as a Pax global extended header. 172 * 173 * @since Apache Commons Compress 1.1 174 */ 175 byte LF_PAX_GLOBAL_EXTENDED_HEADER = (byte) 'g'; 176 177 /** 178 * The magic tag representing a POSIX tar archive. 179 */ 180 String MAGIC_POSIX = "ustar\0"; 181 String VERSION_POSIX = "00"; 182 183 /** 184 * The magic tag representing a GNU tar archive. 185 */ 186 String MAGIC_GNU = "ustar "; 187 // Appear to be two possible GNU versions 188 String VERSION_GNU_SPACE = " \0"; 189 String VERSION_GNU_ZERO = "0\0"; 190 191 /** 192 * The magic tag representing an Ant tar archive. 193 * 194 * @since Apache Commons Compress 1.1 195 */ 196 String MAGIC_ANT = "ustar\0"; 197 198 /** 199 * The "version" representing an Ant tar archive. 200 * 201 * @since Apache Commons Compress 1.1 202 */ 203 // Does not appear to have a version, however Ant does write 8 bytes, 204 // so assume the version is 2 nulls 205 String VERSION_ANT = "\0\0"; 206 207 /** 208 * The name of the GNU tar entry which contains a long name. 209 */ 210 String GNU_LONGLINK = "././@LongLink"; // TODO rename as LONGLINK_GNU ? 211 212 }