Tianjie Xu | 91caafe | 2020-03-13 16:16:24 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2020 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 | #pragma once |
| 18 | |
| 19 | #include <stdint.h> |
| 20 | |
Tianjie Xu | 91caafe | 2020-03-13 16:16:24 -0700 | [diff] [blame] | 21 | enum ZipError : int32_t { |
| 22 | kSuccess = 0, |
| 23 | |
| 24 | kIterationEnd = -1, |
| 25 | |
| 26 | // We encountered a Zlib error when inflating a stream from this file. |
| 27 | // Usually indicates file corruption. |
| 28 | kZlibError = -2, |
| 29 | |
| 30 | // The input file cannot be processed as a zip archive. Usually because |
| 31 | // it's too small, too large or does not have a valid signature. |
| 32 | kInvalidFile = -3, |
| 33 | |
| 34 | // An invalid iteration / ziparchive handle was passed in as an input |
| 35 | // argument. |
| 36 | kInvalidHandle = -4, |
| 37 | |
| 38 | // The zip archive contained two (or possibly more) entries with the same |
| 39 | // name. |
| 40 | kDuplicateEntry = -5, |
| 41 | |
| 42 | // The zip archive contains no entries. |
| 43 | kEmptyArchive = -6, |
| 44 | |
| 45 | // The specified entry was not found in the archive. |
| 46 | kEntryNotFound = -7, |
| 47 | |
| 48 | // The zip archive contained an invalid local file header pointer. |
| 49 | kInvalidOffset = -8, |
| 50 | |
| 51 | // The zip archive contained inconsistent entry information. This could |
| 52 | // be because the central directory & local file header did not agree, or |
| 53 | // if the actual uncompressed length or crc32 do not match their declared |
| 54 | // values. |
| 55 | kInconsistentInformation = -9, |
| 56 | |
| 57 | // An invalid entry name was encountered. |
| 58 | kInvalidEntryName = -10, |
| 59 | |
| 60 | // An I/O related system call (read, lseek, ftruncate, map) failed. |
| 61 | kIoError = -11, |
| 62 | |
| 63 | // We were not able to mmap the central directory or entry contents. |
| 64 | kMmapFailed = -12, |
| 65 | |
| 66 | // An allocation failed. |
| 67 | kAllocationFailed = -13, |
| 68 | |
Tianjie | 26ee1db | 2020-04-01 23:08:34 -0700 | [diff] [blame] | 69 | // The compressed or uncompressed size is larger than UINT32_MAX and |
| 70 | // doesn't fit into the 32 bits zip entry. |
| 71 | kUnsupportedEntrySize = -14, |
| 72 | |
| 73 | kLastErrorCode = kUnsupportedEntrySize, |
Tianjie Xu | 91caafe | 2020-03-13 16:16:24 -0700 | [diff] [blame] | 74 | }; |