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 * Decode jar/apk/zip files.
18 */
19 #ifndef _DALVIK_JARFILE
20 #define _DALVIK_JARFILE
21
22 /*
23 * This represents an open, scanned Jar file. (It's actually for any Zip
24 * archive that happens to hold a Dex file.)
25 */
26 typedef struct JarFile {
27 ZipArchive archive;
28 //MemMapping map;
29 char* cacheFileName;
30 DvmDex* pDvmDex;
31 } JarFile;
32
33 /*
34 * Open the Zip archive and get a list of the classfile entries.
35 *
36 * On success, returns 0 and sets "*ppJarFile" to a newly-allocated JarFile.
37 * On failure, returns a meaningful error code [currently just -1].
38 */
39 int dvmJarFileOpen(const char* fileName, const char* odexOutputName,
40 JarFile** ppJarFile, bool isBootstrap);
41
42 /*
43 * Free a JarFile structure, along with any associated structures.
44 */
45 void dvmJarFileFree(JarFile* pJarFile);
46
47 /* pry the DexFile out of a JarFile */
dvmGetJarFileDex(JarFile * pJarFile)48 INLINE DvmDex* dvmGetJarFileDex(JarFile* pJarFile) {
49 return pJarFile->pDvmDex;
50 }
51
52 /* get full path of optimized DEX file */
dvmGetJarFileCacheFileName(JarFile * pJarFile)53 INLINE const char* dvmGetJarFileCacheFileName(JarFile* pJarFile) {
54 return pJarFile->cacheFileName;
55 }
56
57 typedef enum DexCacheStatus {
58 DEX_CACHE_ERROR = -2,
59 DEX_CACHE_BAD_ARCHIVE = -1,
60 DEX_CACHE_OK = 0,
61 DEX_CACHE_STALE,
62 DEX_CACHE_STALE_ODEX,
63 } DexCacheStatus;
64
65 /*
66 * Checks the dependencies of the dex cache file corresponding
67 * to the jar file at the absolute path "fileName".
68 */
69 DexCacheStatus dvmDexCacheStatus(const char *fileName);
70
71 #endif /*_DALVIK_JARFILE*/
72