asset_manager.cpp revision 06ea4d65e81123832d2ae547538d612b0e6b90fa
16cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate/*
26cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate * Copyright (C) 2010 The Android Open Source Project
36cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate *
46cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate * Licensed under the Apache License, Version 2.0 (the "License");
56cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate * you may not use this file except in compliance with the License.
66cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate * You may obtain a copy of the License at
76cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate *
86cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate *      http://www.apache.org/licenses/LICENSE-2.0
96cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate *
106cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate * Unless required by applicable law or agreed to in writing, software
116cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate * distributed under the License is distributed on an "AS IS" BASIS,
126cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
136cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate * See the License for the specific language governing permissions and
146cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate * limitations under the License.
156cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate */
166cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
176cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate#define LOG_TAG "NAsset"
186cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate#include <utils/Log.h>
196cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
2008d5b8fad8d46ccb64db2fdcb4d66972ec87bf48Dianne Hackborn#include <android/asset_manager_jni.h>
216cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate#include <utils/AssetManager.h>
226cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate#include <utils/AssetDir.h>
236cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate#include <utils/Asset.h>
246cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate#include <utils/threads.h>
256cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
266cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate#include "jni.h"
276cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate#include "JNIHelp.h"
286cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
296cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tateusing namespace android;
306cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
316cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate// -------------------- Backing implementation of the public API --------------------
326cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
336cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate// AAssetManager is actually a secret typedef for an empty base class of AssetManager,
346cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate// but AAssetDir and AAsset are actual wrappers for isolation.
356cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
366cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate// -----
376cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tatestruct AAssetDir {
386cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    AssetDir* mAssetDir;
396cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    size_t mCurFileIndex;
406cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    String8 mCachedFileName;
416cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
426cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    AAssetDir(AssetDir* dir) : mAssetDir(dir), mCurFileIndex(0) { }
436cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    ~AAssetDir() { delete mAssetDir; }
446cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate};
456cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
466cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
476cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate// -----
486cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tatestruct AAsset {
496cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    Asset* mAsset;
506cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
516cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    AAsset(Asset* asset) : mAsset(asset) { }
526cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    ~AAsset() { delete mAsset; }
536cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate};
546cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
556cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate// -------------------- Public native C API --------------------
566cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
576cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate/**
586cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate * Supporting information
596cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate */
606cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
616cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tatestatic struct assetmanager_offsets_t
626cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate{
636cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    jfieldID mObject;
646cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate} gAssetManagerOffsets;
656cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
666cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tatestatic volatile bool gJNIConfigured = false;
676cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tatestatic Mutex gMutex;
686cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
696cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate/**
706cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate * Asset Manager functionality
716cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate */
726cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher TateAAssetManager* AAssetManager_fromJava(JNIEnv* env, jobject assetManager)
736cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate{
746cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    {
756cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate        Mutex::Autolock _l(gMutex);
766cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
776cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate        if (gJNIConfigured == false) {
786cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate            jclass amClass = env->FindClass("android/content/res/AssetManager");
796cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate            gAssetManagerOffsets.mObject = env->GetFieldID(amClass, "mObject", "I");
806cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate            gJNIConfigured = true;
816cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate        }
826cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    }
836cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
846cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    return (AAssetManager*) env->GetIntField(assetManager, gAssetManagerOffsets.mObject);
856cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate}
866cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
876cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher TateAAsset* AAssetManager_open(AAssetManager* amgr, const char* filename, int mode)
886cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate{
896cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    Asset::AccessMode amMode;
906cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    switch (mode) {
916cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    case AASSET_MODE_UNKNOWN:
926cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate        amMode = Asset::ACCESS_UNKNOWN;
936cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate        break;
946cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    case AASSET_MODE_RANDOM:
956cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate        amMode = Asset::ACCESS_RANDOM;
966cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate        break;
976cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    case AASSET_MODE_STREAMING:
986cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate        amMode = Asset::ACCESS_STREAMING;
996cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate        break;
1006cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    case AASSET_MODE_BUFFER:
1016cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate        amMode = Asset::ACCESS_BUFFER;
1026cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate        break;
1036cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    default:
1046cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate        return NULL;
1056cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    }
1066cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
1076cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    AssetManager* mgr = static_cast<AssetManager*>(amgr);
1086cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    Asset* asset = mgr->open(filename, amMode);
1096cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    if (asset == NULL) {
1106cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate        return NULL;
1116cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    }
1126cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
1136cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    return new AAsset(asset);
1146cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate}
1156cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
1166cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher TateAAssetDir* AAssetManager_openDir(AAssetManager* amgr, const char* dirName)
1176cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate{
1186cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    AssetManager* mgr = static_cast<AssetManager*>(amgr);
1196cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    return new AAssetDir(mgr->openDir(dirName));
1206cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate}
1216cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
1226cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate/**
1236cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate * AssetDir functionality
1246cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate */
1256cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
1266cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tateconst char* AAssetDir_getNextFileName(AAssetDir* assetDir)
1276cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate{
1286cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    const char* returnName = NULL;
1296cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    size_t index = assetDir->mCurFileIndex;
1306cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    const size_t max = assetDir->mAssetDir->getFileCount();
1316cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
1326cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    // Find the next regular file; explicitly don't report directories even if the
1336cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    // underlying implementation changes to report them.  At that point we can add
1346cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    // a more general iterator to this native interface set if appropriate.
1356cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    while ((index < max) && (assetDir->mAssetDir->getFileType(index) != kFileTypeRegular)) {
1366cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate        index++;
1376cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    }
1386cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
1396cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    // still in bounds? then the one at 'index' is the next to be reported; generate
1406cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    // the string to return and advance the iterator for next time.
1416cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    if (index < max) {
1426cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate        assetDir->mCachedFileName = assetDir->mAssetDir->getFileName(index);
1436cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate        returnName = assetDir->mCachedFileName.string();
1446cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate        index++;
1456cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    }
1466cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
1476cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    assetDir->mCurFileIndex = index;
1486cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    return returnName;
1496cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate}
1506cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
1516cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tatevoid AAssetDir_rewind(AAssetDir* assetDir)
1526cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate{
1536cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    assetDir->mCurFileIndex = 0;
1546cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate}
1556cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
1566cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tateconst char* AAssetDir_getFileName(AAssetDir* assetDir, int index)
1576cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate{
1586cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    assetDir->mCachedFileName = assetDir->mAssetDir->getFileName(index);
1596cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    return assetDir->mCachedFileName.string();
1606cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate}
1616cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
1626cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tatevoid AAssetDir_close(AAssetDir* assetDir)
1636cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate{
1646cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    delete assetDir;
1656cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate}
1666cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
1676cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate/**
1686cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate * Asset functionality
1696cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate */
1706cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
1716cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tateint AAsset_read(AAsset* asset, void* buf, size_t count)
1726cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate{
1736cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    return asset->mAsset->read(buf, (size_t)count);
1746cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate}
1756cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
1766cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tateoff_t AAsset_seek(AAsset* asset, off_t offset, int whence)
1776cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate{
1786cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    return asset->mAsset->seek(offset, whence);
1796cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate}
1806cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
18106ea4d65e81123832d2ae547538d612b0e6b90faKenny Rootoff64_t AAsset_seek64(AAsset* asset, off64_t offset, int whence)
18206ea4d65e81123832d2ae547538d612b0e6b90faKenny Root{
18306ea4d65e81123832d2ae547538d612b0e6b90faKenny Root    return asset->mAsset->seek(offset, whence);
18406ea4d65e81123832d2ae547538d612b0e6b90faKenny Root}
18506ea4d65e81123832d2ae547538d612b0e6b90faKenny Root
1866cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tatevoid AAsset_close(AAsset* asset)
1876cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate{
1886cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    asset->mAsset->close();
1896cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    delete asset;
1906cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate}
1916cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
1926cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tateconst void* AAsset_getBuffer(AAsset* asset)
1936cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate{
1946cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    return asset->mAsset->getBuffer(false);
1956cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate}
1966cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
1976cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tateoff_t AAsset_getLength(AAsset* asset)
1986cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate{
1996cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    return asset->mAsset->getLength();
2006cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate}
2016cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
20206ea4d65e81123832d2ae547538d612b0e6b90faKenny Rootoff64_t AAsset_getLength64(AAsset* asset)
20306ea4d65e81123832d2ae547538d612b0e6b90faKenny Root{
20406ea4d65e81123832d2ae547538d612b0e6b90faKenny Root    return asset->mAsset->getLength();
20506ea4d65e81123832d2ae547538d612b0e6b90faKenny Root}
20606ea4d65e81123832d2ae547538d612b0e6b90faKenny Root
2076cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tateoff_t AAsset_getRemainingLength(AAsset* asset)
2086cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate{
2096cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    return asset->mAsset->getRemainingLength();
2106cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate}
2116cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
21206ea4d65e81123832d2ae547538d612b0e6b90faKenny Rootoff64_t AAsset_getRemainingLength64(AAsset* asset)
21306ea4d65e81123832d2ae547538d612b0e6b90faKenny Root{
21406ea4d65e81123832d2ae547538d612b0e6b90faKenny Root    return asset->mAsset->getRemainingLength();
21506ea4d65e81123832d2ae547538d612b0e6b90faKenny Root}
21606ea4d65e81123832d2ae547538d612b0e6b90faKenny Root
2176cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tateint AAsset_openFileDescriptor(AAsset* asset, off_t* outStart, off_t* outLength)
2186cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate{
21906ea4d65e81123832d2ae547538d612b0e6b90faKenny Root    off64_t outStart64, outLength64;
22006ea4d65e81123832d2ae547538d612b0e6b90faKenny Root
22106ea4d65e81123832d2ae547538d612b0e6b90faKenny Root    int ret = asset->mAsset->openFileDescriptor(&outStart64, &outLength64);
22206ea4d65e81123832d2ae547538d612b0e6b90faKenny Root
22306ea4d65e81123832d2ae547538d612b0e6b90faKenny Root    *outStart = off_t(outStart64);
22406ea4d65e81123832d2ae547538d612b0e6b90faKenny Root    *outLength = off_t(outLength64);
22506ea4d65e81123832d2ae547538d612b0e6b90faKenny Root    return ret;
22606ea4d65e81123832d2ae547538d612b0e6b90faKenny Root}
22706ea4d65e81123832d2ae547538d612b0e6b90faKenny Root
22806ea4d65e81123832d2ae547538d612b0e6b90faKenny Rootint AAsset_openFileDescriptor64(AAsset* asset, off64_t* outStart, off64_t* outLength)
22906ea4d65e81123832d2ae547538d612b0e6b90faKenny Root{
23006ea4d65e81123832d2ae547538d612b0e6b90faKenny Root    return asset->mAsset->openFileDescriptor(outStart, outLength);
2316cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate}
2326cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate
2336cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tateint AAsset_isAllocated(AAsset* asset)
2346cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate{
2356cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate    return asset->mAsset->isAllocated() ? 1 : 0;
2366cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate}
237