OSDN Git Service

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