diff options
author | Tor Lillqvist <tlillqvist@suse.com> | 2012-01-04 00:03:18 +0200 |
---|---|---|
committer | Tor Lillqvist <tlillqvist@suse.com> | 2012-01-04 00:17:25 +0200 |
commit | 90b141496018201ee9df721b382cd2b177a3a92f (patch) | |
tree | 1a0fc73adbf51c618b10661cc396f5ec11ee491a /sal/osl/unx/uunxapi.cxx | |
parent | 2717fe35ae7fd35b787b53d291919449d307ea01 (diff) |
Use the lo_apk_* functions for files under /assets
Diffstat (limited to 'sal/osl/unx/uunxapi.cxx')
-rw-r--r-- | sal/osl/unx/uunxapi.cxx | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/sal/osl/unx/uunxapi.cxx b/sal/osl/unx/uunxapi.cxx index ee3cdeb928d8..3c2067bb318d 100644 --- a/sal/osl/unx/uunxapi.cxx +++ b/sal/osl/unx/uunxapi.cxx @@ -47,6 +47,10 @@ #include <osl/thread.h> #endif + #ifdef ANDROID + #include <lo-bootstrap.h> + #endif + //########################### inline rtl::OString OUStringToOString(const rtl_uString* s) { @@ -80,7 +84,24 @@ int access_u(const rtl_uString* pustrPath, int mode) { #ifndef MACOSX // not MACOSX - return access(OUStringToOString(pustrPath).getStr(), mode); + const char *path = OUStringToOString(pustrPath).getStr(); +#ifdef ANDROID + if (strncmp(path, "/assets", sizeof("/assets")-1) == 0 && + (path[sizeof("/assets")-1] == '\0' || + path[sizeof("/assets")-1] == '/')) + { + struct stat stat; + if (lo_apk_lstat(path, &stat) == -1) + return -1; + if (mode & W_OK) + { + errno = EACCES; + return -1; + } + return 0; + } +#endif + return access(path, mode); #else return access(macxp_resolveAliasAndConvert(pustrPath).getStr(), mode); #endif @@ -114,7 +135,14 @@ int lstat_u(const rtl_uString* pustrPath, struct stat* buf) { #ifndef MACOSX // not MACOSX - return lstat(OUStringToOString(pustrPath).getStr(), buf); + const char *path = OUStringToOString(pustrPath).getStr(); +#ifdef ANDROID + if (strncmp(path, "/assets", sizeof("/assets")-1) == 0 && + (path[sizeof("/assets")-1] == '\0' || + path[sizeof("/assets")-1] == '/')) + return lo_apk_lstat(path, buf); +#endif + return lstat(path, buf); #else return lstat(macxp_resolveAliasAndConvert(pustrPath).getStr(), buf); #endif |