1*73d9b18aSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*73d9b18aSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*73d9b18aSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*73d9b18aSAndrew Rist * distributed with this work for additional information
6*73d9b18aSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*73d9b18aSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*73d9b18aSAndrew Rist * "License"); you may not use this file except in compliance
9*73d9b18aSAndrew Rist * with the License. You may obtain a copy of the License at
10*73d9b18aSAndrew Rist *
11*73d9b18aSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*73d9b18aSAndrew Rist *
13*73d9b18aSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*73d9b18aSAndrew Rist * software distributed under the License is distributed on an
15*73d9b18aSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*73d9b18aSAndrew Rist * KIND, either express or implied. See the License for the
17*73d9b18aSAndrew Rist * specific language governing permissions and limitations
18*73d9b18aSAndrew Rist * under the License.
19*73d9b18aSAndrew Rist *
20*73d9b18aSAndrew Rist *************************************************************/
21*73d9b18aSAndrew Rist
22*73d9b18aSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_store.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "storlckb.hxx"
28cdf0e10cSrcweir
29cdf0e10cSrcweir #include "sal/types.h"
30cdf0e10cSrcweir #include "sal/macros.h"
31cdf0e10cSrcweir #include "rtl/string.h"
32cdf0e10cSrcweir #include "rtl/ref.hxx"
33cdf0e10cSrcweir #include "osl/mutex.hxx"
34cdf0e10cSrcweir
35cdf0e10cSrcweir #include "store/types.h"
36cdf0e10cSrcweir #include "object.hxx"
37cdf0e10cSrcweir
38cdf0e10cSrcweir #include "storbase.hxx"
39cdf0e10cSrcweir #include "stordata.hxx"
40cdf0e10cSrcweir #include "storpage.hxx"
41cdf0e10cSrcweir
42cdf0e10cSrcweir using namespace store;
43cdf0e10cSrcweir
44cdf0e10cSrcweir /*========================================================================
45cdf0e10cSrcweir *
46cdf0e10cSrcweir * OStoreLockBytes implementation.
47cdf0e10cSrcweir *
48cdf0e10cSrcweir *======================================================================*/
49cdf0e10cSrcweir const sal_uInt32 OStoreLockBytes::m_nTypeId = sal_uInt32(0x94190310);
50cdf0e10cSrcweir
51cdf0e10cSrcweir /*
52cdf0e10cSrcweir * OStoreLockBytes.
53cdf0e10cSrcweir */
OStoreLockBytes(void)54cdf0e10cSrcweir OStoreLockBytes::OStoreLockBytes (void)
55cdf0e10cSrcweir : m_xManager (),
56cdf0e10cSrcweir m_xNode (),
57cdf0e10cSrcweir m_bWriteable (false)
58cdf0e10cSrcweir {
59cdf0e10cSrcweir }
60cdf0e10cSrcweir
61cdf0e10cSrcweir /*
62cdf0e10cSrcweir * ~OStoreLockBytes.
63cdf0e10cSrcweir */
~OStoreLockBytes(void)64cdf0e10cSrcweir OStoreLockBytes::~OStoreLockBytes (void)
65cdf0e10cSrcweir {
66cdf0e10cSrcweir if (m_xManager.is())
67cdf0e10cSrcweir {
68cdf0e10cSrcweir if (m_xNode.is())
69cdf0e10cSrcweir {
70cdf0e10cSrcweir OStorePageDescriptor aDescr (m_xNode->m_aDescr);
71cdf0e10cSrcweir if (m_bWriteable)
72cdf0e10cSrcweir m_xManager->releasePage (aDescr, store_AccessReadWrite);
73cdf0e10cSrcweir else
74cdf0e10cSrcweir m_xManager->releasePage (aDescr, store_AccessReadOnly);
75cdf0e10cSrcweir }
76cdf0e10cSrcweir }
77cdf0e10cSrcweir }
78cdf0e10cSrcweir
79cdf0e10cSrcweir /*
80cdf0e10cSrcweir * isKindOf.
81cdf0e10cSrcweir */
isKindOf(sal_uInt32 nTypeId)82cdf0e10cSrcweir sal_Bool SAL_CALL OStoreLockBytes::isKindOf (sal_uInt32 nTypeId)
83cdf0e10cSrcweir {
84cdf0e10cSrcweir return (nTypeId == m_nTypeId);
85cdf0e10cSrcweir }
86cdf0e10cSrcweir
87cdf0e10cSrcweir /*
88cdf0e10cSrcweir * create.
89cdf0e10cSrcweir */
create(OStorePageManager * pManager,rtl_String * pPath,rtl_String * pName,storeAccessMode eMode)90cdf0e10cSrcweir storeError OStoreLockBytes::create (
91cdf0e10cSrcweir OStorePageManager *pManager,
92cdf0e10cSrcweir rtl_String *pPath,
93cdf0e10cSrcweir rtl_String *pName,
94cdf0e10cSrcweir storeAccessMode eMode)
95cdf0e10cSrcweir {
96cdf0e10cSrcweir rtl::Reference<OStorePageManager> xManager (pManager);
97cdf0e10cSrcweir if (!xManager.is())
98cdf0e10cSrcweir return store_E_InvalidAccess;
99cdf0e10cSrcweir
100cdf0e10cSrcweir if (!(pPath && pName))
101cdf0e10cSrcweir return store_E_InvalidParameter;
102cdf0e10cSrcweir
103cdf0e10cSrcweir OStoreDirectoryPageObject aPage;
104cdf0e10cSrcweir storeError eErrCode = xManager->iget (
105cdf0e10cSrcweir aPage, STORE_ATTRIB_ISFILE,
106cdf0e10cSrcweir pPath, pName, eMode);
107cdf0e10cSrcweir if (eErrCode != store_E_None)
108cdf0e10cSrcweir return eErrCode;
109cdf0e10cSrcweir
110cdf0e10cSrcweir if (!(aPage.attrib() & STORE_ATTRIB_ISFILE))
111cdf0e10cSrcweir {
112cdf0e10cSrcweir // No ISFILE in older versions (backward compatibility).
113cdf0e10cSrcweir if (aPage.attrib() & STORE_ATTRIB_ISLINK)
114cdf0e10cSrcweir return store_E_NotFile;
115cdf0e10cSrcweir }
116cdf0e10cSrcweir
117cdf0e10cSrcweir // ...
118cdf0e10cSrcweir inode_holder_type xNode (aPage.get());
119cdf0e10cSrcweir if (eMode != store_AccessReadOnly)
120cdf0e10cSrcweir eErrCode = xManager->acquirePage (xNode->m_aDescr, store_AccessReadWrite);
121cdf0e10cSrcweir else
122cdf0e10cSrcweir eErrCode = xManager->acquirePage (xNode->m_aDescr, store_AccessReadOnly);
123cdf0e10cSrcweir if (eErrCode != store_E_None)
124cdf0e10cSrcweir return eErrCode;
125cdf0e10cSrcweir
126cdf0e10cSrcweir // ...
127cdf0e10cSrcweir m_xManager = xManager;
128cdf0e10cSrcweir m_xNode = xNode;
129cdf0e10cSrcweir m_bWriteable = (eMode != store_AccessReadOnly);
130cdf0e10cSrcweir
131cdf0e10cSrcweir // Check for truncation.
132cdf0e10cSrcweir if (eMode == store_AccessCreate)
133cdf0e10cSrcweir {
134cdf0e10cSrcweir // Truncate to zero length.
135cdf0e10cSrcweir eErrCode = setSize(0);
136cdf0e10cSrcweir }
137cdf0e10cSrcweir return eErrCode;
138cdf0e10cSrcweir }
139cdf0e10cSrcweir
140cdf0e10cSrcweir /*
141cdf0e10cSrcweir * readAt.
142cdf0e10cSrcweir */
readAt(sal_uInt32 nOffset,void * pBuffer,sal_uInt32 nBytes,sal_uInt32 & rnDone)143cdf0e10cSrcweir storeError OStoreLockBytes::readAt (
144cdf0e10cSrcweir sal_uInt32 nOffset,
145cdf0e10cSrcweir void *pBuffer,
146cdf0e10cSrcweir sal_uInt32 nBytes,
147cdf0e10cSrcweir sal_uInt32 &rnDone)
148cdf0e10cSrcweir {
149cdf0e10cSrcweir rnDone = 0;
150cdf0e10cSrcweir
151cdf0e10cSrcweir if (!m_xManager.is())
152cdf0e10cSrcweir return store_E_InvalidAccess;
153cdf0e10cSrcweir
154cdf0e10cSrcweir if (!pBuffer)
155cdf0e10cSrcweir return store_E_InvalidParameter;
156cdf0e10cSrcweir if (!nBytes)
157cdf0e10cSrcweir return store_E_None;
158cdf0e10cSrcweir
159cdf0e10cSrcweir // Acquire exclusive access.
160cdf0e10cSrcweir osl::MutexGuard aGuard (*m_xManager);
161cdf0e10cSrcweir
162cdf0e10cSrcweir // Determine data length.
163cdf0e10cSrcweir OStoreDirectoryPageObject aPage (m_xNode.get());
164cdf0e10cSrcweir
165cdf0e10cSrcweir sal_uInt32 nDataLen = aPage.dataLength();
166cdf0e10cSrcweir if ((nOffset + nBytes) > nDataLen)
167cdf0e10cSrcweir nBytes = nDataLen - nOffset;
168cdf0e10cSrcweir
169cdf0e10cSrcweir // Read data.
170cdf0e10cSrcweir OStoreDataPageObject aData;
171cdf0e10cSrcweir sal_uInt8 *pData = (sal_uInt8*)pBuffer;
172cdf0e10cSrcweir while ((0 < nBytes) && (nOffset < nDataLen))
173cdf0e10cSrcweir {
174cdf0e10cSrcweir // Determine 'Offset' scope.
175cdf0e10cSrcweir inode::ChunkScope eScope = m_xNode->scope (nOffset);
176cdf0e10cSrcweir if (eScope == inode::SCOPE_INTERNAL)
177cdf0e10cSrcweir {
178cdf0e10cSrcweir // Read from inode page (internal scope).
179cdf0e10cSrcweir inode::ChunkDescriptor aDescr (
180cdf0e10cSrcweir nOffset, m_xNode->capacity());
181cdf0e10cSrcweir
182cdf0e10cSrcweir sal_uInt32 nLength = sal_uInt32(aDescr.m_nLength);
183cdf0e10cSrcweir nLength = SAL_MIN(nLength, nBytes);
184cdf0e10cSrcweir
185cdf0e10cSrcweir memcpy (
186cdf0e10cSrcweir &pData[rnDone],
187cdf0e10cSrcweir &m_xNode->m_pData[aDescr.m_nOffset],
188cdf0e10cSrcweir nLength);
189cdf0e10cSrcweir
190cdf0e10cSrcweir // Adjust counters.
191cdf0e10cSrcweir rnDone += nLength;
192cdf0e10cSrcweir nOffset += nLength;
193cdf0e10cSrcweir nBytes -= nLength;
194cdf0e10cSrcweir }
195cdf0e10cSrcweir else
196cdf0e10cSrcweir {
197cdf0e10cSrcweir // Read from data page (external scope).
198cdf0e10cSrcweir inode::ChunkDescriptor aDescr (
199cdf0e10cSrcweir nOffset - m_xNode->capacity(), OStoreDataPageData::capacity(m_xNode->m_aDescr)); // @@@
200cdf0e10cSrcweir
201cdf0e10cSrcweir sal_uInt32 nLength = sal_uInt32(aDescr.m_nLength);
202cdf0e10cSrcweir nLength = SAL_MIN(nLength, nBytes);
203cdf0e10cSrcweir
204cdf0e10cSrcweir storeError eErrCode = aPage.read (aDescr.m_nPage, aData, *m_xManager);
205cdf0e10cSrcweir if (eErrCode != store_E_None)
206cdf0e10cSrcweir {
207cdf0e10cSrcweir if (eErrCode != store_E_NotExists)
208cdf0e10cSrcweir return eErrCode;
209cdf0e10cSrcweir
210cdf0e10cSrcweir memset (
211cdf0e10cSrcweir &pData[rnDone],
212cdf0e10cSrcweir 0,
213cdf0e10cSrcweir nLength);
214cdf0e10cSrcweir }
215cdf0e10cSrcweir else
216cdf0e10cSrcweir {
217cdf0e10cSrcweir PageHolderObject< data > xData (aData.makeHolder<data>());
218cdf0e10cSrcweir memcpy (
219cdf0e10cSrcweir &pData[rnDone],
220cdf0e10cSrcweir &xData->m_pData[aDescr.m_nOffset],
221cdf0e10cSrcweir nLength);
222cdf0e10cSrcweir }
223cdf0e10cSrcweir
224cdf0e10cSrcweir // Adjust counters.
225cdf0e10cSrcweir rnDone += nLength;
226cdf0e10cSrcweir nOffset += nLength;
227cdf0e10cSrcweir nBytes -= nLength;
228cdf0e10cSrcweir }
229cdf0e10cSrcweir }
230cdf0e10cSrcweir
231cdf0e10cSrcweir // Done.
232cdf0e10cSrcweir return store_E_None;
233cdf0e10cSrcweir }
234cdf0e10cSrcweir
235cdf0e10cSrcweir /*
236cdf0e10cSrcweir * writeAt.
237cdf0e10cSrcweir */
writeAt(sal_uInt32 nOffset,const void * pBuffer,sal_uInt32 nBytes,sal_uInt32 & rnDone)238cdf0e10cSrcweir storeError OStoreLockBytes::writeAt (
239cdf0e10cSrcweir sal_uInt32 nOffset,
240cdf0e10cSrcweir const void *pBuffer,
241cdf0e10cSrcweir sal_uInt32 nBytes,
242cdf0e10cSrcweir sal_uInt32 &rnDone)
243cdf0e10cSrcweir {
244cdf0e10cSrcweir rnDone = 0;
245cdf0e10cSrcweir
246cdf0e10cSrcweir if (!m_xManager.is())
247cdf0e10cSrcweir return store_E_InvalidAccess;
248cdf0e10cSrcweir if (!m_bWriteable)
249cdf0e10cSrcweir return store_E_AccessViolation;
250cdf0e10cSrcweir
251cdf0e10cSrcweir if (!pBuffer)
252cdf0e10cSrcweir return store_E_InvalidParameter;
253cdf0e10cSrcweir if (!nBytes)
254cdf0e10cSrcweir return store_E_None;
255cdf0e10cSrcweir
256cdf0e10cSrcweir // Acquire exclusive access.
257cdf0e10cSrcweir osl::MutexGuard aGuard (*m_xManager);
258cdf0e10cSrcweir
259cdf0e10cSrcweir // Write data.
260cdf0e10cSrcweir OStoreDirectoryPageObject aPage (m_xNode.get());
261cdf0e10cSrcweir const sal_uInt8 *pData = (const sal_uInt8*)pBuffer;
262cdf0e10cSrcweir
263cdf0e10cSrcweir storeError eErrCode = store_E_None;
264cdf0e10cSrcweir while (nBytes > 0)
265cdf0e10cSrcweir {
266cdf0e10cSrcweir // Determine 'Offset' scope.
267cdf0e10cSrcweir inode::ChunkScope eScope = m_xNode->scope (nOffset);
268cdf0e10cSrcweir if (eScope == inode::SCOPE_INTERNAL)
269cdf0e10cSrcweir {
270cdf0e10cSrcweir // Write to inode page (internal scope).
271cdf0e10cSrcweir inode::ChunkDescriptor aDescr (
272cdf0e10cSrcweir nOffset, m_xNode->capacity());
273cdf0e10cSrcweir
274cdf0e10cSrcweir sal_uInt32 nLength = sal_uInt32(aDescr.m_nLength);
275cdf0e10cSrcweir nLength = SAL_MIN(nLength, nBytes);
276cdf0e10cSrcweir
277cdf0e10cSrcweir memcpy (
278cdf0e10cSrcweir &m_xNode->m_pData[aDescr.m_nOffset],
279cdf0e10cSrcweir &pData[rnDone], nLength);
280cdf0e10cSrcweir
281cdf0e10cSrcweir // Mark inode dirty.
282cdf0e10cSrcweir aPage.touch();
283cdf0e10cSrcweir
284cdf0e10cSrcweir // Adjust counters.
285cdf0e10cSrcweir rnDone += nLength;
286cdf0e10cSrcweir nOffset += nLength;
287cdf0e10cSrcweir nBytes -= nLength;
288cdf0e10cSrcweir
289cdf0e10cSrcweir // Adjust data length.
290cdf0e10cSrcweir if (aPage.dataLength() < nOffset)
291cdf0e10cSrcweir aPage.dataLength (nOffset);
292cdf0e10cSrcweir }
293cdf0e10cSrcweir else
294cdf0e10cSrcweir {
295cdf0e10cSrcweir // Write to data page (external scope).
296cdf0e10cSrcweir OStoreDataPageObject aData;
297cdf0e10cSrcweir
298cdf0e10cSrcweir inode::ChunkDescriptor aDescr (
299cdf0e10cSrcweir nOffset - m_xNode->capacity(), OStoreDataPageData::capacity(m_xNode->m_aDescr)); // @@@
300cdf0e10cSrcweir
301cdf0e10cSrcweir sal_uInt32 nLength = sal_uInt32(aDescr.m_nLength);
302cdf0e10cSrcweir if ((aDescr.m_nOffset > 0) || (nBytes < nLength))
303cdf0e10cSrcweir {
304cdf0e10cSrcweir // Unaligned. Need to load/create data page.
305cdf0e10cSrcweir // @@@ loadOrCreate()
306cdf0e10cSrcweir eErrCode = aPage.read (aDescr.m_nPage, aData, *m_xManager);
307cdf0e10cSrcweir if (eErrCode != store_E_None)
308cdf0e10cSrcweir {
309cdf0e10cSrcweir if (eErrCode != store_E_NotExists)
310cdf0e10cSrcweir return eErrCode;
311cdf0e10cSrcweir
312cdf0e10cSrcweir eErrCode = aData.construct<data>(m_xManager->allocator());
313cdf0e10cSrcweir if (eErrCode != store_E_None)
314cdf0e10cSrcweir return eErrCode;
315cdf0e10cSrcweir }
316cdf0e10cSrcweir }
317cdf0e10cSrcweir
318cdf0e10cSrcweir PageHolderObject< data > xData (aData.makeHolder<data>());
319cdf0e10cSrcweir if (!xData.is())
320cdf0e10cSrcweir {
321cdf0e10cSrcweir eErrCode = aData.construct<data>(m_xManager->allocator());
322cdf0e10cSrcweir if (eErrCode != store_E_None)
323cdf0e10cSrcweir return eErrCode;
324cdf0e10cSrcweir xData = aData.makeHolder<data>();
325cdf0e10cSrcweir }
326cdf0e10cSrcweir
327cdf0e10cSrcweir // Modify data page.
328cdf0e10cSrcweir nLength = SAL_MIN(nLength, nBytes);
329cdf0e10cSrcweir memcpy (
330cdf0e10cSrcweir &xData->m_pData[aDescr.m_nOffset],
331cdf0e10cSrcweir &pData[rnDone], nLength);
332cdf0e10cSrcweir
333cdf0e10cSrcweir // Save data page.
334cdf0e10cSrcweir eErrCode = aPage.write (aDescr.m_nPage, aData, *m_xManager);
335cdf0e10cSrcweir if (eErrCode != store_E_None)
336cdf0e10cSrcweir return eErrCode;
337cdf0e10cSrcweir
338cdf0e10cSrcweir // Adjust counters.
339cdf0e10cSrcweir rnDone += nLength;
340cdf0e10cSrcweir nOffset += nLength;
341cdf0e10cSrcweir nBytes -= nLength;
342cdf0e10cSrcweir
343cdf0e10cSrcweir // Adjust data length.
344cdf0e10cSrcweir if (aPage.dataLength() < nOffset)
345cdf0e10cSrcweir aPage.dataLength (nOffset);
346cdf0e10cSrcweir }
347cdf0e10cSrcweir }
348cdf0e10cSrcweir
349cdf0e10cSrcweir // Check for modified inode.
350cdf0e10cSrcweir if (aPage.dirty())
351cdf0e10cSrcweir return m_xManager->saveObjectAt (aPage, aPage.location());
352cdf0e10cSrcweir else
353cdf0e10cSrcweir return store_E_None;
354cdf0e10cSrcweir }
355cdf0e10cSrcweir
356cdf0e10cSrcweir /*
357cdf0e10cSrcweir * flush.
358cdf0e10cSrcweir */
flush(void)359cdf0e10cSrcweir storeError OStoreLockBytes::flush (void)
360cdf0e10cSrcweir {
361cdf0e10cSrcweir if (!m_xManager.is())
362cdf0e10cSrcweir return store_E_InvalidAccess;
363cdf0e10cSrcweir
364cdf0e10cSrcweir return m_xManager->flush();
365cdf0e10cSrcweir }
366cdf0e10cSrcweir
367cdf0e10cSrcweir /*
368cdf0e10cSrcweir * setSize.
369cdf0e10cSrcweir */
setSize(sal_uInt32 nSize)370cdf0e10cSrcweir storeError OStoreLockBytes::setSize (sal_uInt32 nSize)
371cdf0e10cSrcweir {
372cdf0e10cSrcweir if (!m_xManager.is())
373cdf0e10cSrcweir return store_E_InvalidAccess;
374cdf0e10cSrcweir if (!m_bWriteable)
375cdf0e10cSrcweir return store_E_AccessViolation;
376cdf0e10cSrcweir
377cdf0e10cSrcweir // Acquire exclusive access.
378cdf0e10cSrcweir osl::MutexGuard aGuard (*m_xManager);
379cdf0e10cSrcweir
380cdf0e10cSrcweir // Determine current length.
381cdf0e10cSrcweir OStoreDirectoryPageObject aPage (m_xNode.get());
382cdf0e10cSrcweir sal_uInt32 nDataLen = aPage.dataLength();
383cdf0e10cSrcweir
384cdf0e10cSrcweir if (nSize == nDataLen)
385cdf0e10cSrcweir return store_E_None;
386cdf0e10cSrcweir
387cdf0e10cSrcweir if (nSize < nDataLen)
388cdf0e10cSrcweir {
389cdf0e10cSrcweir // Truncate.
390cdf0e10cSrcweir storeError eErrCode = store_E_None;
391cdf0e10cSrcweir
392cdf0e10cSrcweir // Determine 'Size' scope.
393cdf0e10cSrcweir inode::ChunkScope eSizeScope = m_xNode->scope (nSize);
394cdf0e10cSrcweir if (eSizeScope == inode::SCOPE_INTERNAL)
395cdf0e10cSrcweir {
396cdf0e10cSrcweir // Internal 'Size' scope. Determine 'Data' scope.
397cdf0e10cSrcweir inode::ChunkScope eDataScope = m_xNode->scope (nDataLen);
398cdf0e10cSrcweir if (eDataScope == inode::SCOPE_EXTERNAL)
399cdf0e10cSrcweir {
400cdf0e10cSrcweir // External 'Data' scope. Truncate all external data pages.
401cdf0e10cSrcweir eErrCode = aPage.truncate (0, *m_xManager);
402cdf0e10cSrcweir if (eErrCode != store_E_None)
403cdf0e10cSrcweir return eErrCode;
404cdf0e10cSrcweir }
405cdf0e10cSrcweir
406cdf0e10cSrcweir // Truncate internal data page.
407cdf0e10cSrcweir inode::ChunkDescriptor aDescr (nSize, m_xNode->capacity());
408cdf0e10cSrcweir memset (
409cdf0e10cSrcweir &(m_xNode->m_pData[aDescr.m_nOffset]),
410cdf0e10cSrcweir 0, aDescr.m_nLength);
411cdf0e10cSrcweir }
412cdf0e10cSrcweir else
413cdf0e10cSrcweir {
414cdf0e10cSrcweir // External 'Size' scope. Truncate external data pages.
415cdf0e10cSrcweir inode::ChunkDescriptor aDescr (
416cdf0e10cSrcweir nSize - m_xNode->capacity(), OStoreDataPageData::capacity(m_xNode->m_aDescr)); // @@@
417cdf0e10cSrcweir
418cdf0e10cSrcweir sal_uInt32 nPage = aDescr.m_nPage;
419cdf0e10cSrcweir if (aDescr.m_nOffset) nPage += 1;
420cdf0e10cSrcweir
421cdf0e10cSrcweir eErrCode = aPage.truncate (nPage, *m_xManager);
422cdf0e10cSrcweir if (eErrCode != store_E_None)
423cdf0e10cSrcweir return eErrCode;
424cdf0e10cSrcweir }
425cdf0e10cSrcweir }
426cdf0e10cSrcweir
427cdf0e10cSrcweir // Set (extended or truncated) size.
428cdf0e10cSrcweir aPage.dataLength (nSize);
429cdf0e10cSrcweir
430cdf0e10cSrcweir // Save modified inode.
431cdf0e10cSrcweir return m_xManager->saveObjectAt (aPage, aPage.location());
432cdf0e10cSrcweir }
433cdf0e10cSrcweir
434cdf0e10cSrcweir /*
435cdf0e10cSrcweir * stat.
436cdf0e10cSrcweir */
stat(sal_uInt32 & rnSize)437cdf0e10cSrcweir storeError OStoreLockBytes::stat (sal_uInt32 &rnSize)
438cdf0e10cSrcweir {
439cdf0e10cSrcweir rnSize = 0;
440cdf0e10cSrcweir
441cdf0e10cSrcweir if (!m_xManager.is())
442cdf0e10cSrcweir return store_E_InvalidAccess;
443cdf0e10cSrcweir
444cdf0e10cSrcweir OStoreDirectoryPageObject aPage (m_xNode.get());
445cdf0e10cSrcweir rnSize = aPage.dataLength();
446cdf0e10cSrcweir return store_E_None;
447cdf0e10cSrcweir }
448