The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2008 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 | #include "utils/ZipFileCRO.h" |
| 18 | #include "utils/ZipFileRO.h" |
| 19 | |
| 20 | using namespace android; |
| 21 | |
| 22 | ZipFileCRO ZipFileXRO_open(const char* path) { |
| 23 | ZipFileRO* zip = new ZipFileRO(); |
| 24 | if (zip->open(path) == NO_ERROR) { |
| 25 | return (ZipFileCRO)zip; |
| 26 | } |
| 27 | return NULL; |
| 28 | } |
| 29 | |
| 30 | void ZipFileCRO_destroy(ZipFileCRO zipToken) { |
| 31 | ZipFileRO* zip = (ZipFileRO*)zipToken; |
| 32 | delete zip; |
| 33 | } |
| 34 | |
| 35 | ZipEntryCRO ZipFileCRO_findEntryByName(ZipFileCRO zipToken, |
| 36 | const char* fileName) { |
| 37 | ZipFileRO* zip = (ZipFileRO*)zipToken; |
| 38 | return (ZipEntryCRO)zip->findEntryByName(fileName); |
| 39 | } |
| 40 | |
| 41 | bool ZipFileCRO_getEntryInfo(ZipFileCRO zipToken, ZipEntryRO entryToken, |
| 42 | int* pMethod, long* pUncompLen, |
| 43 | long* pCompLen, off_t* pOffset, long* pModWhen, long* pCrc32) { |
| 44 | ZipFileRO* zip = (ZipFileRO*)zipToken; |
| 45 | ZipEntryRO entry = (ZipEntryRO)entryToken; |
| 46 | return zip->getEntryInfo(entry, pMethod, pUncompLen, pCompLen, pOffset, |
| 47 | pModWhen, pCrc32); |
| 48 | } |
| 49 | |
| 50 | bool ZipFileCRO_uncompressEntry(ZipFileCRO zipToken, ZipEntryRO entryToken, int fd) { |
| 51 | ZipFileRO* zip = (ZipFileRO*)zipToken; |
| 52 | ZipEntryRO entry = (ZipEntryRO)entryToken; |
| 53 | return zip->uncompressEntry(entry, fd); |
| 54 | } |