---
title: "android ndk obb.h "
author: "Darar"
date: "2013-03-12T15:14:24Z"
tags: []
categories: ["移动开发"]
slug: "android-ndk-obb-h"
draft: false
lastmod: "2013-03-12T15:14:24Z"
id: 1828187
url: "https://darar.iteye.com/blog/1828187"
---

#ifndef ANDROID_OBB_H
#define ANDROID_OBB_H

#include <sys/types.h>

#ifdef __cplusplus
extern "C" {
#endif

/* 如果我们设计一款资源包含比较多的游戏，可能你会发现最终生成的 APK 文件可能高达 300 MB，
 * 但是 APK 文件很大导致 Android 系统无法正常安装，而这么大其实都是游戏中用到的资源文件，
 * 我们放到 SD 卡上可能其他应用也可以访问，
 * 比如说系统的图片管理器会索引游戏中的图片资源，而音乐播放器也会索引资源中的音乐，
 * 所以 Android 2.3 的 OBB 文件(Opaque Binary Blob)可以很好的解决大文件在 SD 卡上分离出 APK 文件，
 * 同时别的程序没有权限访问这样一种隔离的文件系统。
 */
struct AObbInfo;
typedef struct AObbInfo AObbInfo;

enum {
    /* Flag noting that this OBB is an overlay patch for a base OBB.
     * 标志强调这个 OBB 对于一个基本 OBB 是一个覆盖补丁。　
     * 参见：    android.content.res.ObbInfo 类的成员常量 OBB_OVERLAY 。
     */
    AOBBINFO_OVERLAY = 0x0001,
};

/**
 * Scan an OBB and get information about it.
 * 扫描一个 OBB 且得到关于它的信息。
 * 参见：android.content.res.ObbScanner 类的 getObbInfo 方法。
 */
AObbInfo* 
AObbScanner_getObbInfo( const char* filename );

/**
 * Destroy the AObbInfo object. 
 * 消毁 AObbInfo 对象。
 * 
 * You must call this when finished with the object.
 * 在用完 AObbInfo 对象时你必须调用该函数。
 */
void 
AObbInfo_delete( AObbInfo* obbInfo );

/**
 * Get the package name for the OBB.
 * 得到 OBB 包名。
 */
const char* 
AObbInfo_getPackageName( AObbInfo* obbInfo );

/**
 * Get the version of an OBB file.
 * 得到一个 OBB 文件的版本。
 */
int32_t 
AObbInfo_getVersion( AObbInfo* obbInfo );

/**
 * Get the flags of an OBB file.
 * 得到一个 OBB 文件的标志。
 */
int32_t 
AObbInfo_getFlags( AObbInfo* obbInfo );

#ifdef __cplusplus
};
#endif

#endif      // ANDROID_OBB_H