summaryrefslogtreecommitdiff
path: root/store
diff options
context:
space:
mode:
authorTor Lillqvist <tlillqvist@suse.com>2011-12-21 13:51:50 +0200
committerTor Lillqvist <tlillqvist@suse.com>2011-12-21 14:08:48 +0200
commite3ab0fd9016bc24c5a0eb0807f171d5025c3bb79 (patch)
treefe87e3d60bf522d0ccc469becacbb0191e129d75 /store
parenteeecf625351238f90c61c82b403bd65e35d7833e (diff)
osl_unmapFile can't work for files bundled inside the .apk on Android
On Android, when an app is installed, arbitrary files bundled in the app won't be unpacked into actual separate files in the file system. They will exist only as archive entries in the .apk file (which is a zip archive). The SDK tooling puts such files under the /assets folder in the .apk. The LibreOffice bootstrapping code for Android maps the .apk file into memory. osl_openFile() knows about the /assets special case, and uses a separate abstraction for such memory-mapped files. Obviously, when producing an .apk, one needs to make sure these bundled files are not compressed, if one wants to be able to use them directly from the memory-mapped .apk file. We do that in our test and sample Android projects. When mapping such files under /assets , just return a pointer to the file's location inside the mapped .apk archive. We can't use the old osl_unmapFile() on such mapped files, as that would unexpectedly unmap fairly arbitrary pages of the .apk mapping, wreaking havoc on later use of the same pages. So, introduce a new osl_unmapMappedFile() function that takes also the oslFileHandle originally passed to osl_mapFile(). Use this instead in the few places where the code actually called osl_unmapFile(). Make sure osl_mapFile() is nonexistent on Android.
Diffstat (limited to 'store')
-rw-r--r--store/source/lockbyte.cxx14
1 files changed, 9 insertions, 5 deletions
diff --git a/store/source/lockbyte.cxx b/store/source/lockbyte.cxx
index f7b20f002f7b..a91e470cc38d 100644
--- a/store/source/lockbyte.cxx
+++ b/store/source/lockbyte.cxx
@@ -476,6 +476,7 @@ struct FileMapping
{
sal_uInt8 * m_pAddr;
sal_uInt32 m_nSize;
+ oslFileHandle m_hFile;
FileMapping() : m_pAddr(0), m_nSize(0) {}
@@ -497,15 +498,17 @@ struct FileMapping
return osl_File_E_OVERFLOW;
m_nSize = sal::static_int_cast<sal_uInt32>(uSize);
+ m_hFile = hFile;
+
// Acquire mapping.
return osl_mapFile (hFile, reinterpret_cast<void**>(&m_pAddr), m_nSize, 0, osl_File_MapFlag_RandomAccess);
}
/** @see MappedLockBytes::destructor.
*/
- static void unmapFile (sal_uInt8 * pAddr, sal_uInt32 nSize)
+ static void unmapFile (oslFileHandle hFile, sal_uInt8 * pAddr, sal_uInt32 nSize)
{
- (void) osl_unmapFile (pAddr, nSize);
+ (void) osl_unmapMappedFile (hFile, pAddr, nSize);
}
/** @see ResourceHolder<T>::destructor_type
@@ -515,7 +518,7 @@ struct FileMapping
void operator ()(FileMapping & rMapping) const
{
// Release mapping.
- unmapFile (rMapping.m_pAddr, rMapping.m_nSize);
+ unmapFile (rMapping.m_hFile, rMapping.m_pAddr, rMapping.m_nSize);
rMapping.m_pAddr = 0, rMapping.m_nSize = 0;
}
};
@@ -532,6 +535,7 @@ class MappedLockBytes :
sal_uInt8 * m_pData;
sal_uInt32 m_nSize;
sal_uInt16 m_nPageSize;
+ oslFileHandle m_hFile;
/** PageData::Allocator implementation.
*/
@@ -577,13 +581,13 @@ protected:
} // namespace store
MappedLockBytes::MappedLockBytes (FileMapping & rMapping)
- : m_pData (rMapping.m_pAddr), m_nSize (rMapping.m_nSize), m_nPageSize(0)
+ : m_pData (rMapping.m_pAddr), m_nSize (rMapping.m_nSize), m_nPageSize(0), m_hFile (rMapping.m_hFile)
{
}
MappedLockBytes::~MappedLockBytes()
{
- FileMapping::unmapFile (m_pData, m_nSize);
+ FileMapping::unmapFile (m_hFile, m_pData, m_nSize);
}
oslInterlockedCount SAL_CALL MappedLockBytes::acquire()