23 using namespace Android;
30 for (
auto _ =
path.rbegin(); _ !=
path.rend(); ++_) {
37 std::string
path(path_);
40 if (i == std::string::npos)
41 i =
path.length() + 1;
42 std::string dir(
path.substr(pos, i - pos - 1));
46 this->path.push_back( AAssetManager_openDir(
manager, dir.c_str()) );
48 }
while (pos <
path.length());
56 while ((
filename = AAssetDir_getNextFileName(
path.back()) ) !=
nullptr) {
60 AAssetDir_rewind(
path.back());
67 AAssetDir_close(
path.back());
74 asset = AAssetManager_open(manager, path, AASSET_MODE_STREAMING);
76 throw IOError(path,
"Cannot access the asset");
86 return AAsset_read(
asset, buffer, bytes) > 0;
91 return result != (off64_t) -1;
95 return AAsset_getRemainingLength(
asset) <= 0;
static const char PATH_DELIMITER
AssetPath(AAssetManager *manager, const char *path="")
bool up()
Goes one level up ("..") from the current asset folder.
std::vector< AAssetDir * > path
void follow(const char *path)
msize listFiles(std::vector< std::string > &files)
Lists files in the current folder.
bool eof() const
Returns true, if the end of the stream is reached (i.e., all the data is read or the stream is empty)...
bool operator()(void *buffer, msize bytes)
Reads a given number of bytes into a specific memory location.
bool seek(msize pos)
Moves the read pointer to a given position in the stream.
Asset(AAssetManager *manager, const char *path)
ChunkAsset(AAssetManager *manager, const std::string &filename)
Creates a read-only chunk collection from an asset.
bool parse()
Goes through the input stream to build the list of existing chunks.
uint32_t msize
memory size
JNIEnv jlong jstring filename