Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 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.cpio; |
| 20 | |
Sebastian Bazley | fec51a1 | 2009-03-31 00:35:56 +0000 | [diff] [blame] | 21 | import java.io.File; |
Stefan Bodewig | 17ffd7f | 2009-08-01 14:52:15 +0000 | [diff] [blame] | 22 | import java.util.Date; |
Sebastian Bazley | fec51a1 | 2009-03-31 00:35:56 +0000 | [diff] [blame] | 23 | |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 24 | import org.apache.commons.compress.archivers.ArchiveEntry; |
| 25 | |
| 26 | /** |
| 27 | * A cpio archive consists of a sequence of files. There are several types of |
| 28 | * headers defided in two categories of new and old format. The headers are |
Stefan Bodewig | 176337a | 2009-03-23 09:10:50 +0000 | [diff] [blame] | 29 | * recognized by magic numbers: |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 30 | * |
Stefan Bodewig | 176337a | 2009-03-23 09:10:50 +0000 | [diff] [blame] | 31 | * <ul> |
| 32 | * <li>"070701" ASCII for new portable format</li> |
Stefan Bodewig | 46212e5 | 2013-01-20 17:07:40 +0000 | [diff] [blame] | 33 | * <li>"070702" ASCII for new portable format with CRC</li> |
Stefan Bodewig | 176337a | 2009-03-23 09:10:50 +0000 | [diff] [blame] | 34 | * <li>"070707" ASCII for old ascii (also known as Portable ASCII, odc or old |
| 35 | * character format</li> |
Sebastian Bazley | b7ea671 | 2009-03-26 15:38:47 +0000 | [diff] [blame] | 36 | * <li>070707 binary for old binary</li> |
Stefan Bodewig | 176337a | 2009-03-23 09:10:50 +0000 | [diff] [blame] | 37 | * </ul> |
Sebastian Bazley | b7ea671 | 2009-03-26 15:38:47 +0000 | [diff] [blame] | 38 | * |
Stefan Bodewig | 176337a | 2009-03-23 09:10:50 +0000 | [diff] [blame] | 39 | * <p>The old binary format is limited to 16 bits for user id, group |
| 40 | * id, device, and inode numbers. It is limited to 4 gigabyte file |
| 41 | * sizes. |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 42 | * |
Stefan Bodewig | 176337a | 2009-03-23 09:10:50 +0000 | [diff] [blame] | 43 | * The old ASCII format is limited to 18 bits for the user id, group |
| 44 | * id, device, and inode numbers. It is limited to 8 gigabyte file |
| 45 | * sizes. |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 46 | * |
Stefan Bodewig | 176337a | 2009-03-23 09:10:50 +0000 | [diff] [blame] | 47 | * The new ASCII format is limited to 4 gigabyte file sizes. |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 48 | * |
Stefan Bodewig | 176337a | 2009-03-23 09:10:50 +0000 | [diff] [blame] | 49 | * CPIO 2.5 knows also about tar, but it is not recognized here.</p> |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 50 | * |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 51 | * |
Stefan Bodewig | 176337a | 2009-03-23 09:10:50 +0000 | [diff] [blame] | 52 | * <h3>OLD FORMAT</h3> |
Stefan Bodewig | 41f4a20 | 2009-03-20 15:42:37 +0000 | [diff] [blame] | 53 | * |
Stefan Bodewig | 176337a | 2009-03-23 09:10:50 +0000 | [diff] [blame] | 54 | * <p>Each file has a 76 (ascii) / 26 (binary) byte header, a variable |
| 55 | * length, NUL terminated filename, and variable length file data. A |
| 56 | * header for a filename "TRAILER!!!" indicates the end of the |
| 57 | * archive.</p> |
| 58 | * |
| 59 | * <p>All the fields in the header are ISO 646 (approximately ASCII) |
| 60 | * strings of octal numbers, left padded, not NUL terminated.</p> |
| 61 | * |
| 62 | * <pre> |
| 63 | * FIELDNAME NOTES |
| 64 | * c_magic The integer value octal 070707. This value can be used to deter- |
| 65 | * mine whether this archive is written with little-endian or big- |
| 66 | * endian integers. |
| 67 | * c_dev Device that contains a directory entry for this file |
| 68 | * c_ino I-node number that identifies the input file to the file system |
| 69 | * c_mode The mode specifies both the regular permissions and the file type. |
| 70 | * c_uid Numeric User ID of the owner of the input file |
| 71 | * c_gid Numeric Group ID of the owner of the input file |
| 72 | * c_nlink Number of links that are connected to the input file |
| 73 | * c_rdev For block special and character special entries, this field |
| 74 | * contains the associated device number. For all other entry types, |
| 75 | * it should be set to zero by writers and ignored by readers. |
| 76 | * c_mtime[2] Modification time of the file, indicated as the number of seconds |
| 77 | * since the start of the epoch, 00:00:00 UTC January 1, 1970. The |
| 78 | * four-byte integer is stored with the most-significant 16 bits |
| 79 | * first followed by the least-significant 16 bits. Each of the two |
| 80 | * 16 bit values are stored in machine-native byte order. |
| 81 | * c_namesize Length of the path name, including the terminating null byte |
| 82 | * c_filesize[2] Length of the file in bytes. This is the length of the data |
| 83 | * section that follows the header structure. Must be 0 for |
| 84 | * FIFOs and directories |
Stefan Bodewig | 06fbac9 | 2009-08-01 14:53:32 +0000 | [diff] [blame] | 85 | * |
Stefan Bodewig | 176337a | 2009-03-23 09:10:50 +0000 | [diff] [blame] | 86 | * All fields are unsigned short fields with 16-bit integer values |
Sebastian Bazley | 1b2e300 | 2009-03-27 17:44:16 +0000 | [diff] [blame] | 87 | * apart from c_mtime and c_filesize which are 32-bit integer values |
Stefan Bodewig | 176337a | 2009-03-23 09:10:50 +0000 | [diff] [blame] | 88 | * </pre> |
| 89 | * |
Sebastian Bazley | 1b2e300 | 2009-03-27 17:44:16 +0000 | [diff] [blame] | 90 | * <p>If necessary, the filename and file data are padded with a NUL byte to an even length</p> |
| 91 | * |
Stefan Bodewig | 176337a | 2009-03-23 09:10:50 +0000 | [diff] [blame] | 92 | * <p>Special files, directories, and the trailer are recorded with |
| 93 | * the h_filesize field equal to 0.</p> |
| 94 | * |
Sebastian Bazley | 1b2e300 | 2009-03-27 17:44:16 +0000 | [diff] [blame] | 95 | * <p>In the ASCII version of this format, the 16-bit entries are represented as 6-byte octal numbers, |
| 96 | * and the 32-bit entries are represented as 11-byte octal numbers. No padding is added.</p> |
Stefan Bodewig | 176337a | 2009-03-23 09:10:50 +0000 | [diff] [blame] | 97 | * |
| 98 | * <h3>NEW FORMAT</h3> |
| 99 | * |
| 100 | * <p>Each file has a 110 byte header, a variable length, NUL |
| 101 | * terminated filename, and variable length file data. A header for a |
| 102 | * filename "TRAILER!!!" indicates the end of the archive. All the |
| 103 | * fields in the header are ISO 646 (approximately ASCII) strings of |
| 104 | * hexadecimal numbers, left padded, not NUL terminated.</p> |
| 105 | * |
| 106 | * <pre> |
| 107 | * FIELDNAME NOTES |
| 108 | * c_magic[6] The string 070701 for new ASCII, the string 070702 for new ASCII with CRC |
| 109 | * c_ino[8] |
| 110 | * c_mode[8] |
| 111 | * c_uid[8] |
| 112 | * c_gid[8] |
| 113 | * c_nlink[8] |
| 114 | * c_mtim[8] |
| 115 | * c_filesize[8] must be 0 for FIFOs and directories |
| 116 | * c_maj[8] |
| 117 | * c_min[8] |
| 118 | * c_rmaj[8] only valid for chr and blk special files |
| 119 | * c_rmin[8] only valid for chr and blk special files |
| 120 | * c_namesize[8] count includes terminating NUL in pathname |
| 121 | * c_check[8] 0 for "new" portable format; for CRC format |
| 122 | * the sum of all the bytes in the file |
| 123 | * </pre> |
| 124 | * |
| 125 | * <p>New ASCII Format The "new" ASCII format uses 8-byte hexadecimal |
| 126 | * fields for all numbers and separates device numbers into separate |
| 127 | * fields for major and minor numbers.</p> |
| 128 | * |
| 129 | * <p>The pathname is followed by NUL bytes so that the total size of |
| 130 | * the fixed header plus pathname is a multiple of four. Likewise, the |
| 131 | * file data is padded to a multiple of four bytes.</p> |
| 132 | * |
| 133 | * <p>This class uses mutable fields and is not considered to be |
| 134 | * threadsafe.</p> |
| 135 | * |
Sebastian Bazley | 70ce471 | 2009-04-14 15:38:08 +0000 | [diff] [blame] | 136 | * <p>Based on code from the jRPM project (http://jrpm.sourceforge.net).</p> |
Stefan Bodewig | 176337a | 2009-03-23 09:10:50 +0000 | [diff] [blame] | 137 | * |
Sebastian Bazley | 70ce471 | 2009-04-14 15:38:08 +0000 | [diff] [blame] | 138 | * <p>The MAGIC numbers and other constants are defined in {@link CpioConstants}</p> |
Sebastian Bazley | f17ce4b | 2009-03-27 20:47:56 +0000 | [diff] [blame] | 139 | * |
Sebastian Bazley | 1736719 | 2009-03-28 19:33:56 +0000 | [diff] [blame] | 140 | * <p> |
| 141 | * N.B. does not handle the cpio "tar" format |
| 142 | * </p> |
Sebastian Bazley | f17ce4b | 2009-03-27 20:47:56 +0000 | [diff] [blame] | 143 | * @NotThreadSafe |
Sebastian Bazley | 70ce471 | 2009-04-14 15:38:08 +0000 | [diff] [blame] | 144 | * @see "http://people.freebsd.org/~kientzle/libarchive/man/cpio.5.txt" |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 145 | */ |
| 146 | public class CpioArchiveEntry implements CpioConstants, ArchiveEntry { |
Stefan Bodewig | 41f4a20 | 2009-03-20 15:42:37 +0000 | [diff] [blame] | 147 | |
Sebastian Bazley | db7f577 | 2009-03-26 20:27:25 +0000 | [diff] [blame] | 148 | // Header description fields - should be same throughout an archive |
Stefan Bodewig | 06fbac9 | 2009-08-01 14:53:32 +0000 | [diff] [blame] | 149 | |
Sebastian Bazley | 0a8aaa5 | 2009-03-26 15:56:48 +0000 | [diff] [blame] | 150 | /** |
Stefan Bodewig | 57cb8c8 | 2010-02-18 13:08:31 +0000 | [diff] [blame] | 151 | * See constructor documenation for possible values. |
Sebastian Bazley | 0a8aaa5 | 2009-03-26 15:56:48 +0000 | [diff] [blame] | 152 | */ |
Sebastian Bazley | f17ce4b | 2009-03-27 20:47:56 +0000 | [diff] [blame] | 153 | private final short fileFormat; |
Sebastian Bazley | db7f577 | 2009-03-26 20:27:25 +0000 | [diff] [blame] | 154 | |
| 155 | /** The number of bytes in each header record; depends on the file format */ |
Sebastian Bazley | f17ce4b | 2009-03-27 20:47:56 +0000 | [diff] [blame] | 156 | private final int headerSize; |
Sebastian Bazley | 1b2e300 | 2009-03-27 17:44:16 +0000 | [diff] [blame] | 157 | |
| 158 | /** The boundary to which the header and data elements are aligned: 0, 2 or 4 bytes */ |
Sebastian Bazley | f17ce4b | 2009-03-27 20:47:56 +0000 | [diff] [blame] | 159 | private final int alignmentBoundary; |
Sebastian Bazley | db7f577 | 2009-03-26 20:27:25 +0000 | [diff] [blame] | 160 | |
| 161 | // Header fields |
Stefan Bodewig | 06fbac9 | 2009-08-01 14:53:32 +0000 | [diff] [blame] | 162 | |
Sebastian Bazley | db7f577 | 2009-03-26 20:27:25 +0000 | [diff] [blame] | 163 | private long chksum = 0; |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 164 | |
Sebastian Bazley | 1b2e300 | 2009-03-27 17:44:16 +0000 | [diff] [blame] | 165 | /** Number of bytes in the file */ |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 166 | private long filesize = 0; |
| 167 | |
| 168 | private long gid = 0; |
| 169 | |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 170 | private long inode = 0; |
| 171 | |
| 172 | private long maj = 0; |
| 173 | |
| 174 | private long min = 0; |
| 175 | |
Sebastian Bazley | db7f577 | 2009-03-26 20:27:25 +0000 | [diff] [blame] | 176 | private long mode = 0; |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 177 | |
Sebastian Bazley | db7f577 | 2009-03-26 20:27:25 +0000 | [diff] [blame] | 178 | private long mtime = 0; |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 179 | |
| 180 | private String name; |
| 181 | |
| 182 | private long nlink = 0; |
| 183 | |
| 184 | private long rmaj = 0; |
| 185 | |
| 186 | private long rmin = 0; |
| 187 | |
| 188 | private long uid = 0; |
| 189 | |
| 190 | /** |
Stefan Bodewig | 57cb8c8 | 2010-02-18 13:08:31 +0000 | [diff] [blame] | 191 | * Creates a CPIOArchiveEntry with a specified format. |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 192 | * |
| 193 | * @param format |
| 194 | * The cpio format for this entry. |
Sebastian Bazley | f17ce4b | 2009-03-27 20:47:56 +0000 | [diff] [blame] | 195 | * <br/> |
| 196 | * Possible format values are: |
| 197 | * <p> |
| 198 | * CpioConstants.FORMAT_NEW<br/> |
| 199 | * CpioConstants.FORMAT_NEW_CRC<br/> |
| 200 | * CpioConstants.FORMAT_OLD_BINARY<br/> |
| 201 | * CpioConstants.FORMAT_OLD_ASCII<br/> |
| 202 | * |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 203 | */ |
| 204 | public CpioArchiveEntry(final short format) { |
Sebastian Bazley | f17ce4b | 2009-03-27 20:47:56 +0000 | [diff] [blame] | 205 | switch (format) { |
| 206 | case FORMAT_NEW: |
| 207 | this.headerSize = 110; |
| 208 | this.alignmentBoundary = 4; |
| 209 | break; |
| 210 | case FORMAT_NEW_CRC: |
| 211 | this.headerSize = 110; |
| 212 | this.alignmentBoundary = 4; |
| 213 | break; |
| 214 | case FORMAT_OLD_ASCII: |
| 215 | this.headerSize = 76; |
| 216 | this.alignmentBoundary = 0; |
| 217 | break; |
| 218 | case FORMAT_OLD_BINARY: |
| 219 | this.headerSize = 26; |
| 220 | this.alignmentBoundary = 2; |
| 221 | break; |
| 222 | default: |
| 223 | throw new IllegalArgumentException("Unknown header type"); |
| 224 | } |
| 225 | this.fileFormat = format; |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | /** |
Stefan Bodewig | 57cb8c8 | 2010-02-18 13:08:31 +0000 | [diff] [blame] | 229 | * Creates a CPIOArchiveEntry with a specified name. The format of |
| 230 | * this entry will be the new format. |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 231 | * |
| 232 | * @param name |
| 233 | * The name of this entry. |
| 234 | */ |
| 235 | public CpioArchiveEntry(final String name) { |
Stefan Bodewig | 57cb8c8 | 2010-02-18 13:08:31 +0000 | [diff] [blame] | 236 | this(FORMAT_NEW, name); |
| 237 | } |
| 238 | |
| 239 | /** |
| 240 | * Creates a CPIOArchiveEntry with a specified name. |
| 241 | * |
| 242 | * @param format |
| 243 | * The cpio format for this entry. |
| 244 | * @param name |
| 245 | * The name of this entry. |
| 246 | * <br/> |
| 247 | * Possible format values are: |
| 248 | * <p> |
| 249 | * CpioConstants.FORMAT_NEW<br/> |
| 250 | * CpioConstants.FORMAT_NEW_CRC<br/> |
| 251 | * CpioConstants.FORMAT_OLD_BINARY<br/> |
| 252 | * CpioConstants.FORMAT_OLD_ASCII<br/> |
Sebastian Bazley | 6209f81 | 2010-05-10 17:36:40 +0000 | [diff] [blame] | 253 | * |
Gary D. Gregory | 2bd0dd4 | 2012-04-01 13:02:39 +0000 | [diff] [blame] | 254 | * @since 1.1 |
Stefan Bodewig | 57cb8c8 | 2010-02-18 13:08:31 +0000 | [diff] [blame] | 255 | */ |
| 256 | public CpioArchiveEntry(final short format, final String name) { |
| 257 | this(format); |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 258 | this.name = name; |
| 259 | } |
| 260 | |
| 261 | /** |
Stefan Bodewig | 57cb8c8 | 2010-02-18 13:08:31 +0000 | [diff] [blame] | 262 | * Creates a CPIOArchiveEntry with a specified name. The format of |
| 263 | * this entry will be the new format. |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 264 | * |
| 265 | * @param name |
| 266 | * The name of this entry. |
| 267 | * @param size |
Stefan Bodewig | 41f4a20 | 2009-03-20 15:42:37 +0000 | [diff] [blame] | 268 | * The size of this entry |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 269 | */ |
| 270 | public CpioArchiveEntry(final String name, final long size) { |
Stefan Bodewig | 57cb8c8 | 2010-02-18 13:08:31 +0000 | [diff] [blame] | 271 | this(name); |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 272 | this.setSize(size); |
| 273 | } |
Stefan Bodewig | 41f4a20 | 2009-03-20 15:42:37 +0000 | [diff] [blame] | 274 | |
Stefan Bodewig | 57cb8c8 | 2010-02-18 13:08:31 +0000 | [diff] [blame] | 275 | /** |
| 276 | * Creates a CPIOArchiveEntry with a specified name. |
| 277 | * |
| 278 | * @param format |
| 279 | * The cpio format for this entry. |
| 280 | * @param name |
| 281 | * The name of this entry. |
| 282 | * @param size |
| 283 | * The size of this entry |
| 284 | * <br/> |
| 285 | * Possible format values are: |
| 286 | * <p> |
| 287 | * CpioConstants.FORMAT_NEW<br/> |
| 288 | * CpioConstants.FORMAT_NEW_CRC<br/> |
| 289 | * CpioConstants.FORMAT_OLD_BINARY<br/> |
| 290 | * CpioConstants.FORMAT_OLD_ASCII<br/> |
Sebastian Bazley | 6209f81 | 2010-05-10 17:36:40 +0000 | [diff] [blame] | 291 | * |
Gary D. Gregory | 2bd0dd4 | 2012-04-01 13:02:39 +0000 | [diff] [blame] | 292 | * @since 1.1 |
Stefan Bodewig | 57cb8c8 | 2010-02-18 13:08:31 +0000 | [diff] [blame] | 293 | */ |
| 294 | public CpioArchiveEntry(final short format, final String name, |
| 295 | final long size) { |
| 296 | this(format, name); |
| 297 | this.setSize(size); |
| 298 | } |
| 299 | |
| 300 | /** |
| 301 | * Creates a CPIOArchiveEntry with a specified name for a |
| 302 | * specified file. The format of this entry will be the new |
| 303 | * format. |
| 304 | * |
| 305 | * @param inputFile |
| 306 | * The file to gather information from. |
| 307 | * @param entryName |
| 308 | * The name of this entry. |
| 309 | */ |
Sebastian Bazley | fec51a1 | 2009-03-31 00:35:56 +0000 | [diff] [blame] | 310 | public CpioArchiveEntry(File inputFile, String entryName) { |
Stefan Bodewig | 57cb8c8 | 2010-02-18 13:08:31 +0000 | [diff] [blame] | 311 | this(FORMAT_NEW, inputFile, entryName); |
| 312 | } |
| 313 | |
| 314 | /** |
| 315 | * Creates a CPIOArchiveEntry with a specified name for a |
| 316 | * specified file. |
| 317 | * |
| 318 | * @param format |
| 319 | * The cpio format for this entry. |
| 320 | * @param inputFile |
| 321 | * The file to gather information from. |
| 322 | * @param entryName |
| 323 | * The name of this entry. |
| 324 | * <br/> |
| 325 | * Possible format values are: |
| 326 | * <p> |
| 327 | * CpioConstants.FORMAT_NEW<br/> |
| 328 | * CpioConstants.FORMAT_NEW_CRC<br/> |
| 329 | * CpioConstants.FORMAT_OLD_BINARY<br/> |
| 330 | * CpioConstants.FORMAT_OLD_ASCII<br/> |
Sebastian Bazley | 6209f81 | 2010-05-10 17:36:40 +0000 | [diff] [blame] | 331 | * |
Gary D. Gregory | 2bd0dd4 | 2012-04-01 13:02:39 +0000 | [diff] [blame] | 332 | * @since 1.1 |
Stefan Bodewig | 57cb8c8 | 2010-02-18 13:08:31 +0000 | [diff] [blame] | 333 | */ |
| 334 | public CpioArchiveEntry(final short format, File inputFile, |
| 335 | String entryName) { |
| 336 | this(format, entryName, inputFile.isFile() ? inputFile.length() : 0); |
Sebastian Bazley | fec51a1 | 2009-03-31 00:35:56 +0000 | [diff] [blame] | 337 | long mode=0; |
| 338 | if (inputFile.isDirectory()){ |
| 339 | mode |= C_ISDIR; |
| 340 | } else if (inputFile.isFile()){ |
| 341 | mode |= C_ISREG; |
| 342 | } else { |
Stefan Bodewig | 57cb8c8 | 2010-02-18 13:08:31 +0000 | [diff] [blame] | 343 | throw new IllegalArgumentException("Cannot determine type of file " |
| 344 | + inputFile.getName()); |
Sebastian Bazley | fec51a1 | 2009-03-31 00:35:56 +0000 | [diff] [blame] | 345 | } |
| 346 | // TODO set other fields as needed |
| 347 | setMode(mode); |
Stefan Bodewig | e1640e5 | 2009-08-01 20:07:53 +0000 | [diff] [blame] | 348 | setTime(inputFile.lastModified() / 1000); |
Sebastian Bazley | fec51a1 | 2009-03-31 00:35:56 +0000 | [diff] [blame] | 349 | } |
| 350 | |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 351 | /** |
| 352 | * Check if the method is allowed for the defined format. |
| 353 | */ |
| 354 | private void checkNewFormat() { |
| 355 | if ((this.fileFormat & FORMAT_NEW_MASK) == 0) { |
| 356 | throw new UnsupportedOperationException(); |
| 357 | } |
| 358 | } |
| 359 | |
| 360 | /** |
| 361 | * Check if the method is allowed for the defined format. |
| 362 | */ |
| 363 | private void checkOldFormat() { |
| 364 | if ((this.fileFormat & FORMAT_OLD_MASK) == 0) { |
| 365 | throw new UnsupportedOperationException(); |
| 366 | } |
| 367 | } |
| 368 | |
| 369 | /** |
| 370 | * Get the checksum. |
Sebastian Bazley | 1b2e300 | 2009-03-27 17:44:16 +0000 | [diff] [blame] | 371 | * Only supported for the new formats. |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 372 | * |
| 373 | * @return Returns the checksum. |
Sebastian Bazley | 1b2e300 | 2009-03-27 17:44:16 +0000 | [diff] [blame] | 374 | * @throws UnsupportedOperationException if the format is not a new format |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 375 | */ |
| 376 | public long getChksum() { |
| 377 | checkNewFormat(); |
| 378 | return this.chksum; |
| 379 | } |
| 380 | |
| 381 | /** |
| 382 | * Get the device id. |
| 383 | * |
| 384 | * @return Returns the device id. |
| 385 | * @throws UnsupportedOperationException |
Stefan Bodewig | 41f4a20 | 2009-03-20 15:42:37 +0000 | [diff] [blame] | 386 | * if this method is called for a CPIOArchiveEntry with a new |
| 387 | * format. |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 388 | */ |
| 389 | public long getDevice() { |
| 390 | checkOldFormat(); |
| 391 | return this.min; |
| 392 | } |
| 393 | |
| 394 | /** |
| 395 | * Get the major device id. |
| 396 | * |
| 397 | * @return Returns the major device id. |
| 398 | * @throws UnsupportedOperationException |
Stefan Bodewig | 41f4a20 | 2009-03-20 15:42:37 +0000 | [diff] [blame] | 399 | * if this method is called for a CPIOArchiveEntry with an old |
| 400 | * format. |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 401 | */ |
| 402 | public long getDeviceMaj() { |
| 403 | checkNewFormat(); |
| 404 | return this.maj; |
| 405 | } |
| 406 | |
| 407 | /** |
| 408 | * Get the minor device id |
| 409 | * |
| 410 | * @return Returns the minor device id. |
Sebastian Bazley | 1b2e300 | 2009-03-27 17:44:16 +0000 | [diff] [blame] | 411 | * @throws UnsupportedOperationException if format is not a new format |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 412 | */ |
| 413 | public long getDeviceMin() { |
| 414 | checkNewFormat(); |
| 415 | return this.min; |
| 416 | } |
| 417 | |
| 418 | /** |
| 419 | * Get the filesize. |
| 420 | * |
| 421 | * @return Returns the filesize. |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 422 | * @see org.apache.commons.compress.archivers.ArchiveEntry#getSize() |
| 423 | */ |
| 424 | public long getSize() { |
| 425 | return this.filesize; |
| 426 | } |
| 427 | |
| 428 | /** |
| 429 | * Get the format for this entry. |
| 430 | * |
| 431 | * @return Returns the format. |
| 432 | */ |
| 433 | public short getFormat() { |
| 434 | return this.fileFormat; |
| 435 | } |
| 436 | |
| 437 | /** |
| 438 | * Get the group id. |
| 439 | * |
| 440 | * @return Returns the group id. |
| 441 | */ |
| 442 | public long getGID() { |
| 443 | return this.gid; |
| 444 | } |
| 445 | |
| 446 | /** |
Sebastian Bazley | 1b2e300 | 2009-03-27 17:44:16 +0000 | [diff] [blame] | 447 | * Get the header size for this CPIO format |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 448 | * |
Sebastian Bazley | 1b2e300 | 2009-03-27 17:44:16 +0000 | [diff] [blame] | 449 | * @return Returns the header size in bytes. |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 450 | */ |
Sebastian Bazley | 1b2e300 | 2009-03-27 17:44:16 +0000 | [diff] [blame] | 451 | public int getHeaderSize() { |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 452 | return this.headerSize; |
| 453 | } |
| 454 | |
| 455 | /** |
Sebastian Bazley | 1b2e300 | 2009-03-27 17:44:16 +0000 | [diff] [blame] | 456 | * Get the alignment boundary for this CPIO format |
| 457 | * |
| 458 | * @return Returns the aligment boundary (0, 2, 4) in bytes |
| 459 | */ |
| 460 | public int getAlignmentBoundary() { |
| 461 | return this.alignmentBoundary; |
| 462 | } |
| 463 | |
| 464 | /** |
| 465 | * Get the number of bytes needed to pad the header to the alignment boundary. |
| 466 | * |
| 467 | * @return the number of bytes needed to pad the header (0,1,2,3) |
| 468 | */ |
| 469 | public int getHeaderPadCount(){ |
Sebastian Bazley | a0e435e | 2012-03-31 10:59:47 +0000 | [diff] [blame] | 470 | if (this.alignmentBoundary == 0) { return 0; } |
Sebastian Bazley | 1b2e300 | 2009-03-27 17:44:16 +0000 | [diff] [blame] | 471 | int size = this.headerSize+this.name.length()+1; // Name has terminating null |
| 472 | int remain = size % this.alignmentBoundary; |
| 473 | if (remain > 0){ |
| 474 | return this.alignmentBoundary - remain; |
| 475 | } |
| 476 | return 0; |
| 477 | } |
| 478 | |
| 479 | /** |
| 480 | * Get the number of bytes needed to pad the data to the alignment boundary. |
| 481 | * |
| 482 | * @return the number of bytes needed to pad the data (0,1,2,3) |
| 483 | */ |
| 484 | public int getDataPadCount(){ |
Sebastian Bazley | a0e435e | 2012-03-31 10:59:47 +0000 | [diff] [blame] | 485 | if (this.alignmentBoundary == 0) { return 0; } |
Sebastian Bazley | 1b2e300 | 2009-03-27 17:44:16 +0000 | [diff] [blame] | 486 | long size = this.filesize; |
| 487 | int remain = (int) (size % this.alignmentBoundary); |
| 488 | if (remain > 0){ |
| 489 | return this.alignmentBoundary - remain; |
| 490 | } |
| 491 | return 0; |
| 492 | } |
| 493 | |
| 494 | /** |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 495 | * Set the inode. |
| 496 | * |
| 497 | * @return Returns the inode. |
| 498 | */ |
| 499 | public long getInode() { |
| 500 | return this.inode; |
| 501 | } |
| 502 | |
| 503 | /** |
| 504 | * Get the mode of this entry (e.g. directory, regular file). |
| 505 | * |
| 506 | * @return Returns the mode. |
| 507 | */ |
| 508 | public long getMode() { |
Stefan Bodewig | b11dca2 | 2010-02-18 11:55:21 +0000 | [diff] [blame] | 509 | return mode == 0 && !CPIO_TRAILER.equals(name) ? C_ISREG : mode; |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 510 | } |
| 511 | |
| 512 | /** |
| 513 | * Get the name. |
| 514 | * |
| 515 | * @return Returns the name. |
| 516 | */ |
| 517 | public String getName() { |
| 518 | return this.name; |
| 519 | } |
| 520 | |
| 521 | /** |
| 522 | * Get the number of links. |
| 523 | * |
| 524 | * @return Returns the number of links. |
| 525 | */ |
| 526 | public long getNumberOfLinks() { |
Stefan Bodewig | b11dca2 | 2010-02-18 11:55:21 +0000 | [diff] [blame] | 527 | return nlink == 0 ? |
| 528 | (isDirectory() ? 2 : 1) |
| 529 | : nlink; |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 530 | } |
| 531 | |
| 532 | /** |
| 533 | * Get the remote device id. |
| 534 | * |
| 535 | * @return Returns the remote device id. |
| 536 | * @throws UnsupportedOperationException |
Stefan Bodewig | 41f4a20 | 2009-03-20 15:42:37 +0000 | [diff] [blame] | 537 | * if this method is called for a CPIOArchiveEntry with a new |
| 538 | * format. |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 539 | */ |
| 540 | public long getRemoteDevice() { |
| 541 | checkOldFormat(); |
| 542 | return this.rmin; |
| 543 | } |
| 544 | |
| 545 | /** |
| 546 | * Get the remote major device id. |
| 547 | * |
| 548 | * @return Returns the remote major device id. |
| 549 | * @throws UnsupportedOperationException |
Stefan Bodewig | 41f4a20 | 2009-03-20 15:42:37 +0000 | [diff] [blame] | 550 | * if this method is called for a CPIOArchiveEntry with an old |
| 551 | * format. |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 552 | */ |
| 553 | public long getRemoteDeviceMaj() { |
| 554 | checkNewFormat(); |
| 555 | return this.rmaj; |
| 556 | } |
| 557 | |
| 558 | /** |
| 559 | * Get the remote minor device id. |
| 560 | * |
| 561 | * @return Returns the remote minor device id. |
| 562 | * @throws UnsupportedOperationException |
Stefan Bodewig | 41f4a20 | 2009-03-20 15:42:37 +0000 | [diff] [blame] | 563 | * if this method is called for a CPIOArchiveEntry with an old |
| 564 | * format. |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 565 | */ |
| 566 | public long getRemoteDeviceMin() { |
| 567 | checkNewFormat(); |
| 568 | return this.rmin; |
| 569 | } |
| 570 | |
| 571 | /** |
| 572 | * Get the time in seconds. |
| 573 | * |
| 574 | * @return Returns the time. |
| 575 | */ |
| 576 | public long getTime() { |
| 577 | return this.mtime; |
| 578 | } |
| 579 | |
Stefan Bodewig | 17ffd7f | 2009-08-01 14:52:15 +0000 | [diff] [blame] | 580 | public Date getLastModifiedDate() { |
| 581 | return new Date(1000 * getTime()); |
| 582 | } |
| 583 | |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 584 | /** |
| 585 | * Get the user id. |
| 586 | * |
| 587 | * @return Returns the user id. |
| 588 | */ |
| 589 | public long getUID() { |
| 590 | return this.uid; |
| 591 | } |
| 592 | |
| 593 | /** |
| 594 | * Check if this entry represents a block device. |
| 595 | * |
| 596 | * @return TRUE if this entry is a block device. |
| 597 | */ |
| 598 | public boolean isBlockDevice() { |
| 599 | return (this.mode & S_IFMT) == C_ISBLK; |
| 600 | } |
| 601 | |
| 602 | /** |
| 603 | * Check if this entry represents a character device. |
| 604 | * |
| 605 | * @return TRUE if this entry is a character device. |
| 606 | */ |
| 607 | public boolean isCharacterDevice() { |
| 608 | return (this.mode & S_IFMT) == C_ISCHR; |
| 609 | } |
| 610 | |
| 611 | /** |
| 612 | * Check if this entry represents a directory. |
| 613 | * |
| 614 | * @return TRUE if this entry is a directory. |
| 615 | */ |
| 616 | public boolean isDirectory() { |
| 617 | return (this.mode & S_IFMT) == C_ISDIR; |
| 618 | } |
| 619 | |
| 620 | /** |
| 621 | * Check if this entry represents a network device. |
| 622 | * |
| 623 | * @return TRUE if this entry is a network device. |
| 624 | */ |
| 625 | public boolean isNetwork() { |
| 626 | return (this.mode & S_IFMT) == C_ISNWK; |
| 627 | } |
| 628 | |
| 629 | /** |
| 630 | * Check if this entry represents a pipe. |
| 631 | * |
| 632 | * @return TRUE if this entry is a pipe. |
| 633 | */ |
| 634 | public boolean isPipe() { |
| 635 | return (this.mode & S_IFMT) == C_ISFIFO; |
| 636 | } |
| 637 | |
| 638 | /** |
| 639 | * Check if this entry represents a regular file. |
| 640 | * |
| 641 | * @return TRUE if this entry is a regular file. |
| 642 | */ |
| 643 | public boolean isRegularFile() { |
| 644 | return (this.mode & S_IFMT) == C_ISREG; |
| 645 | } |
| 646 | |
| 647 | /** |
| 648 | * Check if this entry represents a socket. |
| 649 | * |
| 650 | * @return TRUE if this entry is a socket. |
| 651 | */ |
| 652 | public boolean isSocket() { |
| 653 | return (this.mode & S_IFMT) == C_ISSOCK; |
| 654 | } |
| 655 | |
| 656 | /** |
| 657 | * Check if this entry represents a symbolic link. |
| 658 | * |
| 659 | * @return TRUE if this entry is a symbolic link. |
| 660 | */ |
| 661 | public boolean isSymbolicLink() { |
| 662 | return (this.mode & S_IFMT) == C_ISLNK; |
| 663 | } |
| 664 | |
| 665 | /** |
| 666 | * Set the checksum. The checksum is calculated by adding all bytes of a |
| 667 | * file to transfer (crc += buf[pos] & 0xFF). |
| 668 | * |
| 669 | * @param chksum |
| 670 | * The checksum to set. |
| 671 | */ |
| 672 | public void setChksum(final long chksum) { |
| 673 | checkNewFormat(); |
| 674 | this.chksum = chksum; |
| 675 | } |
| 676 | |
| 677 | /** |
| 678 | * Set the device id. |
| 679 | * |
| 680 | * @param device |
| 681 | * The device id to set. |
| 682 | * @throws UnsupportedOperationException |
Stefan Bodewig | 41f4a20 | 2009-03-20 15:42:37 +0000 | [diff] [blame] | 683 | * if this method is called for a CPIOArchiveEntry with a new |
| 684 | * format. |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 685 | */ |
| 686 | public void setDevice(final long device) { |
| 687 | checkOldFormat(); |
| 688 | this.min = device; |
| 689 | } |
| 690 | |
| 691 | /** |
| 692 | * Set major device id. |
| 693 | * |
| 694 | * @param maj |
| 695 | * The major device id to set. |
| 696 | */ |
| 697 | public void setDeviceMaj(final long maj) { |
| 698 | checkNewFormat(); |
| 699 | this.maj = maj; |
| 700 | } |
| 701 | |
| 702 | /** |
| 703 | * Set the minor device id |
| 704 | * |
| 705 | * @param min |
| 706 | * The minor device id to set. |
| 707 | */ |
| 708 | public void setDeviceMin(final long min) { |
| 709 | checkNewFormat(); |
| 710 | this.min = min; |
| 711 | } |
| 712 | |
| 713 | /** |
| 714 | * Set the filesize. |
| 715 | * |
| 716 | * @param size |
| 717 | * The filesize to set. |
| 718 | */ |
| 719 | public void setSize(final long size) { |
| 720 | if (size < 0 || size > 0xFFFFFFFFL) { |
| 721 | throw new IllegalArgumentException("invalid entry size <" + size |
Stefan Bodewig | 06fbac9 | 2009-08-01 14:53:32 +0000 | [diff] [blame] | 722 | + ">"); |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 723 | } |
| 724 | this.filesize = size; |
| 725 | } |
| 726 | |
| 727 | /** |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 728 | * Set the group id. |
| 729 | * |
| 730 | * @param gid |
| 731 | * The group id to set. |
| 732 | */ |
| 733 | public void setGID(final long gid) { |
| 734 | this.gid = gid; |
| 735 | } |
| 736 | |
| 737 | /** |
| 738 | * Set the inode. |
| 739 | * |
| 740 | * @param inode |
| 741 | * The inode to set. |
| 742 | */ |
| 743 | public void setInode(final long inode) { |
| 744 | this.inode = inode; |
| 745 | } |
| 746 | |
| 747 | /** |
| 748 | * Set the mode of this entry (e.g. directory, regular file). |
| 749 | * |
| 750 | * @param mode |
| 751 | * The mode to set. |
| 752 | */ |
| 753 | public void setMode(final long mode) { |
Sebastian Bazley | 8c36ce3 | 2009-03-26 13:40:38 +0000 | [diff] [blame] | 754 | final long maskedMode = mode & S_IFMT; |
| 755 | switch ((int) maskedMode) { |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 756 | case C_ISDIR: |
| 757 | case C_ISLNK: |
| 758 | case C_ISREG: |
| 759 | case C_ISFIFO: |
| 760 | case C_ISCHR: |
| 761 | case C_ISBLK: |
| 762 | case C_ISSOCK: |
| 763 | case C_ISNWK: |
| 764 | break; |
| 765 | default: |
Sebastian Bazley | 84f836e | 2009-03-26 20:54:47 +0000 | [diff] [blame] | 766 | throw new IllegalArgumentException( |
Stefan Bodewig | 06fbac9 | 2009-08-01 14:53:32 +0000 | [diff] [blame] | 767 | "Unknown mode. " |
| 768 | + "Full: " + Long.toHexString(mode) |
| 769 | + " Masked: " + Long.toHexString(maskedMode)); |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 770 | } |
| 771 | |
| 772 | this.mode = mode; |
| 773 | } |
| 774 | |
| 775 | /** |
| 776 | * Set the name. |
| 777 | * |
| 778 | * @param name |
| 779 | * The name to set. |
| 780 | */ |
| 781 | public void setName(final String name) { |
| 782 | this.name = name; |
| 783 | } |
| 784 | |
| 785 | /** |
| 786 | * Set the number of links. |
| 787 | * |
| 788 | * @param nlink |
| 789 | * The number of links to set. |
| 790 | */ |
| 791 | public void setNumberOfLinks(final long nlink) { |
| 792 | this.nlink = nlink; |
| 793 | } |
| 794 | |
| 795 | /** |
| 796 | * Set the remote device id. |
| 797 | * |
| 798 | * @param device |
| 799 | * The remote device id to set. |
| 800 | * @throws UnsupportedOperationException |
Stefan Bodewig | 41f4a20 | 2009-03-20 15:42:37 +0000 | [diff] [blame] | 801 | * if this method is called for a CPIOArchiveEntry with a new |
| 802 | * format. |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 803 | */ |
| 804 | public void setRemoteDevice(final long device) { |
| 805 | checkOldFormat(); |
| 806 | this.rmin = device; |
| 807 | } |
| 808 | |
| 809 | /** |
| 810 | * Set the remote major device id. |
| 811 | * |
| 812 | * @param rmaj |
| 813 | * The remote major device id to set. |
| 814 | * @throws UnsupportedOperationException |
Stefan Bodewig | 41f4a20 | 2009-03-20 15:42:37 +0000 | [diff] [blame] | 815 | * if this method is called for a CPIOArchiveEntry with an old |
| 816 | * format. |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 817 | */ |
| 818 | public void setRemoteDeviceMaj(final long rmaj) { |
| 819 | checkNewFormat(); |
| 820 | this.rmaj = rmaj; |
| 821 | } |
| 822 | |
| 823 | /** |
| 824 | * Set the remote minor device id. |
| 825 | * |
| 826 | * @param rmin |
| 827 | * The remote minor device id to set. |
| 828 | * @throws UnsupportedOperationException |
Stefan Bodewig | 41f4a20 | 2009-03-20 15:42:37 +0000 | [diff] [blame] | 829 | * if this method is called for a CPIOArchiveEntry with an old |
| 830 | * format. |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 831 | */ |
| 832 | public void setRemoteDeviceMin(final long rmin) { |
| 833 | checkNewFormat(); |
| 834 | this.rmin = rmin; |
| 835 | } |
| 836 | |
| 837 | /** |
| 838 | * Set the time in seconds. |
| 839 | * |
| 840 | * @param time |
| 841 | * The time to set. |
| 842 | */ |
| 843 | public void setTime(final long time) { |
| 844 | this.mtime = time; |
| 845 | } |
| 846 | |
| 847 | /** |
| 848 | * Set the user id. |
| 849 | * |
| 850 | * @param uid |
| 851 | * The user id to set. |
| 852 | */ |
| 853 | public void setUID(final long uid) { |
| 854 | this.uid = uid; |
| 855 | } |
Christian Grobmeier | 28c23fb | 2009-04-17 05:14:49 +0000 | [diff] [blame] | 856 | |
| 857 | /* (non-Javadoc) |
| 858 | * @see java.lang.Object#hashCode() |
| 859 | */ |
Stefan Bodewig | 46628ef | 2011-08-06 16:30:40 +0000 | [diff] [blame] | 860 | @Override |
Christian Grobmeier | 28c23fb | 2009-04-17 05:14:49 +0000 | [diff] [blame] | 861 | public int hashCode() { |
| 862 | final int prime = 31; |
| 863 | int result = 1; |
| 864 | result = prime * result + ((name == null) ? 0 : name.hashCode()); |
| 865 | return result; |
| 866 | } |
| 867 | |
| 868 | /* (non-Javadoc) |
| 869 | * @see java.lang.Object#equals(java.lang.Object) |
| 870 | */ |
Stefan Bodewig | 46628ef | 2011-08-06 16:30:40 +0000 | [diff] [blame] | 871 | @Override |
Christian Grobmeier | 28c23fb | 2009-04-17 05:14:49 +0000 | [diff] [blame] | 872 | public boolean equals(Object obj) { |
| 873 | if (this == obj) { |
| 874 | return true; |
| 875 | } |
| 876 | if (obj == null || getClass() != obj.getClass()) { |
| 877 | return false; |
| 878 | } |
| 879 | CpioArchiveEntry other = (CpioArchiveEntry) obj; |
| 880 | if (name == null) { |
| 881 | if (other.name != null) { |
| 882 | return false; |
| 883 | } |
| 884 | } else if (!name.equals(other.name)) { |
| 885 | return false; |
| 886 | } |
| 887 | return true; |
| 888 | } |
Torsten Curdt | 70c8320 | 2009-01-12 11:09:21 +0000 | [diff] [blame] | 889 | } |