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 * This represents a "raw" unswapped, unoptimized DEX file. We don't open
18 * them directly, except to create the optimized version that we tuck in
19 * the cache area.
20 */
21 #ifndef _DALVIK_RAWDEXFILE
22 #define _DALVIK_RAWDEXFILE
23
24 /*
25 * Structure representing a "raw" DEX file, in its unswapped unoptimized
26 * state.
27 */
28 typedef struct RawDexFile {
29 char* cacheFileName;
30 DvmDex* pDvmDex;
31 } RawDexFile;
32
33 /*
34 * Open a raw ".dex" file, optimize it, and load it.
35 *
36 * On success, returns 0 and sets "*ppDexFile" to a newly-allocated DexFile.
37 * On failure, returns a meaningful error code [currently just -1].
38 */
39 int dvmRawDexFileOpen(const char* fileName, const char* odexOutputName,
40 RawDexFile** ppDexFile, bool isBootstrap);
41
42 /*
43 * Free a RawDexFile structure, along with any associated structures.
44 */
45 void dvmRawDexFileFree(RawDexFile* pRawDexFile);
46
47 /*
48 * Pry the DexFile out of a RawDexFile.
49 */
dvmGetRawDexFileDex(RawDexFile * pRawDexFile)50 INLINE DvmDex* dvmGetRawDexFileDex(RawDexFile* pRawDexFile) {
51 return pRawDexFile->pDvmDex;
52 }
53
54 /* get full path of optimized DEX file */
dvmGetRawDexFileCacheFileName(RawDexFile * pRawDexFile)55 INLINE const char* dvmGetRawDexFileCacheFileName(RawDexFile* pRawDexFile) {
56 return pRawDexFile->cacheFileName;
57 }
58
59 #endif /*_DALVIK_RAWDEXFILE*/
60