| 1 | // |
| 2 | // Copyright (c) SAS Institute Inc. |
| 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 zipslicer |
| 18 | |
| 19 | const ( |
| 20 | fileHeaderSignature = 0x04034b50 |
| 21 | directoryHeaderSignature = 0x02014b50 |
| 22 | directoryEndSignature = 0x06054b50 |
| 23 | directory64LocSignature = 0x07064b50 |
| 24 | directory64EndSignature = 0x06064b50 |
| 25 | dataDescriptorSignature = 0x08074b50 |
| 26 | fileHeaderLen = 30 |
| 27 | directoryHeaderLen = 46 |
| 28 | directoryEndLen = 22 |
| 29 | directory64LocLen = 20 |
| 30 | directory64EndLen = 56 |
| 31 | dataDescriptorLen = 16 |
| 32 | dataDescriptor64Len = 24 |
| 33 | zip64ExtraID = 0x0001 |
| 34 | zip64ExtraLen = 24 |
| 35 | |
| 36 | zip20 = 20 |
| 37 | zip45 = 45 |
| 38 | |
| 39 | uint32Max = 0xffffffff |
| 40 | uint16Max = 0xffff |
| 41 | ) |
| 42 | |
| 43 | type zipCentralDir struct { |
| 44 | Signature uint32 |
| 45 | CreatorVersion uint16 |
| 46 | ReaderVersion uint16 |
| 47 | Flags uint16 |
| 48 | Method uint16 |
| 49 | ModifiedTime uint16 |
| 50 | ModifiedDate uint16 |
| 51 | CRC32 uint32 |
| 52 | CompressedSize uint32 |
| 53 | UncompressedSize uint32 |
| 54 | FilenameLen uint16 |
| 55 | ExtraLen uint16 |
| 56 | CommentLen uint16 |
| 57 | StartDisk uint16 |
| 58 | InternalAttrs uint16 |
| 59 | ExternalAttrs uint32 |
| 60 | Offset uint32 |
| 61 | } |
| 62 | |
| 63 | type zip64End struct { |
| 64 | Signature uint32 |
| 65 | RecordSize uint64 |
| 66 | CreatorVersion uint16 |
| 67 | ReaderVersion uint16 |
| 68 | Disk uint32 |
| 69 | FirstDisk uint32 |
| 70 | DiskCDCount uint64 |
| 71 | TotalCDCount uint64 |
| 72 | CDSize uint64 |
| 73 | CDOffset uint64 |
| 74 | } |
| 75 | |
| 76 | type zip64Loc struct { |
| 77 | Signature uint32 |
| 78 | Disk uint32 |
| 79 | Offset uint64 |
| 80 | DiskCount uint32 |
| 81 | } |
| 82 | type zipEndRecord struct { |
| 83 | Signature uint32 |
| 84 | DiskNumber uint16 |
| 85 | DiskCD uint16 |
| 86 | DiskCDCount uint16 |
| 87 | TotalCDCount uint16 |
| 88 | CDSize uint32 |
| 89 | CDOffset uint32 |
| 90 | CommentLength uint16 |
| 91 | } |
| 92 | |
| 93 | type zipLocalHeader struct { |
| 94 | Signature uint32 |
| 95 | ReaderVersion uint16 |
| 96 | Flags uint16 |
| 97 | Method uint16 |
| 98 | ModifiedTime uint16 |
| 99 | ModifiedDate uint16 |
| 100 | CRC32 uint32 |
| 101 | CompressedSize uint32 |
| 102 | UncompressedSize uint32 |
| 103 | FilenameLen uint16 |
| 104 | ExtraLen uint16 |
| 105 | } |
| 106 | |
| 107 | type zip64Extra struct { |
| 108 | Signature uint16 |
| 109 | RecordSize uint16 |
| 110 | UncompressedSize uint64 |
| 111 | CompressedSize uint64 |
| 112 | Offset uint64 |
| 113 | } |
| 114 | |
| 115 | type zipDataDesc struct { |
| 116 | Signature uint32 |
| 117 | CRC32 uint32 |
| 118 | CompressedSize uint32 |
| 119 | UncompressedSize uint32 |
| 120 | } |
| 121 | |
| 122 | type zipDataDesc64 struct { |
| 123 | Signature uint32 |
| 124 | CRC32 uint32 |
| 125 | CompressedSize uint64 |
| 126 | UncompressedSize uint64 |
| 127 | } |