summaryrefslogtreecommitdiff
path: root/libs/androidfw/Asset.cpp
diff options
context:
space:
mode:
author Winson Chiu <chiuwinson@google.com> 2019-10-11 18:05:00 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-10-11 18:05:00 +0000
commit8e4f087cc11f72424c304192291ef35c6f24c179 (patch)
tree12e3973812a95a93a5b2b517e986705b8014af48 /libs/androidfw/Asset.cpp
parent535bd634c8b6b93413048f7f0ea435f6fe3cfa60 (diff)
parent9947f1e4fa6b1e58ca38bfe0ed440a8ab4f66465 (diff)
Merge "Add ResourceLoader API with .apk and .arsc support"
Diffstat (limited to 'libs/androidfw/Asset.cpp')
-rw-r--r--libs/androidfw/Asset.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/libs/androidfw/Asset.cpp b/libs/androidfw/Asset.cpp
index 92125c9da8bb..c132f343713f 100644
--- a/libs/androidfw/Asset.cpp
+++ b/libs/androidfw/Asset.cpp
@@ -133,14 +133,24 @@ Asset::Asset(void)
*/
/*static*/ Asset* Asset::createFromFile(const char* fileName, AccessMode mode)
{
+ return createFromFd(open(fileName, O_RDONLY | O_BINARY), fileName, mode);
+}
+
+/*
+ * Create a new Asset from a file on disk. There is a fair chance that
+ * the file doesn't actually exist.
+ *
+ * We can use "mode" to decide how we want to go about it.
+ */
+/*static*/ Asset* Asset::createFromFd(const int fd, const char* fileName, AccessMode mode)
+{
+ if (fd < 0) {
+ return NULL;
+ }
+
_FileAsset* pAsset;
status_t result;
off64_t length;
- int fd;
-
- fd = open(fileName, O_RDONLY | O_BINARY);
- if (fd < 0)
- return NULL;
/*
* Under Linux, the lseek fails if we actually opened a directory. To