Introduce NDK API for 64-bit assets

Assets were switched to using 64-bit all through the system, so switch
the NDK to using this new API as well.

Change-Id: I2817b11369db3a4dd504b839ef1a3a9780b83533
This commit is contained in:
Kenny Root
2010-12-13 11:58:55 -08:00
parent 14b0a6bc0e
commit 06ea4d65e8
2 changed files with 65 additions and 2 deletions

View File

@@ -178,6 +178,11 @@ off_t AAsset_seek(AAsset* asset, off_t offset, int whence)
return asset->mAsset->seek(offset, whence);
}
off64_t AAsset_seek64(AAsset* asset, off64_t offset, int whence)
{
return asset->mAsset->seek(offset, whence);
}
void AAsset_close(AAsset* asset)
{
asset->mAsset->close();
@@ -194,14 +199,35 @@ off_t AAsset_getLength(AAsset* asset)
return asset->mAsset->getLength();
}
off64_t AAsset_getLength64(AAsset* asset)
{
return asset->mAsset->getLength();
}
off_t AAsset_getRemainingLength(AAsset* asset)
{
return asset->mAsset->getRemainingLength();
}
off64_t AAsset_getRemainingLength64(AAsset* asset)
{
return asset->mAsset->getRemainingLength();
}
int AAsset_openFileDescriptor(AAsset* asset, off_t* outStart, off_t* outLength)
{
return asset->mAsset->openFileDescriptor((off64_t*)outStart, (off64_t*)outLength);
off64_t outStart64, outLength64;
int ret = asset->mAsset->openFileDescriptor(&outStart64, &outLength64);
*outStart = off_t(outStart64);
*outLength = off_t(outLength64);
return ret;
}
int AAsset_openFileDescriptor64(AAsset* asset, off64_t* outStart, off64_t* outLength)
{
return asset->mAsset->openFileDescriptor(outStart, outLength);
}
int AAsset_isAllocated(AAsset* asset)

View File

@@ -93,6 +93,17 @@ int AAsset_read(AAsset* asset, void* buf, size_t count);
*/
off_t AAsset_seek(AAsset* asset, off_t offset, int whence);
/**
* Seek to the specified offset within the asset data. 'whence' uses the
* same constants as lseek()/fseek().
*
* Uses 64-bit data type for large files as opposed to the 32-bit type used
* by AAsset_seek.
*
* Returns the new position on success, or (off64_t) -1 on error.
*/
off64_t AAsset_seek64(AAsset* asset, off64_t offset, int whence);
/**
* Close the asset, freeing all associated resources.
*/
@@ -110,19 +121,45 @@ const void* AAsset_getBuffer(AAsset* asset);
*/
off_t AAsset_getLength(AAsset* asset);
/**
* Report the total size of the asset data. Reports the size using a 64-bit
* number insted of 32-bit as AAsset_getLength.
*/
off64_t AAsset_getLength64(AAsset* asset);
/**
* Report the total amount of asset data that can be read from the current position.
*/
off_t AAsset_getRemainingLength(AAsset* asset);
/**
* Open a new file descriptor that can be used to read the asset data.
* Report the total amount of asset data that can be read from the current position.
*
* Uses a 64-bit number instead of a 32-bit number as AAsset_getRemainingLength does.
*/
off64_t AAsset_getRemainingLength64(AAsset* asset);
/**
* Open a new file descriptor that can be used to read the asset data. If the
* start or length cannot be represented by a 32-bit number, it will be
* truncated. If the file is large, use AAsset_openFileDescriptor64 instead.
*
* Returns < 0 if direct fd access is not possible (for example, if the asset is
* compressed).
*/
int AAsset_openFileDescriptor(AAsset* asset, off_t* outStart, off_t* outLength);
/**
* Open a new file descriptor that can be used to read the asset data.
*
* Uses a 64-bit number for the offset and length instead of 32-bit instead of
* as AAsset_openFileDescriptor does.
*
* Returns < 0 if direct fd access is not possible (for example, if the asset is
* compressed).
*/
int AAsset_openFileDescriptor64(AAsset* asset, off64_t* outStart, off64_t* outLength);
/**
* Returns whether this asset's internal buffer is allocated in ordinary RAM (i.e. not
* mmapped).