blob: f15aac283dc11f004a90516f4e06fc4cff4129b0 [file] [log] [blame]
The Android Open Source Projectf6c38712009-03-03 19:28:47 -08001/*
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 */
28typedef 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 */
39int dvmRawDexFileOpen(const char* fileName, const char* odexOutputName,
40 RawDexFile** ppDexFile, bool isBootstrap);
41
42/*
Dan Bornsteinc5ba2b62010-12-14 16:57:00 -080043 * Open a raw ".dex" file based on the given chunk of memory, and load
44 * it. The bytes are assumed to be owned by the caller for the
45 * purposes of memory management and further assumed to not be touched
46 * by the caller while the raw dex file remains open. The bytes *may*
47 * be modified as the result of issuing this call.
48 *
49 * On success, returns 0 and sets "*ppDexFile" to a newly-allocated DexFile.
50 * On failure, returns a meaningful error code [currently just -1].
51 */
52int dvmRawDexFileOpenArray(const u1* pBytes, u4 length,
53 RawDexFile** ppDexFile);
54
55/*
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080056 * Free a RawDexFile structure, along with any associated structures.
57 */
58void dvmRawDexFileFree(RawDexFile* pRawDexFile);
59
60/*
61 * Pry the DexFile out of a RawDexFile.
62 */
63INLINE DvmDex* dvmGetRawDexFileDex(RawDexFile* pRawDexFile) {
64 return pRawDexFile->pDvmDex;
65}
66
67/* get full path of optimized DEX file */
68INLINE const char* dvmGetRawDexFileCacheFileName(RawDexFile* pRawDexFile) {
69 return pRawDexFile->cacheFileName;
70}
71
72#endif /*_DALVIK_RAWDEXFILE*/