diff options
Diffstat (limited to 'store')
-rw-r--r-- | store/source/storbios.cxx | 109 | ||||
-rw-r--r-- | store/source/storbios.hxx | 14 | ||||
-rw-r--r-- | store/source/stordata.hxx | 4 | ||||
-rw-r--r-- | store/source/store.cxx | 335 | ||||
-rw-r--r-- | store/source/storlckb.cxx | 26 | ||||
-rw-r--r-- | store/source/storlckb.hxx | 11 | ||||
-rw-r--r-- | store/source/storpage.cxx | 472 | ||||
-rw-r--r-- | store/source/storpage.hxx | 43 |
8 files changed, 0 insertions, 1014 deletions
diff --git a/store/source/storbios.cxx b/store/source/storbios.cxx index f378894d7746..a1d863d18ce8 100644 --- a/store/source/storbios.cxx +++ b/store/source/storbios.cxx @@ -783,19 +783,6 @@ storeError OStorePageBIOS::releasePage (const OStorePageDescriptor& rDescr) } /* - * getRefererCount. - * Precond: none. - */ -sal_uInt32 OStorePageBIOS::getRefererCount() -{ - // Acquire exclusive access. - osl::MutexGuard aGuard (m_aMutex); - - // Obtain total referer count. - return m_ace_head.m_used; -} - -/* * allocate. * Precond: initialized, writeable. */ @@ -1004,101 +991,5 @@ storeError OStorePageBIOS::size (sal_uInt32 &rnSize) return m_xLockBytes->getSize (rnSize); } -/* - * scanBegin. - * Precond: initialized. - */ -storeError OStorePageBIOS::scanBegin ( - ScanContext &rCtx, sal_uInt32 nMagic) -{ - // Acquire exclusive access. - osl::MutexGuard aGuard (m_aMutex); - - // Initialize [out] param. - rCtx.m_aDescr = OStorePageDescriptor(0, 0, 0); - rCtx.m_nSize = 0; - rCtx.m_nMagic = nMagic; - - // Check precond. - if (!m_xLockBytes.is()) - return store_E_InvalidAccess; - - // Check SuperBlock page. - storeError eErrCode = m_pSuper->verify (*this); - if (eErrCode != store_E_None) - { - // Damaged. Determine page size (NYI). - OSL_TRACE ("OStorePageBIOS::scanBegin(): damaged.\n"); - return eErrCode; - } - - // Setup Context descriptor. - rCtx.m_aDescr = m_pSuper->m_aSuperOne.m_aDescr; - 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); - if (eErrCode != store_E_None) - rCtx.m_nSize = ((sal_uInt32)(~0)); - - // Done. - return store_E_None; -} - -/* - * scanNext. - * Precond: initialized. - */ -storeError OStorePageBIOS::scanNext ( - ScanContext &rCtx, OStorePageObject &rPage) -{ - // Acquire exclusive access. - osl::MutexGuard aGuard (m_aMutex); - - // Check precond. - if (!m_xLockBytes.is()) - return store_E_InvalidAccess; - - // Setup PageHead. - PageData aPageHead; - - // Check context. - while (rCtx.isValid()) - { - // Assign next location. - sal_uInt32 nAddr = rCtx.m_aDescr.m_nAddr; - rCtx.m_aDescr.m_nAddr += rCtx.m_aDescr.m_nSize; - - // Read PageHead. - storeError eErrCode = read (nAddr, &aPageHead, PageData::theSize); - if (eErrCode != store_E_None) - continue; - - // Verify PageHead. - eErrCode = aPageHead.verify (nAddr); - if (eErrCode != store_E_None) - continue; - - // Check PageHead Magic number. - if (aPageHead.m_aGuard.m_nMagic != rCtx.m_nMagic) - continue; - - // Check PageHead Unused link. - if (aPageHead.m_aUnused.m_nAddr != STORE_PAGE_NULL) - continue; - - // Load page. - eErrCode = loadObjectAt_Impl (rPage, nAddr); - if (eErrCode != store_E_None) - continue; - - // Deliver page. - return store_E_None; - } - - // Done. - return store_E_CantSeek; -} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/store/source/storbios.hxx b/store/source/storbios.hxx index 2f8a4db0b295..2c93acd1126b 100644 --- a/store/source/storbios.hxx +++ b/store/source/storbios.hxx @@ -92,8 +92,6 @@ public: storeError releasePage (const OStorePageDescriptor& rDescr); - sal_uInt32 getRefererCount(); - /** Page Allocation. */ enum Allocation @@ -149,18 +147,6 @@ public: inline bool isValid() const; }; - /** scanBegin. - */ - storeError scanBegin ( - ScanContext &rCtx, - sal_uInt32 nMagic = 0); - - /** scanNext. - */ - storeError scanNext ( - ScanContext &rCtx, - OStorePageObject &rPage); - protected: /** Destruction (OReference). */ diff --git a/store/source/stordata.hxx b/store/source/stordata.hxx index 90e5cdaf7933..640c5847426a 100644 --- a/store/source/stordata.hxx +++ b/store/source/stordata.hxx @@ -664,10 +664,6 @@ public: /** key. */ - OStorePageKey key() const - { - return PAGE().m_aNameBlock.m_aKey; - } void key (OStorePageKey const & rKey) { PAGE().m_aNameBlock.m_aKey = rKey; diff --git a/store/source/store.cxx b/store/source/store.cxx index 1b5107fc3837..beedbee91ea7 100644 --- a/store/source/store.cxx +++ b/store/source/store.cxx @@ -200,77 +200,6 @@ storeError SAL_CALL store_flushFile ( return xManager->flush(); } -/* - * store_getFileRefererCount. - */ -storeError SAL_CALL store_getFileRefererCount ( - storeFileHandle Handle, - sal_uInt32 *pnRefCount -) SAL_THROW_EXTERN_C() -{ - OStoreHandle<OStorePageManager> xManager ( - OStoreHandle<OStorePageManager>::query (Handle)); - if (!xManager.is()) - return store_E_InvalidHandle; - - if (!pnRefCount) - return store_E_InvalidParameter; - - *pnRefCount = xManager->getRefererCount(); - return store_E_None; -} - -/* - * store_getFileSize. - */ -storeError SAL_CALL store_getFileSize ( - storeFileHandle Handle, - sal_uInt32 *pnSize -) SAL_THROW_EXTERN_C() -{ - OStoreHandle<OStorePageManager> xManager ( - OStoreHandle<OStorePageManager>::query (Handle)); - if (!xManager.is()) - return store_E_InvalidHandle; - - if (!pnSize) - return store_E_InvalidParameter; - - return xManager->size (*pnSize); -} - -/* - * store_rebuildFile. - */ -storeError SAL_CALL store_rebuildFile ( - rtl_uString *pSrcFilename, - rtl_uString *pDstFilename -) SAL_THROW_EXTERN_C() -{ - storeError eErrCode = store_E_None; - - if (!(pSrcFilename && pDstFilename)) - return store_E_InvalidParameter; - - Reference<OStorePageManager> xManager (new OStorePageManager()); - if (!xManager.is()) - return store_E_OutOfMemory; - - Reference<ILockBytes> xSrcLB; - eErrCode = FileLockBytes_createInstance (xSrcLB, pSrcFilename, store_AccessReadOnly); - if (eErrCode != store_E_None) - return eErrCode; - OSL_ASSERT(xSrcLB.is()); - - Reference<ILockBytes> xDstLB; - eErrCode = FileLockBytes_createInstance (xDstLB, pDstFilename, store_AccessCreate); - if (eErrCode != store_E_None) - return eErrCode; - OSL_ASSERT(xDstLB.is()); - - return xManager->rebuild (&*xSrcLB, &*xDstLB); -} - /*======================================================================== * * storeDirectoryHandle implementation. @@ -317,22 +246,6 @@ storeError SAL_CALL store_openDirectory ( } /* - * store_closeDirectory. - */ -storeError SAL_CALL store_closeDirectory ( - storeDirectoryHandle Handle -) SAL_THROW_EXTERN_C() -{ - OStoreDirectory_Impl *pDirectory = - OStoreHandle<OStoreDirectory_Impl>::query (Handle); - if (!pDirectory) - return store_E_InvalidHandle; - - pDirectory->release(); - return store_E_None; -} - -/* * store_findFirst. */ storeError SAL_CALL store_findFirst ( @@ -427,22 +340,6 @@ storeError SAL_CALL store_openStream ( } /* - * store_closeStream. - */ -storeError SAL_CALL store_closeStream ( - storeStreamHandle Handle -) SAL_THROW_EXTERN_C() -{ - OStoreLockBytes *pLockBytes = - OStoreHandle<OStoreLockBytes>::query (Handle); - if (!pLockBytes) - return store_E_InvalidHandle; - - pLockBytes->release(); - return store_E_None; -} - -/* * store_readStream. */ storeError SAL_CALL store_readStream ( @@ -487,238 +384,6 @@ storeError SAL_CALL store_writeStream ( } /* - * store_flushStream. - */ -storeError SAL_CALL store_flushStream ( - storeStreamHandle Handle -) SAL_THROW_EXTERN_C() -{ - OStoreHandle<OStoreLockBytes> xLockBytes ( - OStoreHandle<OStoreLockBytes>::query (Handle)); - if (!xLockBytes.is()) - return store_E_InvalidHandle; - - return xLockBytes->flush(); -} - -/* - * store_getStreamSize. - */ -storeError SAL_CALL store_getStreamSize ( - storeStreamHandle Handle, - sal_uInt32 *pnSize -) SAL_THROW_EXTERN_C() -{ - OStoreHandle<OStoreLockBytes> xLockBytes ( - OStoreHandle<OStoreLockBytes>::query (Handle)); - if (!xLockBytes.is()) - return store_E_InvalidHandle; - - if (!pnSize) - return store_E_InvalidParameter; - - return xLockBytes->stat (*pnSize); -} - -/* - * store_setStreamSize. - */ -storeError SAL_CALL store_setStreamSize ( - storeStreamHandle Handle, - sal_uInt32 nSize -) SAL_THROW_EXTERN_C() -{ - OStoreHandle<OStoreLockBytes> xLockBytes ( - OStoreHandle<OStoreLockBytes>::query (Handle)); - if (!xLockBytes.is()) - return store_E_InvalidHandle; - - return xLockBytes->setSize (nSize); -} - -/*======================================================================== - * - * Common storeDirectoryHandle and storeStreamHandle operations. - * - *======================================================================*/ -/* - * store_attrib. - */ -storeError SAL_CALL store_attrib ( - storeFileHandle Handle, - rtl_uString *pPath, - rtl_uString *pName, - sal_uInt32 nMask1, - sal_uInt32 nMask2, - sal_uInt32 *pnAttrib -) SAL_THROW_EXTERN_C() -{ - storeError eErrCode = store_E_None; - if (pnAttrib) - *pnAttrib = 0; - - OStoreHandle<OStorePageManager> xManager ( - OStoreHandle<OStorePageManager>::query (Handle)); - if (!xManager.is()) - return store_E_InvalidHandle; - - if (!(pPath && pName)) - return store_E_InvalidParameter; - - // Setup page key. - OString aPath (pPath->buffer, pPath->length, RTL_TEXTENCODING_UTF8); - OString aName (pName->buffer, pName->length, RTL_TEXTENCODING_UTF8); - OStorePageKey aKey; - - eErrCode = OStorePageManager::namei (aPath.pData, aName.pData, aKey); - if (eErrCode != store_E_None) - return eErrCode; - - // Obtain or modify page attributes. - sal_uInt32 nAttrib = 0; - eErrCode = xManager->attrib (aKey, nMask1, nMask2, nAttrib); - if (pnAttrib) - *pnAttrib = nAttrib; - return eErrCode; -} - -/* - * store_link. - */ -storeError SAL_CALL store_link ( - storeFileHandle Handle, - rtl_uString *pSrcPath, rtl_uString *pSrcName, - rtl_uString *pDstPath, rtl_uString *pDstName -) SAL_THROW_EXTERN_C() -{ - storeError eErrCode = store_E_None; - - OStoreHandle<OStorePageManager> xManager ( - OStoreHandle<OStorePageManager>::query (Handle)); - if (!xManager.is()) - return store_E_InvalidHandle; - - if (!(pSrcPath && pSrcName)) - return store_E_InvalidParameter; - - if (!(pDstPath && pDstName)) - return store_E_InvalidParameter; - - // Setup 'Source' page key. - OString aSrcPath ( - pSrcPath->buffer, pSrcPath->length, RTL_TEXTENCODING_UTF8); - OString aSrcName ( - pSrcName->buffer, pSrcName->length, RTL_TEXTENCODING_UTF8); - OStorePageKey aSrcKey; - - eErrCode = OStorePageManager::namei ( - aSrcPath.pData, aSrcName.pData, aSrcKey); - if (eErrCode != store_E_None) - return eErrCode; - - // Setup 'Destination' page key. - OString aDstPath ( - pDstPath->buffer, pDstPath->length, RTL_TEXTENCODING_UTF8); - OString aDstName ( - pDstName->buffer, pDstName->length, RTL_TEXTENCODING_UTF8); - OStorePageKey aDstKey; - - eErrCode = OStorePageManager::namei ( - aDstPath.pData, aDstName.pData, aDstKey); - if (eErrCode != store_E_None) - return eErrCode; - - // Link 'Source' hard to 'Destination'. - return xManager->link (aSrcKey, aDstKey); -} - -/* - * store_symlink. - */ -storeError SAL_CALL store_symlink ( - storeFileHandle Handle, - rtl_uString *pSrcPath, rtl_uString *pSrcName, - rtl_uString *pDstPath, rtl_uString *pDstName -) SAL_THROW_EXTERN_C() -{ - storeError eErrCode = store_E_None; - - OStoreHandle<OStorePageManager> xManager ( - OStoreHandle<OStorePageManager>::query (Handle)); - if (!xManager.is()) - return store_E_InvalidHandle; - - if (!(pSrcPath && pSrcName)) - return store_E_InvalidParameter; - - if (!(pDstPath && pDstName)) - return store_E_InvalidParameter; - - // Setup 'Destination' page key. - OString aDstPath ( - pDstPath->buffer, pDstPath->length, RTL_TEXTENCODING_UTF8); - OString aDstName ( - pDstName->buffer, pDstName->length, RTL_TEXTENCODING_UTF8); - OStorePageKey aDstKey; - - eErrCode = OStorePageManager::namei ( - aDstPath.pData, aDstName.pData, aDstKey); - if (eErrCode != store_E_None) - return eErrCode; - - // Insert 'Source' as symlink to 'Destination'. - OString aSrcPath ( - pSrcPath->buffer, pSrcPath->length, RTL_TEXTENCODING_UTF8); - OString aSrcName ( - pSrcName->buffer, pSrcName->length, RTL_TEXTENCODING_UTF8); - - return xManager->symlink (aSrcPath.pData, aSrcName.pData, aDstKey); -} - -/* - * store_rename. - */ -storeError SAL_CALL store_rename ( - storeFileHandle Handle, - rtl_uString *pSrcPath, rtl_uString *pSrcName, - rtl_uString *pDstPath, rtl_uString *pDstName -) SAL_THROW_EXTERN_C() -{ - storeError eErrCode = store_E_None; - - OStoreHandle<OStorePageManager> xManager ( - OStoreHandle<OStorePageManager>::query (Handle)); - if (!xManager.is()) - return store_E_InvalidHandle; - - if (!(pSrcPath && pSrcName)) - return store_E_InvalidParameter; - - if (!(pDstPath && pDstName)) - return store_E_InvalidParameter; - - // Setup 'Source' page key. - OString aSrcPath ( - pSrcPath->buffer, pSrcPath->length, RTL_TEXTENCODING_UTF8); - OString aSrcName ( - pSrcName->buffer, pSrcName->length, RTL_TEXTENCODING_UTF8); - OStorePageKey aSrcKey; - - eErrCode = OStorePageManager::namei ( - aSrcPath.pData, aSrcName.pData, aSrcKey); - if (eErrCode != store_E_None) - return eErrCode; - - // Rename 'Source' into 'Destination'. - OString aDstPath ( - pDstPath->buffer, pDstPath->length, RTL_TEXTENCODING_UTF8); - OString aDstName ( - pDstName->buffer, pDstName->length, RTL_TEXTENCODING_UTF8); - - return xManager->rename (aSrcKey, aDstPath.pData, aDstName.pData); -} - -/* * store_remove. */ storeError SAL_CALL store_remove ( diff --git a/store/source/storlckb.cxx b/store/source/storlckb.cxx index b6afa2d086c8..0e74ab931974 100644 --- a/store/source/storlckb.cxx +++ b/store/source/storlckb.cxx @@ -349,17 +349,6 @@ storeError OStoreLockBytes::writeAt ( } /* - * flush. - */ -storeError OStoreLockBytes::flush() -{ - if (!m_xManager.is()) - return store_E_InvalidAccess; - - return m_xManager->flush(); -} - -/* * setSize. */ storeError OStoreLockBytes::setSize (sal_uInt32 nSize) @@ -426,19 +415,4 @@ storeError OStoreLockBytes::setSize (sal_uInt32 nSize) return m_xManager->saveObjectAt (aPage, aPage.location()); } -/* - * stat. - */ -storeError OStoreLockBytes::stat (sal_uInt32 &rnSize) -{ - rnSize = 0; - - if (!m_xManager.is()) - return store_E_InvalidAccess; - - OStoreDirectoryPageObject aPage (m_xNode.get()); - rnSize = aPage.dataLength(); - return store_E_None; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/store/source/storlckb.hxx b/store/source/storlckb.hxx index 184f14ccca03..c49993a55b8b 100644 --- a/store/source/storlckb.hxx +++ b/store/source/storlckb.hxx @@ -86,23 +86,12 @@ public: sal_uInt32 nBytes, sal_uInt32 &rnDone); - /** flush. - * @return store_E_None upon success - */ - storeError flush(); - /** setSize. * @param nSize [in] * @return store_E_None upon success */ storeError setSize (sal_uInt32 nSize); - /** stat. - * @paran rnSize [out] - * @return store_E_None upon success - */ - storeError stat (sal_uInt32 &rnSize); - /** IStoreHandle. */ virtual bool isKindOf (sal_uInt32 nMagic) override; diff --git a/store/source/storpage.cxx b/store/source/storpage.cxx index a50182681174..2892908599c1 100644 --- a/store/source/storpage.cxx +++ b/store/source/storpage.cxx @@ -437,282 +437,6 @@ storeError OStorePageManager::save_dirpage_Impl ( } /* - * attrib [nAttrib = ((nAttrib & ~nMask1) | nMask2)]. - * Precond: initialized. - */ -storeError OStorePageManager::attrib ( - const OStorePageKey &rKey, - sal_uInt32 nMask1, - sal_uInt32 nMask2, - sal_uInt32 &rAttrib) -{ - // Acquire exclusive access. - osl::MutexGuard aGuard(*this); - - // Check precond. - if (!self::isValid()) - return store_E_InvalidAccess; - - // Find NodePage and index. - OStoreBTreeNodeObject aNode; - sal_uInt16 i = 0; - storeError eErrCode = find_lookup (aNode, i, rKey); - if (eErrCode != store_E_None) - return eErrCode; - - // Existing entry. - PageHolderObject< page > xNode (aNode.get()); - entry e (xNode->m_pData[i]); - if (nMask1 != nMask2) - { - // Evaluate new attributes. - sal_uInt32 nAttrib = store::ntohl(e.m_nAttrib); - - nAttrib &= ~nMask1; - nAttrib |= nMask2; - - if (store::htonl(nAttrib) != e.m_nAttrib) - { - // Check access mode. - if (base::isWriteable()) - { - // Set new attributes. - e.m_nAttrib = store::htonl(nAttrib); - xNode->m_pData[i] = e; - - // Save modified NodePage. - eErrCode = saveObjectAt (aNode, aNode.location()); - } - else - { - // Access denied. - eErrCode = store_E_AccessViolation; - } - } - } - - // Obtain current attributes. - rAttrib = store::ntohl(e.m_nAttrib); - return eErrCode; -} - -/* - * link (insert 'Source' as hardlink to 'Destination'). - * Precond: initialized, writeable. - */ -storeError OStorePageManager::link ( - const OStorePageKey &rSrcKey, - const OStorePageKey &rDstKey) -{ - // Acquire exclusive access. - osl::MutexGuard aGuard(*this); - - // Check precond. - if (!self::isValid()) - return store_E_InvalidAccess; - - if (!base::isWriteable()) - return store_E_AccessViolation; - - // Find 'Destination' NodePage and Index. - OStoreBTreeNodeObject aDstNode; - sal_uInt16 i = 0; - storeError eErrCode = find_lookup (aDstNode, i, rDstKey); - if (eErrCode != store_E_None) - return eErrCode; - - // Existing 'Destination' entry. - PageHolderObject< page > xDstNode (aDstNode.get()); - entry e (xDstNode->m_pData[i]); - OStorePageLink aDstLink (e.m_aLink); - - // Find 'Source' NodePage and Index. - OStoreBTreeNodeObject aSrcNode; - eErrCode = m_aRoot.find_insert (aSrcNode, i, rSrcKey, *this); - if (eErrCode != store_E_None) - return eErrCode; - - // Insert 'Source' entry. - PageHolderObject< page > xSrcNode (aSrcNode.get()); - xSrcNode->insert (i + 1, entry (rSrcKey, aDstLink, STORE_ATTRIB_ISLINK)); - return saveObjectAt (aSrcNode, aSrcNode.location()); -} - -/* - * symlink (insert 'Source' DirectoryPage as symlink to 'Destination'). - * Precond: initialized, writeable. - */ -storeError OStorePageManager::symlink ( - const rtl_String *pSrcPath, - const rtl_String *pSrcName, - const OStorePageKey &rDstKey) -{ - // Acquire exclusive access. - osl::MutexGuard aGuard(*this); - - // Check precond. - if (!self::isValid()) - return store_E_InvalidAccess; - - if (!base::isWriteable()) - return store_E_AccessViolation; - - // Check 'Source' parameter. - storeError eErrCode = store_E_InvalidParameter; - if (!(pSrcPath && pSrcName)) - return eErrCode; - - // Setup 'Source' page key. - OStorePageKey aSrcKey; - eErrCode = namei (pSrcPath, pSrcName, aSrcKey); - if (eErrCode != store_E_None) - return eErrCode; - - // Find 'Source' NodePage and Index. - OStoreBTreeNodeObject aSrcNode; - sal_uInt16 i = 0; - eErrCode = m_aRoot.find_insert (aSrcNode, i, aSrcKey, *this); - if (eErrCode != store_E_None) - return eErrCode; - - // Initialize directory page. - OStoreDirectoryPageObject aPage; - eErrCode = aPage.construct< inode >(base::allocator()); - if (eErrCode != store_E_None) - return eErrCode; - - // Setup as 'Source' directory page. - inode_holder_type xNode (aPage.get()); - aPage.key (aSrcKey); - memcpy ( - &(xNode->m_aNameBlock.m_pData[0]), - pSrcName->buffer, pSrcName->length); - - // Store 'Destination' page key. - OStorePageKey aDstKey (rDstKey); - memcpy (&(xNode->m_pData[0]), &aDstKey, sizeof(aDstKey)); - - // Mark 'Source' as symbolic link to 'Destination'. - aPage.attrib (STORE_ATTRIB_ISLINK); - aPage.dataLength (sal_uInt32(sizeof(aDstKey))); - - // Allocate and save 'Source' directory page. - eErrCode = base::allocate (aPage); - if (eErrCode != store_E_None) - return eErrCode; - - // Insert 'Source' entry. - PageHolderObject< page > xSrcNode (aSrcNode.get()); - OStorePageLink aSrcLink (aPage.location()); - xSrcNode->insert (i + 1, entry(aSrcKey, aSrcLink)); - - // Save modified NodePage. - return saveObjectAt (aSrcNode, aSrcNode.location()); -} - -/* - * rename. - * Precond: initialized, writeable. - */ -storeError OStorePageManager::rename ( - const OStorePageKey &rSrcKey, - const rtl_String *pDstPath, - const rtl_String *pDstName) -{ - // Acquire exclusive access. - osl::MutexGuard aGuard(*this); - - // Check precond. - if (!self::isValid()) - return store_E_InvalidAccess; - - if (!base::isWriteable()) - return store_E_AccessViolation; - - // Check 'Destination' parameter. - storeError eErrCode = store_E_InvalidParameter; - if (!(pDstPath && pDstName)) - return eErrCode; - - // Setup 'Destination' page key. - OStorePageKey aDstKey; - eErrCode = namei (pDstPath, pDstName, aDstKey); - if (eErrCode != store_E_None) - return eErrCode; - - // Find 'Source' NodePage and Index. - OStoreBTreeNodeObject aSrcNode; - sal_uInt16 i = 0; - eErrCode = find_lookup (aSrcNode, i, rSrcKey); - if (eErrCode != store_E_None) - return eErrCode; - - // Existing 'Source' entry. - PageHolderObject< page > xSrcNode (aSrcNode.get()); - entry e (xSrcNode->m_pData[i]); - - // Check for (not a) hardlink. - OStoreDirectoryPageObject aPage; - if (!(store::ntohl(e.m_nAttrib) & STORE_ATTRIB_ISLINK)) - { - // Load directory page. - eErrCode = base::loadObjectAt (aPage, e.m_aLink.location()); - if (eErrCode != store_E_None) - return eErrCode; - - // Check for directory. - if (aPage.attrib() & STORE_ATTRIB_ISDIR) - { - // Ugly, but necessary (backward compatibility). - aDstKey.m_nLow = store::htonl(rtl_crc32 (store::ntohl(aDstKey.m_nLow), "/", 1)); - } - } - - // Let 'Source' entry be 'Destination' entry. - e.m_aKey = aDstKey; - - // Find 'Destination' NodePage and Index. - OStoreBTreeNodeObject aDstNode; - eErrCode = m_aRoot.find_insert (aDstNode, i, e.m_aKey, *this); - if (eErrCode != store_E_None) - return eErrCode; - - // Insert 'Destination' entry. - PageHolderObject< page > xDstNode (aDstNode.get()); - xDstNode->insert (i + 1, e); - - eErrCode = saveObjectAt (aDstNode, aDstNode.location()); - if (eErrCode != store_E_None) - return eErrCode; - - // Check for (not a) hardlink. - if (!(store::ntohl(e.m_nAttrib) & STORE_ATTRIB_ISLINK)) - { - // Modify 'Source' directory page. - inode_holder_type xNode (aPage.get()); - - // Setup 'Destination' NameBlock. - sal_Int32 nDstLen = pDstName->length; - memcpy ( - &(xNode->m_aNameBlock.m_pData[0]), - pDstName->buffer, pDstName->length); - memset ( - &(xNode->m_aNameBlock.m_pData[nDstLen]), - 0, STORE_MAXIMUM_NAMESIZE - nDstLen); - aPage.key (e.m_aKey); - - // Save directory page. - eErrCode = base::saveObjectAt (aPage, e.m_aLink.location()); - if (eErrCode != store_E_None) - return eErrCode; - } - - // Remove 'Source' entry. - e.m_aKey = rSrcKey; - return remove_Impl (e); -} - -/* * remove. * Precond: initialized, writeable. */ @@ -785,201 +509,5 @@ storeError OStorePageManager::remove (const OStorePageKey &rKey) return remove_Impl (e); } -/* - * RebuildContext. - */ -struct RebuildContext -{ - /** Representation. - */ - rtl::Reference<OStorePageBIOS> m_xBIOS; - OStorePageBIOS::ScanContext m_aCtx; - sal_uInt16 m_nPageSize; - - /** Construction. - */ - RebuildContext() - : m_xBIOS (new OStorePageBIOS()), - m_nPageSize (0) - {} - - /** initialize (PageBIOS and ScanContext). - */ - storeError initialize (ILockBytes *pLockBytes, sal_uInt32 nMagic = 0) - { - storeError eErrCode = store_E_InvalidParameter; - if (pLockBytes) - { - m_xBIOS->initialize (pLockBytes, store_AccessReadOnly, m_nPageSize); - eErrCode = m_xBIOS->scanBegin (m_aCtx, nMagic); - } - return eErrCode; - } - - /** initialize (ScanContext). - */ - storeError initialize (sal_uInt32 nMagic = 0) - { - return m_xBIOS->scanBegin (m_aCtx, nMagic); - } - - /** load (next ScanContext matching page). - */ - storeError load (OStorePageObject &rPage) - { - if (m_aCtx.isValid()) - return m_xBIOS->scanNext (m_aCtx, rPage); - else - return store_E_CantSeek; - } -}; - -/* - * rebuild. - * Precond: none. - */ -storeError OStorePageManager::rebuild ( - ILockBytes *pSrcLB, ILockBytes *pDstLB) -{ - // Acquire exclusive access. - osl::MutexGuard aGuard(*this); - - // Check arguments. - storeError eErrCode = store_E_InvalidParameter; - if (!(pSrcLB && pDstLB)) - return eErrCode; - - // Initialize 'Source' rebuild context. - RebuildContext aCtx; - eErrCode = aCtx.initialize (pSrcLB, STORE_MAGIC_DIRECTORYPAGE); - if (eErrCode != store_E_None) - return eErrCode; - rtl::Reference<OStorePageBIOS> xSrcBIOS (aCtx.m_xBIOS); - - // Initialize as 'Destination' with 'Source' page size. - eErrCode = self::initialize (pDstLB, store_AccessCreate, aCtx.m_nPageSize); - if (eErrCode != store_E_None) - return eErrCode; - - // Pass One: Scan 'Source' directory pages. - { - // Scan 'Source' directory pages. - OStoreDirectoryPageObject aSrcPage; - while ((eErrCode = aCtx.load(aSrcPage)) == store_E_None) - { - OStoreDirectoryPageObject aDstPage; - eErrCode = aDstPage.construct< inode >(base::allocator()); - if (eErrCode != store_E_None) - break; - - inode_holder_type xSrcDir (aSrcPage.get()); - inode_holder_type xDstDir (aDstPage.get()); - - // Copy NameBlock @@@ OLD @@@ - memcpy (&(xDstDir->m_aNameBlock), &(xSrcDir->m_aNameBlock), sizeof(xSrcDir->m_aNameBlock)); - - // Obtain 'Source' data length. - sal_uInt32 nDataLen = aSrcPage.dataLength(); - if (nDataLen > 0) - { - // Copy internal data area @@@ OLD @@@ - memcpy (&(xDstDir->m_pData[0]), &(xSrcDir->m_pData[0]), xSrcDir->capacity()); - } - - // Insert 'Destination' directory page. - eErrCode = save_dirpage_Impl (aDstPage.key(), aDstPage); - if (eErrCode != store_E_None) - break; - - // Check for external data page scope. - if (xSrcDir->scope(nDataLen) != inode::SCOPE_INTERNAL) - { - // Initialize 'Destination' data page. - typedef OStoreDataPageData data; - PageHolderObject< data > xData; - if (!xData.construct(base::allocator())) - return store_E_OutOfMemory; - - // Determine data page count. - inode::ChunkDescriptor aDescr ( - nDataLen - xDstDir->capacity(), xData->capacity()); - - sal_uInt32 i, n = aDescr.m_nPage; - if (aDescr.m_nOffset) n += 1; - - // Copy data pages. - OStoreDataPageObject aData; - for (i = 0; i < n; i++) - { - // Read 'Source' data page. - osl::MutexGuard aSrcGuard (*xSrcBIOS); - - eErrCode = aSrcPage.read (i, aData, *xSrcBIOS); - if (eErrCode != store_E_None) - continue; - - // Write 'Destination' data page. @@@ READONLY @@@ - (void) aDstPage.write (i, aData, *this); - } - } - - // Update 'Destination' directory page. - aDstPage.dataLength (nDataLen); - (void) base::saveObjectAt (aDstPage, aDstPage.location()); - } - - // Save directory scan results. - flush(); - } - - // Pass Two: Scan 'Source' BTree nodes. - { - // Re-start 'Source' rebuild context. - aCtx.initialize (STORE_MAGIC_BTREENODE); - - // Scan 'Source' BTree nodes. - OStoreBTreeNodeObject aNode; - while ((eErrCode = aCtx.load(aNode)) == store_E_None) - { - // Check for leaf node. - PageHolderObject< page > xNode (aNode.get()); - if (xNode->depth() == 0) - { - sal_uInt16 i, n = xNode->usageCount(); - for (i = 0; i < n; i++) - { - entry e (xNode->m_pData[i]); - - // Check for Hard link. - if (e.m_nAttrib & STORE_ATTRIB_ISLINK) - { - // Load the hard link destination. - OStoreDirectoryPageObject aSrcPage; - eErrCode = xSrcBIOS->loadObjectAt (aSrcPage, e.m_aLink.location()); - if (eErrCode == store_E_None) - { - OStorePageKey aDstKey (aSrcPage.key()); - link (e.m_aKey, aDstKey); - } - e.m_nAttrib &= ~STORE_ATTRIB_ISLINK; - } - - if (e.m_nAttrib) - { - // Ordinary attributes. - sal_uInt32 nAttrib = 0; - attrib (e.m_aKey, 0, e.m_nAttrib, nAttrib); - } - } - } - } - - // Save BTree node scan results. - flush(); - } - - // Done. - return store_E_None; -} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/store/source/storpage.hxx b/store/source/storpage.hxx index cdeeea68e2e2..1dfeb048d777 100644 --- a/store/source/storpage.hxx +++ b/store/source/storpage.hxx @@ -79,55 +79,12 @@ public: OStorePageLink & rLink, sal_uInt32 & rAttrib); - /** attrib [nAttrib = ((nAttrib & ~nMask1) | nMask2)]. - * @see store_attrib() - */ - storeError attrib ( - const OStorePageKey &rKey, - sal_uInt32 nMask1, - sal_uInt32 nMask2, - sal_uInt32 &rAttrib); - - /** link (insert Source Key as hardlink to Destination). - * @see store_link() - */ - storeError link ( - const OStorePageKey &rSrcKey, - const OStorePageKey &rDstKey); - - /** symlink (insert Source DirectoryPage as symlink to Destination). - * @see store_symlink() - */ - storeError symlink ( - const rtl_String *pSrcPath, - const rtl_String *pSrcName, - const OStorePageKey &rDstKey); - - /** rename. - * @see store_rename() - */ - storeError rename ( - const OStorePageKey &rSrcKey, - const rtl_String *pDstPath, - const rtl_String *pDstName); - /** remove. * @see store_remove() */ storeError remove ( const OStorePageKey &rKey); - /** rebuild (combines recover and compact from 'Src' to 'Dst'). - * @param pSrcLB [in] accessed readonly. - * @param pDstLB [in] truncated and accessed readwrite (as initialize()). - * @return store_E_None upon success. - * - * @see store_rebuildFile() - */ - storeError rebuild ( - ILockBytes *pSrcLB, - ILockBytes *pDstLB); - /** IStoreHandle. */ virtual bool isKindOf (sal_uInt32 nTypeId) override; |