1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.tools.build.apkzlib.zip;
18 
19 /**
20  * Type of data descriptor that an entry has. Data descriptors are used if the CRC and sizing data
21  * is not known when the data is being written and cannot be placed in the file's local header.
22  * In those cases, after the file data itself, a data descriptor is placed after the entry's
23  * contents.
24  * <p>
25  * While the zip specification says the data descriptor should be used but it is optional. We
26  * record also whether the data descriptor contained the 4-byte signature at the start of the
27  * block or not.
28  */
29 public enum DataDescriptorType {
30     /**
31      * The entry has no data descriptor.
32      */
33     NO_DATA_DESCRIPTOR(0),
34 
35     /**
36      * The entry has a data descriptor that does not contain a signature.
37      */
38     DATA_DESCRIPTOR_WITHOUT_SIGNATURE(12),
39 
40     /**
41      * The entry has a data descriptor that contains a signature.
42      */
43     DATA_DESCRIPTOR_WITH_SIGNATURE(16);
44 
45     /**
46      * The number of bytes the data descriptor spans.
47      */
48     public int size;
49 
50     /**
51      * Creates a new data descriptor.
52      *
53      * @param size the number of bytes the data descriptor spans
54      */
DataDescriptorType(int size)55     DataDescriptorType(int size) {
56         this.size = size;
57     }
58 }
59