overview

command
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Example: AAssetManager API overview and directory iteration.

Demonstrates the full ndk/asset API surface: opening assets by path, reading content, querying length and allocation state, seeking within an asset, and iterating directories.

AAssetManager lifecycle on Android:

  1. Obtain the AAssetManager pointer from the Activity's ANativeActivity struct (activity.AssetManager in ndk/activity). The manager is owned by the framework and must not be freed by application code.
  2. Open an individual asset with Manager.Open(filename, mode). The filename is relative to the APK's "assets/" directory (e.g. "textures/wood.png"). The mode controls how the NDK buffers the data.
  3. Read the asset with Asset.Read, or access it directly via Asset.Buffer (only valid when opened with Buffer mode). Query the size with Asset.Length / Asset.Length64 and the unread portion with Asset.RemainingLength / Asset.RemainingLength64. Reposition with Asset.Seek using standard SEEK_SET/SEEK_CUR/SEEK_END whence values.
  4. Close the asset with Asset.Close when finished.

Directory iteration:

  1. Open a directory with Manager.OpenDir(dirName). Pass an empty string to list the root of the assets/ tree, or a subdirectory path.
  2. Call Dir.NextFileName repeatedly. Each call returns the next filename as a string, or "" when the listing is exhausted.
  3. Call Dir.Rewind to reset the iterator back to the first entry.
  4. Close with Dir.Close when finished.

This program prints all Mode constants and documents the usage patterns in executable form. It cannot run without a real AAssetManager obtained from an Android Activity.

This program must run on an Android device.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL