diff options
Diffstat (limited to 'store')
-rw-r--r-- | store/inc/store/store.hxx | 424 | ||||
-rw-r--r-- | store/inc/store/store.inl | 451 | ||||
-rw-r--r-- | store/source/lockbyte.cxx | 34 | ||||
-rw-r--r-- | store/source/lockbyte.hxx | 32 | ||||
-rw-r--r-- | store/source/object.hxx | 2 | ||||
-rw-r--r-- | store/source/storbase.hxx | 17 | ||||
-rw-r--r-- | store/source/storbios.cxx | 862 | ||||
-rw-r--r-- | store/source/storbios.hxx | 47 | ||||
-rw-r--r-- | store/source/stordata.cxx | 102 | ||||
-rw-r--r-- | store/source/stordata.hxx | 2 | ||||
-rw-r--r-- | store/source/stordir.hxx | 2 | ||||
-rw-r--r-- | store/source/storpage.cxx | 8 | ||||
-rw-r--r-- | store/source/stortree.cxx | 125 | ||||
-rw-r--r-- | store/workben/makefile.mk | 2 | ||||
-rw-r--r-- | store/workben/t_base.cxx | 11 |
15 files changed, 579 insertions, 1542 deletions
diff --git a/store/inc/store/store.hxx b/store/inc/store/store.hxx index 67fa5e3d824b..8e90de321345 100644 --- a/store/inc/store/store.hxx +++ b/store/inc/store/store.hxx @@ -26,11 +26,11 @@ ************************************************************************/ #ifndef _STORE_STORE_HXX_ -#define _STORE_STORE_HXX_ "$Revision: 1.5 $" +#define _STORE_STORE_HXX_ -#include <sal/types.h> -#include <rtl/ustring.hxx> -#include <store/store.h> +#include "sal/types.h" +#include "rtl/ustring.hxx" +#include "store/store.h" namespace store { @@ -45,86 +45,154 @@ class OStoreStream public: /** Construction. */ - inline OStoreStream (void) SAL_THROW(()); + inline OStoreStream (void) SAL_THROW(()) + : m_hImpl (0) + {} /** Destruction. */ - inline ~OStoreStream (void) SAL_THROW(()); + inline ~OStoreStream (void) SAL_THROW(()) + { + if (m_hImpl) + (void) store_releaseHandle (m_hImpl); + } /** Copy construction. */ - inline OStoreStream ( - const OStoreStream& rOther) SAL_THROW(()); + inline OStoreStream (OStoreStream const & rhs) SAL_THROW(()) + : m_hImpl (rhs.m_hImpl) + { + if (m_hImpl) + (void) store_acquireHandle (m_hImpl); + } /** Assignment. */ - inline OStoreStream& operator= ( - const OStoreStream& rOther) SAL_THROW(()); - + inline OStoreStream & operator= (OStoreStream const & rhs) SAL_THROW(()) + { + if (rhs.m_hImpl) + (void) store_acquireHandle (rhs.m_hImpl); + if (m_hImpl) + (void) store_releaseHandle (m_hImpl); + m_hImpl = rhs.m_hImpl; + return *this; + } /** Construction from Stream Handle. */ - inline OStoreStream (storeStreamHandle Handle) SAL_THROW(()); + inline explicit OStoreStream (storeStreamHandle Handle) SAL_THROW(()) + : m_hImpl (Handle) + { + if (m_hImpl) + (void) store_acquireHandle (m_hImpl); + } /** Conversion into Stream Handle. */ - inline operator storeStreamHandle (void) const SAL_THROW(()); + inline operator storeStreamHandle (void) const SAL_THROW(()) + { + return m_hImpl; + } /** Check for a valid Stream Handle. @return sal_True if valid, sal_False otherwise. */ - inline sal_Bool isValid (void) const SAL_THROW(()); - + inline bool isValid (void) const SAL_THROW(()) + { + return (m_hImpl != 0); + } /** Open the stream. @see store_openStream() */ inline storeError create ( - storeFileHandle hFile, - const rtl::OUString &rPath, - const rtl::OUString &rName, - storeAccessMode eMode - ) SAL_THROW(()); + storeFileHandle hFile, + rtl::OUString const & rPath, + rtl::OUString const & rName, + storeAccessMode eMode) SAL_THROW(()) + { + if (m_hImpl) + { + (void) store_releaseHandle (m_hImpl); + m_hImpl = 0; + } + return store_openStream (hFile, rPath.pData, rName.pData, eMode, &m_hImpl); + } /** Close the stream. @see store_closeStream() */ - inline void close (void) SAL_THROW(()); + inline void close (void) SAL_THROW(()) + { + if (m_hImpl) + { + (void) store_closeStream (m_hImpl); + m_hImpl = 0; + } + } /** Read from the stream. @see store_readStream() */ inline storeError readAt ( - sal_uInt32 nOffset, - void *pBuffer, - sal_uInt32 nBytes, - sal_uInt32 &rnDone - ) SAL_THROW(()); + sal_uInt32 nOffset, + void * pBuffer, + sal_uInt32 nBytes, + sal_uInt32 & rnDone) SAL_THROW(()) + { + if (!m_hImpl) + return store_E_InvalidHandle; + + return store_readStream (m_hImpl, nOffset, pBuffer, nBytes, &rnDone); + } /** Write to the stream. @see store_writeStream() */ inline storeError writeAt ( - sal_uInt32 nOffset, - const void *pBuffer, - sal_uInt32 nBytes, - sal_uInt32 &rnDone - ) SAL_THROW(()); + sal_uInt32 nOffset, + void const * pBuffer, + sal_uInt32 nBytes, + sal_uInt32 & rnDone) SAL_THROW(()) + { + if (!m_hImpl) + return store_E_InvalidHandle; + + return store_writeStream (m_hImpl, nOffset, pBuffer, nBytes, &rnDone); + } /** Flush the stream. @see store_flushStream() */ - inline storeError flush (void) const SAL_THROW(()); + inline storeError flush (void) const SAL_THROW(()) + { + if (!m_hImpl) + return store_E_InvalidHandle; + + return store_flushStream (m_hImpl); + } /** Get the stream size. @see store_getStreamSize() */ - inline storeError getSize (sal_uInt32 &rnSize) const SAL_THROW(()); + inline storeError getSize (sal_uInt32 & rnSize) const SAL_THROW(()) + { + if (!m_hImpl) + return store_E_InvalidHandle; + + return store_getStreamSize (m_hImpl, &rnSize); + } /** Set the stream size. @see store_setStreamSize() */ - inline storeError setSize (sal_uInt32 nSize) SAL_THROW(()); + inline storeError setSize (sal_uInt32 nSize) SAL_THROW(()) + { + if (!m_hImpl) + return store_E_InvalidHandle; + + return store_setStreamSize (m_hImpl, nSize); + } private: /** Representation. @@ -142,52 +210,91 @@ class OStoreDirectory public: /** Construction. */ - inline OStoreDirectory (void) SAL_THROW(()); + inline OStoreDirectory (void) SAL_THROW(()) + : m_hImpl (0) + {} /** Destruction. */ - inline ~OStoreDirectory (void) SAL_THROW(()); + inline ~OStoreDirectory (void) SAL_THROW(()) + { + if (m_hImpl) + (void) store_releaseHandle (m_hImpl); + } /** Copy construction. */ - inline OStoreDirectory ( - const OStoreDirectory& rOther) SAL_THROW(()); + inline OStoreDirectory (OStoreDirectory const & rhs) SAL_THROW(()) + : m_hImpl (rhs.m_hImpl) + { + if (m_hImpl) + (void) store_acquireHandle (m_hImpl); + } /** Assignment. */ - inline OStoreDirectory& operator= ( - const OStoreDirectory& rOther) SAL_THROW(()); - + inline OStoreDirectory & operator= (OStoreDirectory const & rhs) SAL_THROW(()) + { + if (rhs.m_hImpl) + (void) store_acquireHandle (rhs.m_hImpl); + if (m_hImpl) + (void) store_releaseHandle (m_hImpl); + m_hImpl = rhs.m_hImpl; + return *this; + } /** Construction from Directory Handle. */ - inline OStoreDirectory (storeDirectoryHandle Handle) SAL_THROW(()); + inline explicit OStoreDirectory (storeDirectoryHandle Handle) SAL_THROW(()) + : m_hImpl (Handle) + { + if (m_hImpl) + (void) store_acquireHandle (m_hImpl); + } /** Conversion into Directory Handle. */ - inline operator storeDirectoryHandle (void) const SAL_THROW(()); + inline operator storeDirectoryHandle(void) const SAL_THROW(()) + { + return m_hImpl; + } /** Check for a valid Directory Handle. @return sal_True if valid, sal_False otherwise. */ - inline sal_Bool isValid (void) const SAL_THROW(()); - + inline bool isValid (void) const SAL_THROW(()) + { + return (m_hImpl != 0); + } /** Open the directory. @see store_openDirectory() */ inline storeError create ( - storeFileHandle hFile, - const rtl::OUString &rPath, - const rtl::OUString &rName, - storeAccessMode eMode - ) SAL_THROW(()); + storeFileHandle hFile, + rtl::OUString const & rPath, + rtl::OUString const & rName, + storeAccessMode eMode) SAL_THROW(()) + { + if (m_hImpl) + { + (void) store_releaseHandle (m_hImpl); + m_hImpl = 0; + } + return store_openDirectory (hFile, rPath.pData, rName.pData, eMode, &m_hImpl); + } /** Close the directory. @see store_closeDirectory() */ - inline void close (void) SAL_THROW(()); - + inline void close (void) SAL_THROW(()) + { + if (m_hImpl) + { + (void) store_closeDirectory (m_hImpl); + m_hImpl = 0; + } + } /** Directory iterator type. @see first() @@ -198,12 +305,24 @@ public: /** Find first directory entry. @see store_findFirst() */ - inline storeError first (iterator& it) SAL_THROW(()); + inline storeError first (iterator& it) SAL_THROW(()) + { + if (!m_hImpl) + return store_E_InvalidHandle; + + return store_findFirst (m_hImpl, &it); + } /** Find next directory entry. @see store_findNext() */ - inline storeError next (iterator& it) SAL_THROW(()); + inline storeError next (iterator& it) SAL_THROW(()) + { + if (!m_hImpl) + return store_E_InvalidHandle; + + return store_findNext (m_hImpl, &it); + } /** Directory traversal helper. @see travel() @@ -225,7 +344,18 @@ public: @param rTraveller [in] the traversal callback. @return store_E_NoMoreFiles upon end of iteration. */ - inline storeError travel (traveller& rTraveller) const; + inline storeError travel (traveller & rTraveller) const + { + storeError eErrCode = store_E_InvalidHandle; + if (m_hImpl) + { + iterator it; + eErrCode = store_findFirst (m_hImpl, &it); + while ((eErrCode == store_E_None) && rTraveller.visit(it)) + eErrCode = store_findNext (m_hImpl, &it); + } + return eErrCode; + } private: /** Representation. @@ -243,126 +373,220 @@ class OStoreFile public: /** Construction. */ - inline OStoreFile (void) SAL_THROW(()); + inline OStoreFile (void) SAL_THROW(()) + : m_hImpl (0) + {} /** Destruction. */ - inline ~OStoreFile (void) SAL_THROW(()); + inline ~OStoreFile (void) SAL_THROW(()) + { + if (m_hImpl) + (void) store_releaseHandle (m_hImpl); + } /** Copy construction. */ - inline OStoreFile (const OStoreFile& rOther) SAL_THROW(()); + inline OStoreFile (OStoreFile const & rhs) SAL_THROW(()) + : m_hImpl (rhs.m_hImpl) + { + if (m_hImpl) + (void) store_acquireHandle (m_hImpl); + } /** Assignment. */ - inline OStoreFile& operator= (const OStoreFile& rOther) SAL_THROW(()); - + inline OStoreFile & operator= (OStoreFile const & rhs) SAL_THROW(()) + { + if (rhs.m_hImpl) + (void) store_acquireHandle (rhs.m_hImpl); + if (m_hImpl) + (void) store_releaseHandle (m_hImpl); + m_hImpl = rhs.m_hImpl; + return *this; + } /** Construction from File Handle. */ - inline OStoreFile (storeFileHandle Handle) SAL_THROW(()); + inline explicit OStoreFile (storeFileHandle Handle) SAL_THROW(()) + : m_hImpl (Handle) + { + if (m_hImpl) + (void) store_acquireHandle (m_hImpl); + } /** Conversion into File Handle. */ - inline operator storeFileHandle (void) const SAL_THROW(()); + inline operator storeFileHandle (void) const SAL_THROW(()) + { + return m_hImpl; + } /** Check for a valid File Handle. @return sal_True if valid, sal_False otherwise. */ - inline sal_Bool isValid (void) const SAL_THROW(()); - + inline bool isValid (void) const SAL_THROW(()) + { + return (m_hImpl != 0); + } /** Open the file. @see store_openFile() */ inline storeError create ( - const rtl::OUString &rFilename, - storeAccessMode eAccessMode, - sal_uInt16 nPageSize = STORE_DEFAULT_PAGESIZE - ) SAL_THROW(()); + rtl::OUString const & rFilename, + storeAccessMode eAccessMode, + sal_uInt16 nPageSize = STORE_DEFAULT_PAGESIZE) SAL_THROW(()) + { + if (m_hImpl) + { + (void) store_releaseHandle (m_hImpl); + m_hImpl = 0; + } + return store_openFile (rFilename.pData, eAccessMode, nPageSize, &m_hImpl); + } /** Open the temporary file in memory. @see store_createMemoryFile() */ inline storeError createInMemory ( - sal_uInt16 nPageSize = STORE_DEFAULT_PAGESIZE - ) SAL_THROW(()); + sal_uInt16 nPageSize = STORE_DEFAULT_PAGESIZE) SAL_THROW(()) + { + if (m_hImpl) + { + (void) store_releaseHandle (m_hImpl); + m_hImpl = 0; + } + return store_createMemoryFile (nPageSize, &m_hImpl); + } /** Close the file. @see store_closeFile() */ - inline void close (void) SAL_THROW(()); + inline void close (void) SAL_THROW(()) + { + if (m_hImpl) + { + (void) store_closeFile (m_hImpl); + m_hImpl = 0; + } + } /** Flush the file. @see store_flushFile() */ - inline storeError flush (void) const SAL_THROW(()); + inline storeError flush (void) const SAL_THROW(()) + { + if (!m_hImpl) + return store_E_InvalidHandle; + + return store_flushFile (m_hImpl); + } /** Get the number of referers to the file. @see store_getFileRefererCount() */ - inline storeError getRefererCount ( - sal_uInt32 &rnRefCount) const SAL_THROW(()); + inline storeError getRefererCount (sal_uInt32 & rnRefCount) const SAL_THROW(()) + { + if (!m_hImpl) + return store_E_InvalidHandle; + + return store_getFileRefererCount (m_hImpl, &rnRefCount); + } /** Get the file size. @see store_getFileSize() */ - inline storeError getSize ( - sal_uInt32 &rnSize) const SAL_THROW(()); + inline storeError getSize (sal_uInt32 & rnSize) const SAL_THROW(()) + { + if (!m_hImpl) + return store_E_InvalidHandle; + return store_getFileSize (m_hImpl, &rnSize); + } /** Set attributes of a file entry. @see store_attrib() */ inline storeError attrib ( - const rtl::OUString &rPath, - const rtl::OUString &rName, - sal_uInt32 nMask1, - sal_uInt32 nMask2, - sal_uInt32 &rnAttrib - ) SAL_THROW(()); + rtl::OUString const & rPath, + rtl::OUString const & rName, + sal_uInt32 nMask1, + sal_uInt32 nMask2, + sal_uInt32 & rnAttrib) SAL_THROW(()) + { + if (!m_hImpl) + return store_E_InvalidHandle; + + return store_attrib (m_hImpl, rPath.pData, rName.pData, nMask1, nMask2, &rnAttrib); + } /** Set attributes of a file entry. @see store_attrib() */ inline storeError attrib ( - const rtl::OUString &rPath, - const rtl::OUString &rName, - sal_uInt32 nMask1, - sal_uInt32 nMask2 - ) SAL_THROW(()); + rtl::OUString const & rPath, + rtl::OUString const & rName, + sal_uInt32 nMask1, + sal_uInt32 nMask2) SAL_THROW(()) + { + if (!m_hImpl) + return store_E_InvalidHandle; + + return store_attrib (m_hImpl, rPath.pData, rName.pData, nMask1, nMask2, NULL); + } /** Insert a file entry as 'hard link' to another file entry. @see store_link() */ inline storeError link ( - const rtl::OUString &rSrcPath, const rtl::OUString &rSrcName, - const rtl::OUString &rDstPath, const rtl::OUString &rDstName - ) SAL_THROW(()); + rtl::OUString const & rSrcPath, rtl::OUString const & rSrcName, + rtl::OUString const & rDstPath, rtl::OUString const & rDstName) SAL_THROW(()) + { + if (!m_hImpl) + return store_E_InvalidHandle; + + return store_link ( + m_hImpl, rSrcPath.pData, rSrcName.pData, rDstPath.pData, rDstName.pData); + } /** Insert a file entry as 'symbolic link' to another file entry. @see store_symlink() */ inline storeError symlink ( - const rtl::OUString &rSrcPath, const rtl::OUString &rSrcName, - const rtl::OUString &rDstPath, const rtl::OUString &rDstName - ) SAL_THROW(()); + rtl::OUString const & rSrcPath, rtl::OUString const & rSrcName, + rtl::OUString const & rDstPath, rtl::OUString const & rDstName) SAL_THROW(()) + { + if (!m_hImpl) + return store_E_InvalidHandle; + + return store_symlink (m_hImpl, rSrcPath.pData, rSrcName.pData, rDstPath.pData, rDstName.pData); + } /** Rename a file entry. @see store_rename() */ inline storeError rename ( - const rtl::OUString &rSrcPath, const rtl::OUString &rSrcName, - const rtl::OUString &rDstPath, const rtl::OUString &rDstName - ) SAL_THROW(()); + rtl::OUString const & rSrcPath, rtl::OUString const & rSrcName, + rtl::OUString const & rDstPath, rtl::OUString const & rDstName) SAL_THROW(()) + { + if (!m_hImpl) + return store_E_InvalidHandle; + + return store_rename (m_hImpl, rSrcPath.pData, rSrcName.pData, rDstPath.pData, rDstName.pData); + } /** Remove a file entry. @see store_remove() */ inline storeError remove ( - const rtl::OUString &rPath, - const rtl::OUString &rName - ) SAL_THROW(()); + rtl::OUString const & rPath, rtl::OUString const & rName) SAL_THROW(()) + { + if (!m_hImpl) + return store_E_InvalidHandle; + + return store_remove (m_hImpl, rPath.pData, rName.pData); + } private: /** Representation. @@ -376,8 +600,6 @@ private: * *======================================================================*/ -#include <store/store.inl> - } // namespace store #endif /* !_STORE_STORE_HXX_ */ diff --git a/store/inc/store/store.inl b/store/inc/store/store.inl deleted file mode 100644 index 91866c7311da..000000000000 --- a/store/inc/store/store.inl +++ /dev/null @@ -1,451 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#define _STORE_STORE_INL_ "$Revision: 1.4 $" - -/*======================================================================== - * - * OStoreStream implementation. - * - *======================================================================*/ -inline OStoreStream::OStoreStream (void) SAL_THROW(()) - : m_hImpl (0) -{ -} - -inline OStoreStream::~OStoreStream (void) SAL_THROW(()) -{ - if (m_hImpl) - store_releaseHandle (m_hImpl); -} - -inline OStoreStream::OStoreStream ( - const OStoreStream& rOther) SAL_THROW(()) - : m_hImpl (rOther.m_hImpl) -{ - if (m_hImpl) - store_acquireHandle (m_hImpl); -} - -inline OStoreStream& OStoreStream::operator= ( - const OStoreStream& rOther) SAL_THROW(()) -{ - if (m_hImpl) - store_releaseHandle (m_hImpl); - m_hImpl = rOther.m_hImpl; - if (m_hImpl) - store_acquireHandle (m_hImpl); - return *this; -} - -inline OStoreStream::OStoreStream ( - storeStreamHandle Handle) SAL_THROW(()) - : m_hImpl (Handle) -{ - if (m_hImpl) - store_acquireHandle (m_hImpl); -} - -inline OStoreStream::operator storeStreamHandle (void) const SAL_THROW(()) -{ - return m_hImpl; -} - -inline sal_Bool OStoreStream::isValid (void) const SAL_THROW(()) -{ - return (!!m_hImpl); -} - -inline storeError OStoreStream::create ( - storeFileHandle hFile, - const rtl::OUString &rPath, - const rtl::OUString &rName, - storeAccessMode eMode) SAL_THROW(()) -{ - if (m_hImpl) - { - store_releaseHandle (m_hImpl); - m_hImpl = 0; - } - return store_openStream ( - hFile, rPath.pData, rName.pData, eMode, &m_hImpl); -} - -inline void OStoreStream::close (void) SAL_THROW(()) -{ - if (m_hImpl) - { - store_closeStream (m_hImpl); - m_hImpl = 0; - } -} - -inline storeError OStoreStream::readAt ( - sal_uInt32 nOffset, - void *pBuffer, - sal_uInt32 nBytes, - sal_uInt32 &rnDone) SAL_THROW(()) -{ - if (!m_hImpl) - return store_E_InvalidHandle; - - return store_readStream ( - m_hImpl, nOffset, pBuffer, nBytes, &rnDone); -} - -inline storeError OStoreStream::writeAt ( - sal_uInt32 nOffset, - const void *pBuffer, - sal_uInt32 nBytes, - sal_uInt32 &rnDone) SAL_THROW(()) -{ - if (!m_hImpl) - return store_E_InvalidHandle; - - return store_writeStream ( - m_hImpl, nOffset, pBuffer, nBytes, &rnDone); -} - -inline storeError OStoreStream::flush (void) const SAL_THROW(()) -{ - if (!m_hImpl) - return store_E_InvalidHandle; - - return store_flushStream (m_hImpl); -} - -inline storeError OStoreStream::getSize ( - sal_uInt32 &rnSize) const SAL_THROW(()) -{ - if (!m_hImpl) - return store_E_InvalidHandle; - - return store_getStreamSize (m_hImpl, &rnSize); -} - -inline storeError OStoreStream::setSize ( - sal_uInt32 nSize) SAL_THROW(()) -{ - if (!m_hImpl) - return store_E_InvalidHandle; - - return store_setStreamSize (m_hImpl, nSize); -} - -/*======================================================================== - * - * OStoreDirectory implementation. - * - *======================================================================*/ -inline OStoreDirectory::OStoreDirectory (void) SAL_THROW(()) - : m_hImpl (0) -{ -} - -inline OStoreDirectory::~OStoreDirectory (void) SAL_THROW(()) -{ - if (m_hImpl) - store_releaseHandle (m_hImpl); -} - -inline OStoreDirectory::OStoreDirectory ( - const OStoreDirectory& rOther) SAL_THROW(()) - : m_hImpl (rOther.m_hImpl) -{ - if (m_hImpl) - store_acquireHandle (m_hImpl); -} - -inline OStoreDirectory& OStoreDirectory::operator= ( - const OStoreDirectory& rOther) SAL_THROW(()) -{ - if (m_hImpl) - store_releaseHandle (m_hImpl); - m_hImpl = rOther.m_hImpl; - if (m_hImpl) - store_acquireHandle (m_hImpl); - return *this; -} - -inline OStoreDirectory::OStoreDirectory ( - storeDirectoryHandle Handle) SAL_THROW(()) - : m_hImpl (Handle) -{ - if (m_hImpl) - store_acquireHandle (m_hImpl); -} - -inline OStoreDirectory::operator storeDirectoryHandle(void) const SAL_THROW(()) -{ - return m_hImpl; -} - -inline sal_Bool OStoreDirectory::isValid (void) const SAL_THROW(()) -{ - return (!!m_hImpl); -} - -inline storeError OStoreDirectory::create ( - storeFileHandle hFile, - const rtl::OUString &rPath, - const rtl::OUString &rName, - storeAccessMode eMode) SAL_THROW(()) -{ - if (m_hImpl) - { - store_releaseHandle (m_hImpl); - m_hImpl = 0; - } - return store_openDirectory ( - hFile, rPath.pData, rName.pData, eMode, &m_hImpl); -} - -inline void OStoreDirectory::close (void) SAL_THROW(()) -{ - if (m_hImpl) - { - store_closeDirectory (m_hImpl); - m_hImpl = 0; - } -} - -inline storeError OStoreDirectory::first (iterator& it) SAL_THROW(()) -{ - if (!m_hImpl) - return store_E_InvalidHandle; - - return store_findFirst (m_hImpl, &it); -} - -inline storeError OStoreDirectory::next (iterator& it) SAL_THROW(()) -{ - if (!m_hImpl) - return store_E_InvalidHandle; - - return store_findNext (m_hImpl, &it); -} - -inline storeError OStoreDirectory::travel (traveller& rTraveller) const -{ - storeError eErrCode = store_E_InvalidHandle; - if (m_hImpl) - { - iterator it; - eErrCode = store_findFirst (m_hImpl, &it); - while ((eErrCode == store_E_None) && rTraveller.visit(it)) - eErrCode = store_findNext (m_hImpl, &it); - } - return eErrCode; -} - -/*======================================================================== - * - * OStoreFile implementation. - * - *======================================================================*/ -inline OStoreFile::OStoreFile (void) SAL_THROW(()) - : m_hImpl (0) -{ -} - -inline OStoreFile::~OStoreFile (void) SAL_THROW(()) -{ - if (m_hImpl) - store_releaseHandle (m_hImpl); -} - -inline OStoreFile::OStoreFile ( - const OStoreFile& rOther) SAL_THROW(()) - : m_hImpl (rOther.m_hImpl) -{ - if (m_hImpl) - store_acquireHandle (m_hImpl); -} - -inline OStoreFile& OStoreFile::operator= ( - const OStoreFile& rOther) SAL_THROW(()) -{ - if (m_hImpl) - store_releaseHandle (m_hImpl); - m_hImpl = rOther.m_hImpl; - if (m_hImpl) - store_acquireHandle (m_hImpl); - return *this; -} - -inline OStoreFile::OStoreFile ( - storeFileHandle Handle) SAL_THROW(()) - : m_hImpl (Handle) -{ - if (m_hImpl) - store_acquireHandle (m_hImpl); -} - -inline OStoreFile::operator storeFileHandle (void) const SAL_THROW(()) -{ - return m_hImpl; -} - -inline sal_Bool OStoreFile::isValid (void) const SAL_THROW(()) -{ - return (!!m_hImpl); -} - -inline storeError OStoreFile::create ( - const rtl::OUString &rFilename, - storeAccessMode eAccessMode, - sal_uInt16 nPageSize) SAL_THROW(()) -{ - if (m_hImpl) - { - store_releaseHandle (m_hImpl); - m_hImpl = 0; - } - return store_openFile (rFilename.pData, eAccessMode, nPageSize, &m_hImpl); -} - -inline storeError OStoreFile::createInMemory ( - sal_uInt16 nPageSize) SAL_THROW(()) -{ - if (m_hImpl) - { - store_releaseHandle (m_hImpl); - m_hImpl = 0; - } - return store_createMemoryFile (nPageSize, &m_hImpl); -} - -inline void OStoreFile::close (void) SAL_THROW(()) -{ - if (m_hImpl) - { - store_closeFile (m_hImpl); - m_hImpl = 0; - } -} - -inline storeError OStoreFile::flush (void) const SAL_THROW(()) -{ - if (!m_hImpl) - return store_E_InvalidHandle; - - return store_flushFile (m_hImpl); -} - -inline storeError OStoreFile::getRefererCount ( - sal_uInt32 &rnRefCount) const SAL_THROW(()) -{ - if (!m_hImpl) - return store_E_InvalidHandle; - - return store_getFileRefererCount (m_hImpl, &rnRefCount); -} - -inline storeError OStoreFile::getSize ( - sal_uInt32 &rnSize) const SAL_THROW(()) -{ - if (!m_hImpl) - return store_E_InvalidHandle; - - return store_getFileSize (m_hImpl, &rnSize); -} - -inline storeError OStoreFile::attrib ( - const rtl::OUString &rPath, - const rtl::OUString &rName, - sal_uInt32 nMask1, - sal_uInt32 nMask2, - sal_uInt32 &rnAttrib) SAL_THROW(()) -{ - if (!m_hImpl) - return store_E_InvalidHandle; - - return store_attrib ( - m_hImpl, rPath.pData, rName.pData, nMask1, nMask2, &rnAttrib); -} - -inline storeError OStoreFile::attrib ( - const rtl::OUString &rPath, - const rtl::OUString &rName, - sal_uInt32 nMask1, - sal_uInt32 nMask2) SAL_THROW(()) -{ - if (!m_hImpl) - return store_E_InvalidHandle; - - return store_attrib ( - m_hImpl, rPath.pData, rName.pData, nMask1, nMask2, NULL); -} - -inline storeError OStoreFile::link ( - const rtl::OUString &rSrcPath, const rtl::OUString &rSrcName, - const rtl::OUString &rDstPath, const rtl::OUString &rDstName) SAL_THROW(()) -{ - if (!m_hImpl) - return store_E_InvalidHandle; - - return store_link ( - m_hImpl, - rSrcPath.pData, rSrcName.pData, - rDstPath.pData, rDstName.pData); -} - -inline storeError OStoreFile::symlink ( - const rtl::OUString &rSrcPath, const rtl::OUString &rSrcName, - const rtl::OUString &rDstPath, const rtl::OUString &rDstName) SAL_THROW(()) -{ - if (!m_hImpl) - return store_E_InvalidHandle; - - return store_symlink ( - m_hImpl, - rSrcPath.pData, rSrcName.pData, - rDstPath.pData, rDstName.pData); -} - -inline storeError OStoreFile::rename ( - const rtl::OUString &rSrcPath, const rtl::OUString &rSrcName, - const rtl::OUString &rDstPath, const rtl::OUString &rDstName) SAL_THROW(()) -{ - if (!m_hImpl) - return store_E_InvalidHandle; - - return store_rename ( - m_hImpl, - rSrcPath.pData, rSrcName.pData, - rDstPath.pData, rDstName.pData); -} - -inline storeError OStoreFile::remove ( - const rtl::OUString &rPath, const rtl::OUString &rName) SAL_THROW(()) -{ - if (!m_hImpl) - return store_E_InvalidHandle; - - return store_remove (m_hImpl, rPath.pData, rName.pData); -} - diff --git a/store/source/lockbyte.cxx b/store/source/lockbyte.cxx index 795b720e0632..f1145a029c29 100644 --- a/store/source/lockbyte.cxx +++ b/store/source/lockbyte.cxx @@ -148,40 +148,6 @@ storeError ILockBytes::flush() return flush_Impl(); } -storeError ILockBytes::lockRange (sal_uInt32 nOffset, sal_uInt32 nBytes) -{ - OSL_PRECOND(!(nOffset == STORE_PAGE_NULL), "store::ILockBytes::lockRange(): invalid Offset"); - if (nOffset == STORE_PAGE_NULL) - return store_E_CantSeek; - - sal_uInt64 size = nOffset + nBytes; - if (size > SAL_MAX_UINT32) - return store_E_CantSeek; - -#ifdef STORE_FEATURE_LOCKING - return lockRange_Impl (nOffset, nBytes); -#else - return store_E_None; // E_Unsupported -#endif /* STORE_FEATURE_LOCKING */ -} - -storeError ILockBytes::unlockRange (sal_uInt32 nOffset, sal_uInt32 nBytes) -{ - OSL_PRECOND(!(nOffset == STORE_PAGE_NULL), "store::ILockBytes::unlockRange(): invalid Offset"); - if (nOffset == STORE_PAGE_NULL) - return store_E_CantSeek; - - sal_uInt64 size = nOffset + nBytes; - if (size > SAL_MAX_UINT32) - return store_E_CantSeek; - -#ifdef STORE_FEATURE_LOCKING - return unlockRange_Impl (nOffset, nBytes); -#else - return store_E_None; // E_Unsupported -#endif /* STORE_FEATURE_LOCKING */ -} - /*======================================================================== * * FileLockBytes implementation. diff --git a/store/source/lockbyte.hxx b/store/source/lockbyte.hxx index bbaf92c4ae99..b2b6c905f9fd 100644 --- a/store/source/lockbyte.hxx +++ b/store/source/lockbyte.hxx @@ -26,7 +26,7 @@ ************************************************************************/ #ifndef _STORE_LOCKBYTE_HXX_ -#define _STORE_LOCKBYTE_HXX_ "$Revision: 1.1.2.1 $" +#define _STORE_LOCKBYTE_HXX_ #ifndef _SAL_TYPES_H_ #include "sal/types.h" @@ -120,26 +120,6 @@ public: */ storeError flush(); - /** - @param nOffset [in] - @param nBytes [in] - @return store_E_None upon success - store_E_LockingViolation - */ - storeError lockRange ( - sal_uInt32 nOffset, - sal_uInt32 nBytes); - - /** - @param nOffset [in] - @param nBytes [in] - @return store_E_None upon success - store_E_LockingViolation - */ - storeError unlockRange ( - sal_uInt32 nOffset, - sal_uInt32 nBytes); - private: /** Implementation (abstract). */ @@ -172,16 +152,6 @@ private: sal_uInt32 nSize) = 0; virtual storeError flush_Impl() = 0; - -#ifdef STORE_FEATURE_LOCKING - virtual storeError lockRange_Impl ( - sal_uInt32 nOffset, - sal_uInt32 nBytes) = 0; - - virtual storeError unlockRange_Impl ( - sal_uInt32 nOffset, - sal_uInt32 nBytes) = 0; -#endif /* STORE_FEATURE_LOCKING */ }; /*======================================================================== diff --git a/store/source/object.hxx b/store/source/object.hxx index 1061b9c568a9..a3b5ab1c6e63 100644 --- a/store/source/object.hxx +++ b/store/source/object.hxx @@ -26,7 +26,7 @@ ************************************************************************/ #ifndef _STORE_OBJECT_HXX_ -#define _STORE_OBJECT_HXX_ "$Revision: 1.1.2.1 $" +#define _STORE_OBJECT_HXX_ #ifndef _SAL_TYPES_H_ #include "sal/types.h" diff --git a/store/source/storbase.hxx b/store/source/storbase.hxx index 0a489c1ee29f..9c1e4ea985bf 100644 --- a/store/source/storbase.hxx +++ b/store/source/storbase.hxx @@ -553,13 +553,6 @@ struct PageData /** guard (external representation). */ - void guard() - { - sal_uInt32 nCRC32 = 0; - nCRC32 = rtl_crc32 (nCRC32, &m_aGuard.m_nMagic, sizeof(sal_uInt32)); - nCRC32 = rtl_crc32 (nCRC32, &m_aDescr, theSize - sizeof(G)); - m_aGuard.m_nCRC32 = store::htonl(nCRC32); - } void guard (sal_uInt32 nAddr) { sal_uInt32 nCRC32 = 0; @@ -571,16 +564,6 @@ struct PageData /** verify (external representation). */ - storeError verify() const - { - sal_uInt32 nCRC32 = 0; - nCRC32 = rtl_crc32 (nCRC32, &m_aGuard.m_nMagic, sizeof(sal_uInt32)); - nCRC32 = rtl_crc32 (nCRC32, &m_aDescr, theSize - sizeof(G)); - if (m_aGuard.m_nCRC32 != store::htonl(nCRC32)) - return store_E_InvalidChecksum; - else - return store_E_None; - } storeError verify (sal_uInt32 nAddr) const { sal_uInt32 nCRC32 = 0; diff --git a/store/source/storbios.cxx b/store/source/storbios.cxx index 6f1a5cde0340..9014ca1fd149 100644 --- a/store/source/storbios.cxx +++ b/store/source/storbios.cxx @@ -83,36 +83,36 @@ struct OStoreSuperBlock m_aUnused (0) {} - OStoreSuperBlock (const OStoreSuperBlock& rOther) - : m_aGuard (rOther.m_aGuard), - m_aDescr (rOther.m_aDescr), - m_nMarked (rOther.m_nMarked), - m_aMarked (rOther.m_aMarked), - m_nUnused (rOther.m_nUnused), - m_aUnused (rOther.m_aUnused) + OStoreSuperBlock (const OStoreSuperBlock & rhs) + : m_aGuard (rhs.m_aGuard), + m_aDescr (rhs.m_aDescr), + m_nMarked (rhs.m_nMarked), + m_aMarked (rhs.m_aMarked), + m_nUnused (rhs.m_nUnused), + m_aUnused (rhs.m_aUnused) {} - OStoreSuperBlock& operator= (const OStoreSuperBlock& rOther) + OStoreSuperBlock& operator= (const OStoreSuperBlock & rhs) { - m_aGuard = rOther.m_aGuard; - m_aDescr = rOther.m_aDescr; - m_nMarked = rOther.m_nMarked; - m_aMarked = rOther.m_aMarked; - m_nUnused = rOther.m_nUnused; - m_aUnused = rOther.m_aUnused; + m_aGuard = rhs.m_aGuard; + m_aDescr = rhs.m_aDescr; + m_nMarked = rhs.m_nMarked; + m_aMarked = rhs.m_aMarked; + m_nUnused = rhs.m_nUnused; + m_aUnused = rhs.m_aUnused; return *this; } /** Comparison. */ - sal_Bool operator== (const OStoreSuperBlock& rOther) const + sal_Bool operator== (const OStoreSuperBlock & rhs) const { - return ((m_aGuard == rOther.m_aGuard ) && - (m_aDescr == rOther.m_aDescr ) && - (m_nMarked == rOther.m_nMarked) && - (m_aMarked == rOther.m_aMarked) && - (m_nUnused == rOther.m_nUnused) && - (m_aUnused == rOther.m_aUnused) ); + return ((m_aGuard == rhs.m_aGuard ) && + (m_aDescr == rhs.m_aDescr ) && + (m_nMarked == rhs.m_nMarked) && + (m_aMarked == rhs.m_aMarked) && + (m_nUnused == rhs.m_nUnused) && + (m_aUnused == rhs.m_aUnused) ); } /** unused(Count|Head|Insert|Remove|Reset). @@ -173,94 +173,24 @@ struct OStoreSuperBlock /*======================================================================== * - * OStoreStateBlock. - * - *======================================================================*/ -struct OStoreStateBlock -{ - enum StateBits - { - STATE_CLEAN = 0, - STATE_CLOSE_WAIT = 1, - STATE_FLUSH_WAIT = 2 - }; - - /** Representation. - */ - sal_uInt32 m_nState; - - /** theSize. - */ - static const size_t theSize = sizeof(sal_uInt32); - - /** Construction. - */ - OStoreStateBlock() - : m_nState (store::htonl(STATE_CLEAN)) - {} - - /** Operation. - */ - bool closePending (void) const - { - sal_uInt32 nState = store::ntohl(m_nState); - return ((nState & STATE_CLOSE_WAIT) == STATE_CLOSE_WAIT); - } - void closed (void) - { - sal_uInt32 nState = store::ntohl(m_nState); - nState &= ~STATE_CLOSE_WAIT; - m_nState = store::htonl(nState); - } - - bool flushPending (void) const - { - sal_uInt32 nState = store::ntohl(m_nState); - return ((nState & STATE_FLUSH_WAIT) == STATE_FLUSH_WAIT); - } - void flushed (void) - { - sal_uInt32 nState = store::ntohl(m_nState); - nState &= ~STATE_FLUSH_WAIT; - m_nState = store::htonl(nState); - } - - void modified (void) - { - sal_uInt32 nState = store::ntohl(m_nState); - nState |= (STATE_CLOSE_WAIT | STATE_FLUSH_WAIT); - m_nState = store::htonl(nState); - } - void clean (void) - { - sal_uInt32 nState = store::ntohl(m_nState); - nState &= ~(STATE_CLOSE_WAIT | STATE_FLUSH_WAIT); - m_nState = store::htonl(nState); - } -}; - -/*======================================================================== - * - * OStoreSuperBlockPage interface. + * SuperBlockPage interface. * *======================================================================*/ namespace store { -struct OStoreSuperBlockPage +struct SuperBlockPage { typedef OStoreSuperBlock SuperBlock; - typedef OStoreStateBlock StateBlock; /** Representation. */ SuperBlock m_aSuperOne; SuperBlock m_aSuperTwo; - StateBlock m_aState; /** theSize. */ - static const size_t theSize = 2 * SuperBlock::theSize + StateBlock::theSize; + static const size_t theSize = 2 * SuperBlock::theSize; static const sal_uInt16 thePageSize = theSize; STORE_STATIC_ASSERT(STORE_MINIMUM_PAGESIZE >= thePageSize); @@ -286,147 +216,138 @@ struct OStoreSuperBlockPage /** Construction. */ - explicit OStoreSuperBlockPage (sal_uInt16 nPageSize = thePageSize) + explicit SuperBlockPage (sal_uInt16 nPageSize = thePageSize) : m_aSuperOne(nPageSize), - m_aSuperTwo(nPageSize), - m_aState() + m_aSuperTwo(nPageSize) {} - /** guard (external representation). - */ - void guard() - { - m_aSuperOne.guard(); - m_aSuperTwo.guard(); - } - /** save. */ - storeError save (OStorePageBIOS &rBIOS) + storeError save (OStorePageBIOS & rBIOS, sal_uInt32 nSize = theSize) { - // Guard. - guard(); - - // Write. - return rBIOS.write (0, this, theSize); + m_aSuperOne.guard(); + m_aSuperTwo = m_aSuperOne; + return rBIOS.write (0, this, nSize); } - /** close. + /** Page allocation. */ - storeError close ( - OStorePageBIOS &rBIOS); + storeError unusedHead ( + OStorePageBIOS & rBIOS, + PageData & rPageHead); - /** flush. - */ - storeError flush ( - OStorePageBIOS &rBIOS); + storeError unusedPop ( + OStorePageBIOS & rBIOS, + PageData const & rPageHead); - /** modified. - */ - storeError modified ( - OStorePageBIOS &rBIOS); + storeError unusedPush ( + OStorePageBIOS & rBIOS, + sal_uInt32 nAddr); /** verify (with repair). */ - storeError verify ( - OStorePageBIOS &rBIOS); + storeError verify (OStorePageBIOS & rBIOS); }; } // namespace store /*======================================================================== * - * OStoreSuperBlockPage implementation. + * SuperBlockPage implementation. * *======================================================================*/ /* - * close. + * unusedHead(): get freelist head (alloc page, step 1). */ -storeError OStoreSuperBlockPage::close (OStorePageBIOS &rBIOS) +storeError SuperBlockPage::unusedHead (OStorePageBIOS & rBIOS, PageData & rPageHead) { - storeError eErrCode = store_E_None; - if (m_aState.closePending()) + storeError eErrCode = verify (rBIOS); + if (eErrCode != store_E_None) + return eErrCode; + + // Check freelist head. + OStorePageLink const aListHead (m_aSuperOne.unusedHead()); + if (aListHead.location() == 0) { - // Mark as modified. - m_aState.modified(); + // Freelist empty, see SuperBlock::ctor(). + rPageHead.location (STORE_PAGE_NULL); + return store_E_None; + } - // Check access mode. - if (rBIOS.isWriteable()) - { - // Save StateBlock. - StateBlock aState (m_aState); + // Load PageHead. + eErrCode = rBIOS.read (aListHead.location(), &rPageHead, PageData::theSize); + if (eErrCode != store_E_None) + return eErrCode; - // Mark as clean. - aState.clean(); + eErrCode = rPageHead.verify (aListHead.location()); + if (eErrCode != store_E_None) + return eErrCode; - // Write behind SuperBlock. - sal_uInt32 nAddr = 2 * SuperBlock::theSize; - eErrCode = rBIOS.write (nAddr, &aState, StateBlock::theSize); - } + // Verify page is unused. + sal_uInt32 const nAddr = rPageHead.m_aUnused.location(); + OSL_POSTCOND(nAddr != STORE_PAGE_NULL, "store::SuperBlock::unusedHead(): page not free"); + if (nAddr == STORE_PAGE_NULL) + { + // Page in use. + rPageHead.location (STORE_PAGE_NULL); - // Mark as clean. - m_aState.clean(); + // Recovery: Reset freelist to empty. + m_aSuperOne.unusedReset(); + eErrCode = save (rBIOS); } return eErrCode; } /* - * flush. + * unusedPop(): pop freelist head (alloc page, step 2). */ -storeError OStoreSuperBlockPage::flush (OStorePageBIOS &rBIOS) +storeError SuperBlockPage::unusedPop (OStorePageBIOS & rBIOS, PageData const & rPageHead) { - storeError eErrCode = store_E_None; - if (m_aState.flushPending()) - { - // Check access mode. - if (rBIOS.isWriteable()) - { - // Save StateBlock. - StateBlock aState (m_aState); - - // Mark as flushed. - aState.flushed(); - - // Write behind SuperBlock. - sal_uInt32 nAddr = 2 * SuperBlock::theSize; - eErrCode = rBIOS.write (nAddr, &aState, StateBlock::theSize); - } - - // Mark as flushed. - m_aState.flushed(); - } - return eErrCode; + sal_uInt32 const nAddr = rPageHead.m_aUnused.location(); + OSL_PRECOND(nAddr != STORE_PAGE_NULL, "store::SuperBlock::unusedPop(): page not free"); + if (nAddr == STORE_PAGE_NULL) + return store_E_CantSeek; + + // Pop from FreeList. + OStorePageLink const aListHead (nAddr); + m_aSuperOne.unusedRemove (aListHead); + return save (rBIOS); } /* - * modified. + * unusedPush(): push new freelist head. */ -storeError OStoreSuperBlockPage::modified (OStorePageBIOS &rBIOS) +storeError SuperBlockPage::unusedPush (OStorePageBIOS & rBIOS, sal_uInt32 nAddr) { - storeError eErrCode = store_E_None; - if (!m_aState.flushPending()) - { - // Mark as modified. - m_aState.modified(); + storeError eErrCode = verify (rBIOS); + if (eErrCode != store_E_None) + return eErrCode; - // Check access mode. - if (rBIOS.isWriteable()) - { - // Save StateBlock. - StateBlock aState (m_aState); + PageData aPageHead; + eErrCode = rBIOS.read (nAddr, &aPageHead, PageData::theSize); + if (eErrCode != store_E_None) + return eErrCode; - // Write behind SuperBlock. - sal_uInt32 nAddr = 2 * SuperBlock::theSize; - eErrCode = rBIOS.write (nAddr, &aState, StateBlock::theSize); - } - } - return eErrCode; + eErrCode = aPageHead.verify (nAddr); + if (eErrCode != store_E_None) + return eErrCode; + + aPageHead.m_aUnused = m_aSuperOne.unusedHead(); + aPageHead.guard (nAddr); + + eErrCode = rBIOS.write (nAddr, &aPageHead, PageData::theSize); + if (eErrCode != store_E_None) + return eErrCode; + + OStorePageLink const aListHead (nAddr); + m_aSuperOne.unusedInsert(aListHead); + return save (rBIOS); } /* * verify (with repair). */ -storeError OStoreSuperBlockPage::verify (OStorePageBIOS &rBIOS) +storeError SuperBlockPage::verify (OStorePageBIOS & rBIOS) { // Verify 1st copy. storeError eErrCode = m_aSuperOne.verify(); @@ -636,8 +557,7 @@ OStorePageBIOS::AceCache::destroy (OStorePageBIOS::Ace * ace) OStorePageBIOS::OStorePageBIOS (void) : m_xLockBytes (NULL), m_pSuper (NULL), - m_bModified (sal_False), - m_bWriteable (sal_False) + m_bWriteable (false) { } @@ -646,158 +566,63 @@ OStorePageBIOS::OStorePageBIOS (void) */ OStorePageBIOS::~OStorePageBIOS (void) { - OStorePageBIOS::close(); -} - -/* - * verify (SuperBlock with repair). - * Internal: Precond: initialized, exclusive access. - */ -storeError OStorePageBIOS::verify (SuperPage *&rpSuper) -{ - // Check SuperBlock page allocation. - if (rpSuper == 0) - { - // Allocate. - if ((rpSuper = new SuperPage()) == 0) - return store_E_OutOfMemory; - - // Load (w/o verification). - storeError eErrCode = read (0, rpSuper, SuperPage::theSize); - if (eErrCode != store_E_None) - { - // Cleanup and fail. - delete rpSuper, rpSuper = 0; - return eErrCode; - } - - // Check SuperBlock state. - if (rpSuper->m_aState.closePending()) - OSL_TRACE("OStorePageBIOS::verify(): close pending.\n"); - - if (rpSuper->m_aState.flushPending()) - OSL_TRACE("OStorePageBIOS::verify(): flush pending.\n"); - } - - // Verify SuperBlock page (with repair). - return rpSuper->verify (*this); -} - -/* - * repair (SuperBlock). - * Internal: Precond: initialized, exclusive access. - */ -storeError OStorePageBIOS::repair (SuperPage *&rpSuper) -{ - // Acquire Lock. - storeError eErrCode = acquireLock (0, SuperPage::theSize); - if (eErrCode != store_E_None) - return eErrCode; - - // Verify SuperBlock page (with repair). - eErrCode = verify (rpSuper); - if (eErrCode != store_E_None) - { - // Failure. - releaseLock (0, SuperPage::theSize); - return eErrCode; - } - - // ReleaseLock. - return releaseLock (0, SuperPage::theSize); + cleanup_Impl(); } /* - * create (SuperBlock). - * Internal: Precond: initialized, exclusive access. + * initialize. + * Precond: none. */ -storeError OStorePageBIOS::create (sal_uInt16 nPageSize) +storeError OStorePageBIOS::initialize ( + ILockBytes * pLockBytes, + storeAccessMode eAccessMode, + sal_uInt16 & rnPageSize) { - // Check (internal) precond. - OSL_PRECOND(m_xLockBytes.is(), "store::PageBIOS::create(): contract violation"); - - // Check PageSize. - if ((STORE_MINIMUM_PAGESIZE > nPageSize) || (nPageSize > STORE_MAXIMUM_PAGESIZE)) - return store_E_InvalidParameter; - nPageSize = ((nPageSize + STORE_MINIMUM_PAGESIZE - 1) & ~(STORE_MINIMUM_PAGESIZE - 1)); - - // Acquire Lock. - storeError eErrCode = acquireLock (0, nPageSize); - if (eErrCode != store_E_None) - return eErrCode; - - // Allocate SuperBlock page. - delete m_pSuper, m_pSuper = 0; - if ((m_pSuper = new(nPageSize) SuperPage(nPageSize)) == 0) - { - // Cleanup and fail. - releaseLock (0, nPageSize); - return store_E_OutOfMemory; - } - m_pSuper->guard(); + // Acquire exclusive access. + osl::MutexGuard aGuard (m_aMutex); - // Create initial page (w/ SuperBlock). - eErrCode = m_xLockBytes->writeAt (0, m_pSuper, nPageSize); + // Initialize. + storeError eErrCode = initialize_Impl (pLockBytes, eAccessMode, rnPageSize); if (eErrCode != store_E_None) { - // Cleanup and fail. - releaseLock (0, nPageSize); - return eErrCode; + // Cleanup. + cleanup_Impl(); } - -#ifdef STORE_FEATURE_COMMIT - // Commit. - eErrCode = m_xLockBytes->flush(); - OSL_POSTCOND( - eErrCode == store_E_None, - "OStorePageBIOS::create(): flush failed"); -#endif /* STORE_FEATURE_COMMIT */ - - // Adjust modified state. - m_bModified = (eErrCode != store_E_None); - - // Release Lock and finish. - return releaseLock (0, nPageSize); + return eErrCode; } /* - * initialize. - * Precond: none. + * initialize_Impl. + * Internal: Precond: exclusive access. */ -storeError OStorePageBIOS::initialize ( +storeError OStorePageBIOS::initialize_Impl ( ILockBytes * pLockBytes, storeAccessMode eAccessMode, sal_uInt16 & rnPageSize) { - // Acquire exclusive access. - osl::MutexGuard aGuard (m_aMutex); - - // Check arguments. - storeError eErrCode = store_E_InvalidParameter; - if (!pLockBytes) - return eErrCode; - // Cleanup. -#if 0 /* OLD */ - __STORE_DELETEZ (m_pAcl); /* @@@ */ -#endif /* OLD */ - delete m_pSuper, m_pSuper = 0; + cleanup_Impl(); // Initialize. m_xLockBytes = pLockBytes; - m_bModified = sal_False; - m_bWriteable = (!(eAccessMode == store_AccessReadOnly)); + if (!m_xLockBytes.is()) + return store_E_InvalidParameter; + m_bWriteable = (eAccessMode != store_AccessReadOnly); // Check access mode. - if (eAccessMode == store_AccessReadOnly) - { - // Verify SuperBlock page. - eErrCode = verify (m_pSuper); - } - else if (eAccessMode != store_AccessCreate) + storeError eErrCode = store_E_None; + if (eAccessMode != store_AccessCreate) { - // Verify (w/ repair) SuperBlock page. - eErrCode = repair (m_pSuper); + // Load SuperBlock page. + if ((m_pSuper = new SuperBlockPage()) == 0) + return store_E_OutOfMemory; + + eErrCode = read (0, m_pSuper, SuperBlockPage::theSize); + if (eErrCode == store_E_None) + { + // Verify SuperBlock page (with repair). + eErrCode = m_pSuper->verify (*this); + } } else { @@ -806,13 +631,6 @@ storeError OStorePageBIOS::initialize ( if (eErrCode != store_E_None) return eErrCode; -#ifdef STORE_FEATURE_COMMIT - // Commit. - eErrCode = m_xLockBytes->flush(); - if (eErrCode != store_E_None) - return eErrCode; -#endif /* STORE_FEATURE_COMMIT */ - // Mark as not existing. eErrCode = store_E_NotExists; } @@ -829,14 +647,18 @@ storeError OStorePageBIOS::initialize ( if (eAccessMode == store_AccessReadWrite) return store_E_NotExists; - // Create SuperBlock page. - eErrCode = create (rnPageSize); + // Check PageSize. + if ((STORE_MINIMUM_PAGESIZE > rnPageSize) || (rnPageSize > STORE_MAXIMUM_PAGESIZE)) + return store_E_InvalidParameter; + rnPageSize = ((rnPageSize + STORE_MINIMUM_PAGESIZE - 1) & ~(STORE_MINIMUM_PAGESIZE - 1)); + + // Create initial page (w/ SuperBlock). + if ((m_pSuper = new(rnPageSize) SuperBlockPage(rnPageSize)) == 0) + return store_E_OutOfMemory; + eErrCode = m_pSuper->save (*this, rnPageSize); } if (eErrCode == store_E_None) { - // Obtain modified state. - m_bModified = m_pSuper->m_aState.flushPending(); - // Obtain page size. rnPageSize = store::ntohs(m_pSuper->m_aSuperOne.m_aDescr.m_nSize); @@ -852,33 +674,35 @@ storeError OStorePageBIOS::initialize ( } /* - * acquireLock. - * Low Level: Precond: initialized, exclusive access. + * cleanup_Impl. + * Internal: Precond: exclusive access. */ -storeError OStorePageBIOS::acquireLock ( - sal_uInt32 nAddr, sal_uInt32 nSize) +void OStorePageBIOS::cleanup_Impl() { - // Check precond. - if (!m_xLockBytes.is()) - return store_E_InvalidAccess; + // Check referer count. + if (m_ace_head.m_used > 0) + { + // Report remaining referer count. + OSL_TRACE("store::PageBIOS::cleanup_Impl(): referer count: %d\n", m_ace_head.m_used); + for (Ace * ace = m_ace_head.m_next; ace != &m_ace_head; ace = m_ace_head.m_next) + { + m_ace_head.m_used -= ace->m_used; + AceCache::get().destroy (ace); + } + OSL_ENSURE(m_ace_head.m_used == 0, "store::PageBIOS::cleanup_Impl(): logic error"); + } - // Acquire Lock. - return m_xLockBytes->lockRange (nAddr, nSize); -} + // Release SuperBlock page. + delete m_pSuper, m_pSuper = 0; -/* - * releaseLock. - * Low Level: Precond: initialized, exclusive access. - */ -storeError OStorePageBIOS::releaseLock ( - sal_uInt32 nAddr, sal_uInt32 nSize) -{ - // Check precond. - if (!m_xLockBytes.is()) - return store_E_InvalidAccess; + // Release PageCache. + m_xCache.clear(); + + // Release PageAllocator. + m_xAllocator.clear(); - // Release Lock. - return m_xLockBytes->unlockRange (nAddr, nSize); + // Release LockBytes. + m_xLockBytes.clear(); } /* @@ -892,7 +716,7 @@ storeError OStorePageBIOS::read ( if (!m_xLockBytes.is()) return store_E_InvalidAccess; - // Read Page. + // Read Data. return m_xLockBytes->readAt (nAddr, pData, nSize); } @@ -909,18 +733,6 @@ storeError OStorePageBIOS::write ( if (!m_bWriteable) return store_E_AccessViolation; - // Check modified state. - if (!m_bModified) - { - // Mark as modified. - m_bModified = sal_True; - - // Mark SuperBlock modified. - storeError eErrCode = m_pSuper->modified (*this); - if (eErrCode != store_E_None) - return eErrCode; - } - // Write Data. return m_xLockBytes->writeAt (nAddr, pData, nSize); } @@ -1026,160 +838,44 @@ storeError OStorePageBIOS::allocate ( if (!m_bWriteable) return store_E_AccessViolation; - // Acquire SuperBlock Lock. - storeError eErrCode = acquireLock (0, SuperPage::theSize); - if (eErrCode != store_E_None) - return eErrCode; - - // Load SuperBlock and require good health. - eErrCode = verify (m_pSuper); - if (eErrCode != store_E_None) - { - releaseLock (0, SuperPage::theSize); - return eErrCode; - } - - // Check allocation. + // Check allocation type. + storeError eErrCode = store_E_None; if (eAlloc != ALLOCATE_EOF) { - // Check FreeList. - OStorePageLink aListHead (m_pSuper->m_aSuperTwo.unusedHead()); - if (aListHead.location()) - { - // Allocate from FreeList. - OStorePageData aPageHead (OStorePageData::theSize); - aPageHead.location (aListHead.location()); - - // Load PageHead. - eErrCode = peek (aPageHead); - if (eErrCode != store_E_None) - { - releaseLock (0, SuperPage::theSize); - return eErrCode; - } - - // Verify FreeList head. - OSL_PRECOND( - aPageHead.m_aUnused.m_nAddr != STORE_PAGE_NULL, - "OStorePageBIOS::allocate(): page not free"); - if (aPageHead.m_aUnused.location() == STORE_PAGE_NULL) - { - // Recovery: Reset FreeList. - m_pSuper->m_aSuperTwo.unusedReset(); - m_pSuper->m_aSuperOne = m_pSuper->m_aSuperTwo; - - // Save SuperBlock page. - eErrCode = m_pSuper->save (*this); - - // Release SuperBlock Lock. - releaseLock (0, SuperPage::theSize); - - // Recovery: Allocate from EOF. - if (eErrCode == store_E_None) - return allocate (rPage, ALLOCATE_EOF); - else - return store_E_Unknown; - } - - // Pop from FreeList. - aListHead = aPageHead.m_aUnused.location(); - rPage.get()->m_aUnused = STORE_PAGE_NULL; - - // Save page at PageHead location. - eErrCode = saveObjectAt_Impl (rPage, aPageHead.location()); - if (eErrCode != store_E_None) - { - releaseLock (0, SuperPage::theSize); - return eErrCode; - } - - // Save SuperBlock page. - m_pSuper->m_aSuperTwo.unusedRemove (aListHead); - m_pSuper->m_aSuperOne = m_pSuper->m_aSuperTwo; - - eErrCode = m_pSuper->save (*this); - OSL_POSTCOND( - eErrCode == store_E_None, - "OStorePageBIOS::allocate(): SuperBlock save failed"); - - // Release SuperBlock Lock and finish. - return releaseLock (0, SuperPage::theSize); - } - } - - // Allocate from logical EOF. Determine physical EOF. - sal_uInt32 nPhysLen = STORE_PAGE_NULL; - eErrCode = m_xLockBytes->getSize (nPhysLen); - if (eErrCode != store_E_None) - { - releaseLock (0, SuperPage::theSize); - return eErrCode; - } - - // Obtain logical EOF. - OStorePageDescriptor aDescr (m_pSuper->m_aSuperTwo.m_aDescr); - sal_uInt32 nLogLen = store::ntohl(aDescr.m_nAddr); - if (nLogLen == 0) - nLogLen = nPhysLen; /* backward compatibility */ + // Try freelist head. + PageData aPageHead; + eErrCode = m_pSuper->unusedHead (*this, aPageHead); + if (eErrCode != store_E_None) + return eErrCode; - if (!(nLogLen < nPhysLen)) - { - // Check modified state. - if (!m_bModified) + sal_uInt32 const nAddr = aPageHead.location(); + if (nAddr != STORE_PAGE_NULL) { - // Mark modified. - m_bModified = sal_True; - - // Mark SuperBlock modified. - eErrCode = m_pSuper->modified (*this); + // Save page. + eErrCode = saveObjectAt_Impl (rPage, nAddr); if (eErrCode != store_E_None) - { - releaseLock (0, SuperPage::theSize); return eErrCode; - } - } - // Resize. - sal_uInt32 nAlign = SAL_MIN (nPhysLen, STORE_MAXIMUM_PAGESIZE); - nPhysLen = ((nPhysLen + nAlign) / nAlign) * nAlign; - - eErrCode = m_xLockBytes->setSize (nPhysLen); - if (eErrCode != store_E_None) - { - releaseLock (0, SuperPage::theSize); - return eErrCode; + // Pop freelist head and finish. + return m_pSuper->unusedPop (*this, aPageHead); } } - // Save page at logical EOF. - eErrCode = saveObjectAt_Impl (rPage, nLogLen); + // Allocate from EOF. Determine current size. + sal_uInt32 nSize = STORE_PAGE_NULL; + eErrCode = m_xLockBytes->getSize (nSize); if (eErrCode != store_E_None) - { - releaseLock (0, SuperPage::theSize); return eErrCode; - } - - // Save SuperBlock page. - nLogLen += store::ntohs(aDescr.m_nSize); - aDescr.m_nAddr = store::htonl(nLogLen); - m_pSuper->m_aSuperTwo.m_aDescr = aDescr; - m_pSuper->m_aSuperOne = m_pSuper->m_aSuperTwo; - - eErrCode = m_pSuper->save (*this); - OSL_POSTCOND( - eErrCode == store_E_None, - "OStorePageBIOS::allocate(): SuperBlock save failed"); - - // Release SuperBlock Lock and finish. - return releaseLock (0, SuperPage::theSize); + // Save page at current EOF. + return saveObjectAt_Impl (rPage, nSize); } /* * free. * Precond: initialized, writeable. */ -storeError OStorePageBIOS::free (OStorePageData & /* rData */, sal_uInt32 nAddr) +storeError OStorePageBIOS::free (sal_uInt32 nAddr) { // Acquire exclusive access. osl::MutexGuard aGuard (m_aMutex); @@ -1190,58 +886,11 @@ storeError OStorePageBIOS::free (OStorePageData & /* rData */, sal_uInt32 nAddr) if (!m_bWriteable) return store_E_AccessViolation; - // Acquire SuperBlock Lock. - storeError eErrCode = acquireLock (0, SuperPage::theSize); - if (eErrCode != store_E_None) - return eErrCode; - - // Load SuperBlock and require good health. - eErrCode = verify (m_pSuper); - if (eErrCode != store_E_None) - { - releaseLock (0, SuperPage::theSize); - return eErrCode; - } - - // Load PageHead. - OStorePageData aPageHead(OStorePageData::theSize); - aPageHead.location (nAddr); - - eErrCode = peek (aPageHead); - if (eErrCode != store_E_None) - { - releaseLock (0, SuperPage::theSize); - return eErrCode; - } - // Invalidate cache. (void) m_xCache->removePageAt (nAddr); - // Push onto FreeList. - OStorePageLink aListHead (m_pSuper->m_aSuperTwo.unusedHead()); - - aPageHead.m_aUnused.m_nAddr = aListHead.m_nAddr; - aListHead.m_nAddr = aPageHead.m_aDescr.m_nAddr; - - // Save PageHead. - eErrCode = poke (aPageHead); - if (eErrCode != store_E_None) - { - releaseLock (0, SuperPage::theSize); - return eErrCode; - } - - // Save SuperBlock page. - m_pSuper->m_aSuperTwo.unusedInsert (aListHead); - m_pSuper->m_aSuperOne = m_pSuper->m_aSuperTwo; - - eErrCode = m_pSuper->save (*this); - OSL_POSTCOND( - eErrCode == store_E_None, - "OStorePageBIOS::free(): SuperBlock save failed"); - - // Release SuperBlock Lock and finish. - return releaseLock (0, SuperPage::theSize); + // Push onto freelist. + return m_pSuper->unusedPush (*this, nAddr); } /* @@ -1333,57 +982,16 @@ storeError OStorePageBIOS::saveObjectAt_Impl (OStorePageObject & rPage, sal_uInt * close. * Precond: none. */ -storeError OStorePageBIOS::close (void) +storeError OStorePageBIOS::close() { // Acquire exclusive access. osl::MutexGuard aGuard (m_aMutex); - // Check referer count. - if (m_ace_head.m_used > 0) - { - // Report remaining referer count. - OSL_TRACE("store::PageBIOS::close(): referer count: %d\n", m_ace_head.m_used); -#if 1 /* NEW */ - for (Ace * ace = m_ace_head.m_next; ace != &m_ace_head; ace = m_ace_head.m_next) - { - m_ace_head.m_used -= ace->m_used; - AceCache::get().destroy (ace); - } - OSL_ENSURE(m_ace_head.m_used == 0, "store::PageBIOS::close(): logic error"); -#endif /* NEW */ - } - - // Check SuperBlock page. - storeError eErrCode = store_E_None; - if (m_pSuper) - { - // Release SuperBlock page. - eErrCode = m_pSuper->close (*this); - delete m_pSuper, m_pSuper = 0; - } - - // Release PageCache. - m_xCache.clear(); - - // Check LockBytes. - if (m_xLockBytes.is()) - { -#ifdef STORE_FEATURE_COMMIT - // Commit. - storeError result = m_xLockBytes->flush(); - if (eErrCode == store_E_None) - { - // Previous result(s) okay. Propagate next result. - eErrCode = result; - } -#endif /* STORE_FEATURE_COMMIT */ - - // Release LockBytes. - m_xLockBytes.clear(); - } + // Cleanup. + cleanup_Impl(); // Done. - return eErrCode; + return store_E_None; } /* @@ -1399,27 +1007,8 @@ storeError OStorePageBIOS::flush (void) if (!m_xLockBytes.is()) return store_E_InvalidAccess; - // Check mode and state. - storeError eErrCode = store_E_None; - if (!(m_bWriteable && m_bModified)) - return eErrCode; - - // Flush SuperBlock page. - eErrCode = m_pSuper->flush (*this); - - // Flush LockBytes. - storeError result = m_xLockBytes->flush(); - if (eErrCode == store_E_None) - { - // Previous result(s) okay. Propagate next result. - eErrCode = result; - } - - // Adjust modified state. - m_bModified = (eErrCode != store_E_None); - - // Done. - return eErrCode; + // Flush LockBytes and finish. + return m_xLockBytes->flush(); } /* @@ -1462,7 +1051,7 @@ storeError OStorePageBIOS::scanBegin ( return store_E_InvalidAccess; // Check SuperBlock page. - storeError eErrCode = verify (m_pSuper); + storeError eErrCode = m_pSuper->verify (*this); if (eErrCode != store_E_None) { // Damaged. Determine page size (NYI). @@ -1472,7 +1061,8 @@ storeError OStorePageBIOS::scanBegin ( // Setup Context descriptor. rCtx.m_aDescr = m_pSuper->m_aSuperOne.m_aDescr; - rCtx.m_aDescr.m_nAddr = rCtx.m_aDescr.m_nSize; // @@@ ntoh @@@ + rCtx.m_aDescr.m_nSize = store::ntohs(rCtx.m_aDescr.m_nSize); + rCtx.m_aDescr.m_nAddr = rCtx.m_aDescr.m_nSize; // Setup Context size. eErrCode = size (rCtx.m_nSize); @@ -1498,20 +1088,24 @@ storeError OStorePageBIOS::scanNext ( return store_E_InvalidAccess; // Setup PageHead. - OStorePageData aPageHead (OStorePageData::theSize); + PageData aPageHead; // Check context. while (rCtx.isValid()) { // Assign next location. - aPageHead.location (rCtx.m_aDescr.m_nAddr); + sal_uInt32 nAddr = rCtx.m_aDescr.m_nAddr; rCtx.m_aDescr.m_nAddr += rCtx.m_aDescr.m_nSize; - // Load PageHead. - storeError eErrCode = peek (aPageHead); + // Read PageHead. + storeError eErrCode = read (nAddr, &aPageHead, PageData::theSize); if (eErrCode != store_E_None) continue; + // Verify PageHead. + eErrCode = aPageHead.verify (nAddr); + continue; + // Check PageHead Magic number. if (aPageHead.m_aGuard.m_nMagic != rCtx.m_nMagic) continue; @@ -1521,7 +1115,7 @@ storeError OStorePageBIOS::scanNext ( continue; // Load page. - eErrCode = loadObjectAt_Impl (rPage, aPageHead.location()); + eErrCode = loadObjectAt_Impl (rPage, nAddr); if (eErrCode != store_E_None) continue; @@ -1532,31 +1126,3 @@ storeError OStorePageBIOS::scanNext ( // Done. return store_E_CantSeek; } - -/* - * peek (PageHead). - * Internal: Precond: initialized, readable, exclusive access. - */ -storeError OStorePageBIOS::peek (OStorePageData &rData) -{ - // Read PageHead. - storeError eErrCode = read (rData.location(), &rData, OStorePageData::theSize); - if (eErrCode != store_E_None) - return eErrCode; - - // Verify PageHead. - return rData.verify(); -} - -/* - * poke (PageHead). - * Internal: Precond: initialized, writeable, exclusive access. - */ -storeError OStorePageBIOS::poke (OStorePageData &rData) -{ - // Guard PageHead. - rData.guard(); - - // Write PageHead. - return write (rData.location(), &rData, OStorePageData::theSize); -} diff --git a/store/source/storbios.hxx b/store/source/storbios.hxx index ad84b40b05e7..439089d41bd6 100644 --- a/store/source/storbios.hxx +++ b/store/source/storbios.hxx @@ -26,7 +26,7 @@ ************************************************************************/ #ifndef _STORE_STORBIOS_HXX_ -#define _STORE_STORBIOS_HXX_ "$Revision: 1.1.2.3 $" +#define _STORE_STORBIOS_HXX_ #include "sal/types.h" #include "rtl/ref.hxx" @@ -46,7 +46,7 @@ namespace store { -struct OStoreSuperBlockPage; +struct SuperBlockPage; class OStorePageBIOS : public store::OStoreObject { @@ -75,16 +75,6 @@ public: return m_xAllocator; } - /** acquireLock. - */ - storeError acquireLock ( - sal_uInt32 nAddr, sal_uInt32 nSize); - - /** releaseLock. - */ - storeError releaseLock ( - sal_uInt32 nAddr, sal_uInt32 nSize); - /** read. */ storeError read ( @@ -95,10 +85,6 @@ public: storeError write ( sal_uInt32 nAddr, const void *pData, sal_uInt32 nSize); - /** isModified. - */ - inline bool isModified (void) const; - /** isWriteable. */ inline bool isWriteable (void) const; @@ -129,8 +115,7 @@ public: storeError allocate ( OStorePageObject& rPage, Allocation eAllocation = ALLOCATE_FIRST); - storeError free ( - OStorePageData & /* rData */, sal_uInt32 nAddr); + storeError free (sal_uInt32 nAddr); /** Page I/O. */ @@ -196,10 +181,8 @@ private: rtl::Reference<ILockBytes> m_xLockBytes; osl::Mutex m_aMutex; - typedef OStoreSuperBlockPage SuperPage; - SuperPage *m_pSuper; + SuperBlockPage * m_pSuper; - bool m_bModified; bool m_bWriteable; rtl::Reference< PageData::Allocator > m_xAllocator; @@ -230,22 +213,16 @@ private: class AceCache; - /** create (SuperBlock). - */ - storeError create (sal_uInt16 nPageSize); - - /** SuperBlock verification and repair. + /** Initialization. */ - storeError verify (SuperPage *&rpSuper); - storeError repair (SuperPage *&rpSuper); + storeError initialize_Impl ( + ILockBytes * pLockBytes, + storeAccessMode eAccessMode, + sal_uInt16 & rnPageSize); + void cleanup_Impl(); /** Page Maintenance. */ - storeError peek ( - OStorePageData &rData); - storeError poke ( - OStorePageData &rData); - storeError loadObjectAt_Impl ( OStorePageObject & rPage, sal_uInt32 nAddr); storeError saveObjectAt_Impl ( @@ -261,10 +238,6 @@ inline OStorePageBIOS::operator osl::Mutex& (void) const { return (osl::Mutex&)m_aMutex; } -inline bool OStorePageBIOS::isModified (void) const -{ - return m_bModified; -} inline bool OStorePageBIOS::isWriteable (void) const { return m_bWriteable; diff --git a/store/source/stordata.cxx b/store/source/stordata.cxx index 97bcc87fcb6c..901da15c8040 100644 --- a/store/source/stordata.cxx +++ b/store/source/stordata.cxx @@ -95,8 +95,7 @@ static storeError store_truncate_Impl ( if (nSingle == 0) { // Free single indirect page. - OStorePageData aPageHead; - eErrCode = rBIOS.free (aPageHead, nAddr); + eErrCode = rBIOS.free (nAddr); if (eErrCode != store_E_None) return eErrCode; } @@ -135,8 +134,7 @@ static storeError store_truncate_Impl ( if ((nDouble + nSingle) == 0) { // Free double indirect page. - OStorePageData aPageHead; - eErrCode = rBIOS.free (aPageHead, nAddr); + eErrCode = rBIOS.free (nAddr); if (eErrCode != store_E_None) return eErrCode; } @@ -171,8 +169,7 @@ static storeError store_truncate_Impl ( if ((nTriple + nDouble + nSingle) == 0) { // Free triple indirect page. - OStorePageData aPageHead; - eErrCode = rBIOS.free (aPageHead, nAddr); + eErrCode = rBIOS.free (nAddr); if (eErrCode != store_E_None) return eErrCode; } @@ -433,17 +430,8 @@ storeError OStoreIndirectionPageObject::truncate ( if (!(nSingle < nLimit)) return store_E_InvalidAccess; - // Save PageDescriptor. - OStorePageDescriptor aDescr (rPage.m_aDescr); - aDescr.m_nAddr = store::ntohl(aDescr.m_nAddr); - aDescr.m_nSize = store::ntohs(aDescr.m_nSize); - - // Acquire Lock. - storeError eErrCode = rBIOS.acquireLock (aDescr.m_nAddr, aDescr.m_nSize); - if (eErrCode != store_E_None) - return eErrCode; - // Truncate. + storeError eErrCode = store_E_None; for (sal_uInt16 i = nLimit; i > nSingle; i--) { // Obtain data page location. @@ -451,13 +439,9 @@ storeError OStoreIndirectionPageObject::truncate ( if (nAddr != STORE_PAGE_NULL) { // Free data page. - OStorePageData aPageHead; - eErrCode = rBIOS.free (aPageHead, nAddr); + eErrCode = rBIOS.free (nAddr); if (eErrCode != store_E_None) - { - rBIOS.releaseLock (aDescr.m_nAddr, aDescr.m_nSize); return eErrCode; - } // Clear pointer to data page. rPage.m_pData[i - 1] = STORE_PAGE_NULL; @@ -470,19 +454,10 @@ storeError OStoreIndirectionPageObject::truncate ( { // Save this page. eErrCode = rBIOS.saveObjectAt (*this, location()); - if (eErrCode != store_E_None) - { - // Must not happen. - OSL_TRACE("OStoreIndirectionPageObject::truncate(): save failed"); - - // Release Lock and Leave. - rBIOS.releaseLock (aDescr.m_nAddr, aDescr.m_nSize); - return eErrCode; - } } - // Release Lock and Leave. - return rBIOS.releaseLock (aDescr.m_nAddr, aDescr.m_nSize); + // Done. + return eErrCode; } /* @@ -501,26 +476,14 @@ storeError OStoreIndirectionPageObject::truncate ( if (!((nDouble < nLimit) && (nSingle < nLimit))) return store_E_InvalidAccess; - // Save PageDescriptor. - OStorePageDescriptor aDescr (rPage.m_aDescr); - aDescr.m_nAddr = store::ntohl(aDescr.m_nAddr); - aDescr.m_nSize = store::ntohs(aDescr.m_nSize); - - // Acquire Lock. - storeError eErrCode = rBIOS.acquireLock (aDescr.m_nAddr, aDescr.m_nSize); - if (eErrCode != store_E_None) - return eErrCode; - // Truncate. + storeError eErrCode = store_E_None; for (sal_uInt16 i = nLimit; i > nDouble + 1; i--) { // Truncate single indirect page to zero direct pages. eErrCode = store_truncate_Impl (store::ntohl(rPage.m_pData[i - 1]), 0, rBIOS); if (eErrCode != store_E_None) - { - rBIOS.releaseLock (aDescr.m_nAddr, aDescr.m_nSize); return eErrCode; - } // Clear pointer to single indirect page. rPage.m_pData[i - 1] = STORE_PAGE_NULL; @@ -530,10 +493,7 @@ storeError OStoreIndirectionPageObject::truncate ( // Truncate last single indirect page to 'nSingle' direct pages. eErrCode = store_truncate_Impl (store::ntohl(rPage.m_pData[nDouble]), nSingle, rBIOS); if (eErrCode != store_E_None) - { - rBIOS.releaseLock (aDescr.m_nAddr, aDescr.m_nSize); return eErrCode; - } // Check for complete truncation. if (nSingle == 0) @@ -548,19 +508,10 @@ storeError OStoreIndirectionPageObject::truncate ( { // Save this page. eErrCode = rBIOS.saveObjectAt (*this, location()); - if (eErrCode != store_E_None) - { - // Must not happen. - OSL_TRACE("OStoreIndirectionPageObject::truncate(): save failed"); - - // Release Lock and Leave. - rBIOS.releaseLock (aDescr.m_nAddr, aDescr.m_nSize); - return eErrCode; - } } - // Release Lock and Leave. - return rBIOS.releaseLock (aDescr.m_nAddr, aDescr.m_nSize); + // Done. + return eErrCode; } /* @@ -580,26 +531,14 @@ storeError OStoreIndirectionPageObject::truncate ( if (!((nTriple < nLimit) && (nDouble < nLimit) && (nSingle < nLimit))) return store_E_InvalidAccess; - // Save PageDescriptor. - OStorePageDescriptor aDescr (rPage.m_aDescr); - aDescr.m_nAddr = store::ntohl(aDescr.m_nAddr); - aDescr.m_nSize = store::ntohs(aDescr.m_nSize); - - // Acquire Lock. - storeError eErrCode = rBIOS.acquireLock (aDescr.m_nAddr, aDescr.m_nSize); - if (eErrCode != store_E_None) - return eErrCode; - // Truncate. + storeError eErrCode = store_E_None; for (sal_uInt16 i = nLimit; i > nTriple + 1; i--) { // Truncate double indirect page to zero single indirect pages. eErrCode = store_truncate_Impl (store::ntohl(rPage.m_pData[i - 1]), 0, 0, rBIOS); if (eErrCode != store_E_None) - { - rBIOS.releaseLock (aDescr.m_nAddr, aDescr.m_nSize); return eErrCode; - } // Clear pointer to double indirect page. rPage.m_pData[i - 1] = STORE_PAGE_NULL; @@ -609,10 +548,7 @@ storeError OStoreIndirectionPageObject::truncate ( // Truncate last double indirect page to 'nDouble', 'nSingle' pages. eErrCode = store_truncate_Impl (store::ntohl(rPage.m_pData[nTriple]), nDouble, nSingle, rBIOS); if (eErrCode != store_E_None) - { - rBIOS.releaseLock (aDescr.m_nAddr, aDescr.m_nSize); return eErrCode; - } // Check for complete truncation. if ((nDouble + nSingle) == 0) @@ -627,19 +563,10 @@ storeError OStoreIndirectionPageObject::truncate ( { // Save this page. eErrCode = rBIOS.saveObjectAt (*this, location()); - if (eErrCode != store_E_None) - { - // Must not happen. - OSL_TRACE("OStoreIndirectionPageObject::truncate(): save failed"); - - // Release Lock and Leave. - rBIOS.releaseLock (aDescr.m_nAddr, aDescr.m_nSize); - return eErrCode; - } } - // Release Lock and Leave. - return rBIOS.releaseLock (aDescr.m_nAddr, aDescr.m_nSize); + // Done. + return eErrCode; } /*======================================================================== @@ -1129,8 +1056,7 @@ storeError OStoreDirectoryPageObject::truncate ( if (nAddr == STORE_PAGE_NULL) continue; // Free data page. - OStoreDataPageData aData; - eErrCode = rBIOS.free (aData, nAddr); + eErrCode = rBIOS.free (nAddr); if (eErrCode != store_E_None) break; diff --git a/store/source/stordata.hxx b/store/source/stordata.hxx index 6b062f7127f8..01ea2c0f86ec 100644 --- a/store/source/stordata.hxx +++ b/store/source/stordata.hxx @@ -26,7 +26,7 @@ ************************************************************************/ #ifndef _STORE_STORDATA_HXX_ -#define _STORE_STORDATA_HXX_ "$Revision: 1.6.8.2 $" +#define _STORE_STORDATA_HXX_ #include "sal/types.h" #include "sal/macros.h" diff --git a/store/source/stordir.hxx b/store/source/stordir.hxx index 66dd14bd81a6..2e3d79e71319 100644 --- a/store/source/stordir.hxx +++ b/store/source/stordir.hxx @@ -26,7 +26,7 @@ ************************************************************************/ #ifndef _STORE_STORDIR_HXX_ -#define _STORE_STORDIR_HXX_ "$Revision: 1.1.2.2 $" +#define _STORE_STORDIR_HXX_ #ifndef _SAL_TYPES_H_ #include <sal/types.h> diff --git a/store/source/storpage.cxx b/store/source/storpage.cxx index 770e46ee84b6..a49e850061b6 100644 --- a/store/source/storpage.cxx +++ b/store/source/storpage.cxx @@ -117,11 +117,6 @@ storeError OStorePageManager::initialize ( // Save RootNode. eErrCode = base::saveObjectAt (m_aRoot, rnPageSize); - if (eErrCode != store_E_None) - return eErrCode; - - // Flush for robustness. - (void) base::flush(); } // Done. @@ -857,8 +852,7 @@ storeError OStorePageManager::remove (const OStorePageKey &rKey) eErrCode = base::releasePage (aDescr, store_AccessReadWrite); // Release and free directory page. - OStorePageData aPageHead; - eErrCode = base::free (aPageHead, aPage.location()); + eErrCode = base::free (aPage.location()); } // Remove entry. diff --git a/store/source/stortree.cxx b/store/source/stortree.cxx index 9636cc2f4f8c..23d7ca778961 100644 --- a/store/source/stortree.cxx +++ b/store/source/stortree.cxx @@ -202,25 +202,10 @@ storeError OStoreBTreeNodeObject::split ( if (!rxPageL->querySplit()) return store_E_None; - // Save PageDescriptor. - OStorePageDescriptor aDescr (xPage->m_aDescr); - aDescr.m_nAddr = store::ntohl(aDescr.m_nAddr); - aDescr.m_nSize = store::ntohs(aDescr.m_nSize); - - // Acquire Lock. - storeError eErrCode = rBIOS.acquireLock (aDescr.m_nAddr, aDescr.m_nSize); - if (eErrCode != store_E_None) - return eErrCode; - - // [Begin PageL Lock (NYI)] - // Construct right page. PageHolderObject< page > xPageR; if (!xPageR.construct (rBIOS.allocator())) - { - rBIOS.releaseLock (aDescr.m_nAddr, aDescr.m_nSize); return store_E_OutOfMemory; - } // Split right page off left page. xPageR->split (*rxPageL); @@ -228,12 +213,9 @@ storeError OStoreBTreeNodeObject::split ( // Allocate right page. self aNodeR (xPageR.get()); - eErrCode = rBIOS.allocate (aNodeR); + storeError eErrCode = rBIOS.allocate (aNodeR); if (eErrCode != store_E_None) - { - rBIOS.releaseLock (aDescr.m_nAddr, aDescr.m_nSize); return eErrCode; - } // Truncate left page. rxPageL->truncate (rxPageL->capacityCount() / 2); @@ -242,35 +224,14 @@ storeError OStoreBTreeNodeObject::split ( self aNodeL (rxPageL.get()); eErrCode = rBIOS.saveObjectAt (aNodeL, aNodeL.location()); if (eErrCode != store_E_None) - { - // Must not happen. - OSL_TRACE("OStoreBTreeNodeObject::split(): save() failed"); - - // Release Lock and Leave. - rBIOS.releaseLock (aDescr.m_nAddr, aDescr.m_nSize); return eErrCode; - } - - // [End PageL Lock (NYI)] // Insert right page. OStorePageLink aLink (xPageR->location()); xPage->insert (nIndexL + 1, T(xPageR->m_pData[0].m_aKey, aLink)); - // Save this page. - eErrCode = rBIOS.saveObjectAt (*this, location()); - if (eErrCode != store_E_None) - { - // Must not happen. - OSL_TRACE("OStoreBTreeNodeObject::split(): save() failed"); - - // Release Lock and Leave. - rBIOS.releaseLock (aDescr.m_nAddr, aDescr.m_nSize); - return eErrCode; - } - - // Release Lock and Leave. - return rBIOS.releaseLock (aDescr.m_nAddr, aDescr.m_nSize); + // Save this page and leave. + return rBIOS.saveObjectAt (*this, location()); } /* @@ -284,56 +245,34 @@ storeError OStoreBTreeNodeObject::remove ( PageHolderObject< page > xImpl (m_xPage); page & rPage = (*xImpl); - // Save PageDescriptor. - OStorePageDescriptor aDescr (rPage.m_aDescr); - aDescr.m_nAddr = store::ntohl(aDescr.m_nAddr); - aDescr.m_nSize = store::ntohs(aDescr.m_nSize); - - // Acquire Lock. - storeError eErrCode = rBIOS.acquireLock (aDescr.m_nAddr, aDescr.m_nSize); - if (eErrCode != store_E_None) - return eErrCode; - // Check depth. + storeError eErrCode = store_E_None; if (rPage.depth()) { // Check link entry. T const aEntryL (rPage.m_pData[nIndexL]); if (!(rEntryL.compare (aEntryL) == T::COMPARE_EQUAL)) - { - rBIOS.releaseLock (aDescr.m_nAddr, aDescr.m_nSize); return store_E_InvalidAccess; - } // Load link node. self aNodeL; eErrCode = rBIOS.loadObjectAt (aNodeL, aEntryL.m_aLink.location()); if (eErrCode != store_E_None) - { - rBIOS.releaseLock (aDescr.m_nAddr, aDescr.m_nSize); return eErrCode; - } // Recurse: remove from link node. eErrCode = aNodeL.remove (0, rEntryL, rBIOS); if (eErrCode != store_E_None) - { - rBIOS.releaseLock (aDescr.m_nAddr, aDescr.m_nSize); return eErrCode; - } // Check resulting link node usage. PageHolderObject< page > xPageL (aNodeL.get()); if (xPageL->usageCount() == 0) { // Free empty link node. - OStorePageData aPageHead; - eErrCode = rBIOS.free (aPageHead, xPageL->location()); + eErrCode = rBIOS.free (xPageL->location()); if (eErrCode != store_E_None) - { - rBIOS.releaseLock (aDescr.m_nAddr, aDescr.m_nSize); return eErrCode; - } // Remove index. rPage.remove (nIndexL); @@ -355,7 +294,7 @@ storeError OStoreBTreeNodeObject::remove ( { rPageL.merge (rPageR); - eErrCode = rBIOS.free (aPageHead, rPageR.location()); + eErrCode = rBIOS.free (rPageR.location()); } } } @@ -370,10 +309,7 @@ storeError OStoreBTreeNodeObject::remove ( { // Check leaf entry. if (!(rEntryL.compare (rPage.m_pData[nIndexL]) == T::COMPARE_EQUAL)) - { - rBIOS.releaseLock (aDescr.m_nAddr, aDescr.m_nSize); return store_E_NotExists; - } // Save leaf entry. rEntryL = rPage.m_pData[nIndexL]; @@ -388,19 +324,10 @@ storeError OStoreBTreeNodeObject::remove ( { // Save this page. eErrCode = rBIOS.saveObjectAt (*this, location()); - if (eErrCode != store_E_None) - { - // Must not happen. - OSL_TRACE("OStoreBTreeNodeObject::remove(): save() failed"); - - // Release Lock and Leave. - rBIOS.releaseLock (aDescr.m_nAddr, aDescr.m_nSize); - return eErrCode; - } } - // Release Lock and Leave. - return rBIOS.releaseLock (aDescr.m_nAddr, aDescr.m_nSize); + // Done. + return eErrCode; } /*======================================================================== @@ -454,33 +381,17 @@ storeError OStoreBTreeRootObject::change ( PageHolderObject< page > xPage (m_xPage); (void) testInvariant("OStoreBTreeRootObject::change(): enter"); - // Save PageDescriptor. - OStorePageDescriptor aDescr (xPage->m_aDescr); - aDescr.m_nAddr = store::ntohl(aDescr.m_nAddr); - aDescr.m_nSize = store::ntohs(aDescr.m_nSize); - // Save root location. sal_uInt32 const nRootAddr = xPage->location(); - // Acquire Lock. - storeError eErrCode = rBIOS.acquireLock (aDescr.m_nAddr, aDescr.m_nSize); - if (eErrCode != store_E_None) - return eErrCode; - // Construct new root. if (!rxPageL.construct (rBIOS.allocator())) - { - rBIOS.releaseLock (aDescr.m_nAddr, aDescr.m_nSize); return store_E_OutOfMemory; - } // Save this as prev root. - eErrCode = rBIOS.allocate (*this); + storeError eErrCode = rBIOS.allocate (*this); if (eErrCode != store_E_None) - { - rBIOS.releaseLock (aDescr.m_nAddr, aDescr.m_nSize); return store_E_OutOfMemory; - } // Setup new root. rxPageL->depth (xPage->depth() + 1); @@ -495,24 +406,10 @@ storeError OStoreBTreeRootObject::change ( tmp.swap (m_xPage); } - // Save this as new root. + // Save this as new root and finish. eErrCode = rBIOS.saveObjectAt (*this, nRootAddr); - if (eErrCode != store_E_None) - { - // Must not happen. - OSL_TRACE("OStoreBTreeRootObject::change(): save() failed"); - - // Release Lock and Leave. - rBIOS.releaseLock (aDescr.m_nAddr, aDescr.m_nSize); - return eErrCode; - } - - // Flush for robustness. - (void) rBIOS.flush(); - - // Done. Release Lock and Leave. (void) testInvariant("OStoreBTreeRootObject::change(): leave"); - return rBIOS.releaseLock (aDescr.m_nAddr, aDescr.m_nSize); + return eErrCode; } /* diff --git a/store/workben/makefile.mk b/store/workben/makefile.mk index 07b558d06bc6..8893f4c7d646 100644 --- a/store/workben/makefile.mk +++ b/store/workben/makefile.mk @@ -76,6 +76,7 @@ APP1OBJS= $(OBJ)$/t_file.obj APP1STDLIBS= $(STOREDBGLIB) APP1STDLIBS+= $(SALLIB) APP1DEPN= $(STOREDBGLIB) +APP1RPATH= UREBIN APP2TARGET= t_page APP2OBJS= $(OBJ)$/t_page.obj @@ -88,6 +89,7 @@ APP3OBJS= $(OBJ)$/t_base.obj APP3STDLIBS= $(STOREDBGLIB) APP3STDLIBS+= $(SALLIB) APP3DEPN= $(STOREDBGLIB) +APP3RPATH= UREBIN APP4TARGET= t_store APP4OBJS= $(OBJ)$/t_store.obj diff --git a/store/workben/t_base.cxx b/store/workben/t_base.cxx index 49176c3dcfad..7f99c287a210 100644 --- a/store/workben/t_base.cxx +++ b/store/workben/t_base.cxx @@ -362,19 +362,8 @@ int SAL_CALL main (int argc, char **argv) rtl_zeroMemory (pBuffer, sizeof (pBuffer)); rtl_copyMemory (pBuffer, argv[0], rtl_str_getLength(argv[0]) + 1); - eErrCode = xBIOS->acquireLock (TEST_PAGESIZE, sizeof(pBuffer)); - if (eErrCode != store_E_None) - return eErrCode; - eErrCode = xBIOS->write (TEST_PAGESIZE, pBuffer, sizeof (pBuffer)); if (eErrCode != store_E_None) - { - xBIOS->releaseLock (TEST_PAGESIZE, sizeof(pBuffer)); - return eErrCode; - } - - eErrCode = xBIOS->releaseLock (TEST_PAGESIZE, sizeof(pBuffer)); - if (eErrCode != store_E_None) return eErrCode; xBIOS.clear(); |