diff options
author | Tor Lillqvist <tml@iki.fi> | 2013-03-23 13:36:57 +0200 |
---|---|---|
committer | Tor Lillqvist <tml@iki.fi> | 2013-03-26 18:44:11 +0200 |
commit | bdbb0d1cc13a11c8c857ee2d387771a8c2622488 (patch) | |
tree | 9f5720912e46d4ed90903dfe4754ff2857866787 /sal | |
parent | Add LOViewerWindow.[hm] to the project (diff) | |
download | core-bdbb0d1cc13a11c8c857ee2d387771a8c2622488.tar.gz core-bdbb0d1cc13a11c8c857ee2d387771a8c2622488.zip |
Temporary hack for iOS: open files read-only if read-write open fails
Change-Id: Ifc400d9843b23ef942c43af3a2b8830ccff71a7e
Diffstat (limited to 'sal')
-rw-r--r-- | sal/osl/unx/file.cxx | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx index d3f6251b629b..008c61e67f2c 100644 --- a/sal/osl/unx/file.cxx +++ b/sal/osl/unx/file.cxx @@ -911,6 +911,18 @@ SAL_CALL osl_openFilePath( const char *cpFilePath, oslFileHandle* pHandle, sal_u /* open the file */ int fd = open( cpFilePath, flags, mode ); +#ifdef IOS + /* Horrible hack: If opening for RDWR and getting EPERM, just try + * again for RDONLY. Quicker this way than to figure out why + * we get that oh so useful General Error when trying to open a + * read-only document. + */ + if (-1 == fd && (flags & O_RDWR) && EPERM == errno) + { + int rdonly_flags = (flags & ~O_ACCMODE) | O_RDONLY; + fd = open( cpFilePath, rdonly_flags, mode ); + } +#endif if (-1 == fd) { int saved_errno = errno; |