LibreOffice Module sot (master) 1
stgdir.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#ifndef INCLUDED_SOT_SOURCE_SDSTOR_STGDIR_HXX
21#define INCLUDED_SOT_SOURCE_SDSTOR_STGDIR_HXX
22
23#include "stgavl.hxx"
24#include "stgelem.hxx"
25#include "stgstrms.hxx"
26
27class StgIo;
28class StgDirStrm;
29
31class StgDirEntry : public StgAvlNode
32{
33 friend class StgIterator;
34 friend class StgDirStrm;
35 StgEntry m_aSave; // original dir entry
36 StgDirEntry* m_pUp; // parent directory
37 StgDirEntry* m_pDown; // child directory for storages
38 StgStrm* m_pStgStrm; // storage stream
39 StgTmpStrm* m_pTmpStrm; // temporary stream
40 StgTmpStrm* m_pCurStrm; // temp stream after commit
41 sal_Int32 m_nEntry; // entry # in TOC stream (temp)
42 sal_Int32 m_nPos; // current position
43 bool m_bDirty; // dirty directory entry
44 bool m_bRemoved; // removed per Invalidate()
45 void InitMembers(); // ctor helper
46 virtual sal_Int32 Compare( const StgAvlNode* ) const override;
47 bool StoreStream( StgIo& ); // store the stream
48 bool StoreStreams( StgIo& ); // store all streams
49 void RevertAll(); // revert the whole tree
50 bool Strm2Tmp(); // copy stgstream to temp file
51 bool Tmp2Strm(); // copy temp file to stgstream
52public:
53 StgEntry m_aEntry; // entry data
54 sal_Int32 m_nRefCnt; // reference count
55 StreamMode m_nMode; // open mode
56 bool m_bTemp; // true: delete on dir flush
57 bool m_bDirect; // true: direct mode
58 bool m_bZombie; // true: Removed From StgIo
59 bool m_bInvalid; // true: invalid entry
60 StgDirEntry(const void* pBuffer, sal_uInt32 nBufferLen,
61 sal_uInt64 nUnderlyingStreamSize, bool * pbOk);
62 explicit StgDirEntry( const StgEntry& );
63 virtual ~StgDirEntry() override;
64
65 void Invalidate( bool ); // invalidate all open entries
66 void Enum( sal_Int32& ); // enumerate entries for iteration
67 void DelTemp( bool ); // delete temporary entries
68 bool Store( StgDirStrm& ); // save entry into dir strm
69
70 void SetDirty() { m_bDirty = true; }
71 bool IsDirty();
72
73 bool Commit();
74
75 void OpenStream( StgIo& ); // set up an appropriate stream
76 void Close();
77 sal_Int32 GetSize() const;
78 bool SetSize( sal_Int32 );
79 sal_Int32 Seek( sal_Int32 );
80 sal_Int32 Read( void*, sal_Int32 );
81 sal_Int32 Write( const void*, sal_Int32 );
82 void Copy( BaseStorageStream& );
83};
84
85class StgDirStrm : public StgDataStrm
86{
87 friend class StgIterator;
88 StgDirEntry* m_pRoot; // root of dir tree
89 void SetupEntry( sal_Int32, StgDirEntry* );
90public:
91 explicit StgDirStrm( StgIo& );
92 virtual ~StgDirStrm() override;
93 virtual bool SetSize( sal_Int32 ) override; // change the size
94 bool Store();
95 void* GetEntry( sal_Int32 n, bool );// get an entry
97 static StgDirEntry* Find( StgDirEntry&, const OUString& );
98 StgDirEntry* Create( StgDirEntry&, const OUString&, StgEntryType );
99};
100
102{
103public:
104 explicit StgIterator( StgDirEntry& rStg ) : StgAvlIterator( rStg.m_pDown ) {}
105 StgDirEntry* First() { return static_cast<StgDirEntry*>( StgAvlIterator::First() ); }
106 StgDirEntry* Next() { return static_cast<StgDirEntry*>( StgAvlIterator::Next() ); }
107};
108
109#endif
110
111/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
StgAvlNode * First()
Definition: stgavl.cxx:400
StgAvlNode * Next()
Definition: stgavl.cxx:406
void Enum(sal_Int32 &)
Definition: stgdir.cxx:109
void RevertAll()
Definition: stgdir.cxx:228
bool m_bInvalid
Definition: stgdir.hxx:59
sal_Int32 m_nRefCnt
Definition: stgdir.hxx:54
void DelTemp(bool)
Definition: stgdir.cxx:135
void InitMembers()
Definition: stgdir.cxx:62
bool StoreStream(StgIo &)
Definition: stgdir.cxx:185
bool m_bDirect
Definition: stgdir.hxx:57
bool IsDirty()
Definition: stgdir.cxx:241
void Copy(BaseStorageStream &)
Definition: stgdir.cxx:491
bool m_bRemoved
Definition: stgdir.hxx:44
bool m_bZombie
Definition: stgdir.hxx:58
StreamMode m_nMode
Definition: stgdir.hxx:55
bool Store(StgDirStrm &)
Definition: stgdir.cxx:167
StgEntry m_aSave
Definition: stgdir.hxx:35
sal_Int32 Write(const void *, sal_Int32)
Definition: stgdir.cxx:455
bool m_bTemp
Definition: stgdir.hxx:56
void Close()
Definition: stgdir.cxx:278
StgEntry m_aEntry
Definition: stgdir.hxx:53
virtual ~StgDirEntry() override
Definition: stgdir.cxx:82
StgDirEntry * m_pDown
Definition: stgdir.hxx:37
bool SetSize(sal_Int32)
Definition: stgdir.cxx:301
StgTmpStrm * m_pCurStrm
Definition: stgdir.hxx:40
StgStrm * m_pStgStrm
Definition: stgdir.hxx:38
sal_Int32 Read(void *, sal_Int32)
Definition: stgdir.cxx:432
virtual sal_Int32 Compare(const StgAvlNode *) const override
Definition: stgdir.cxx:92
bool m_bDirty
Definition: stgdir.hxx:43
StgDirEntry(const void *pBuffer, sal_uInt32 nBufferLen, sal_uInt64 nUnderlyingStreamSize, bool *pbOk)
Definition: stgdir.cxx:48
StgTmpStrm * m_pTmpStrm
Definition: stgdir.hxx:39
StgDirEntry * m_pUp
Definition: stgdir.hxx:36
bool Commit()
Definition: stgdir.cxx:518
void Invalidate(bool)
Definition: stgdir.cxx:674
sal_Int32 m_nEntry
Definition: stgdir.hxx:41
sal_Int32 GetSize() const
Definition: stgdir.cxx:288
bool StoreStreams(StgIo &)
Definition: stgdir.cxx:210
bool Strm2Tmp()
Definition: stgdir.cxx:548
void SetDirty()
Definition: stgdir.hxx:70
sal_Int32 Seek(sal_Int32)
Definition: stgdir.cxx:387
sal_Int32 m_nPos
Definition: stgdir.hxx:42
void OpenStream(StgIo &)
Definition: stgdir.cxx:256
bool Tmp2Strm()
Definition: stgdir.cxx:611
bool Store()
Definition: stgdir.cxx:815
StgDirEntry * Create(StgDirEntry &, const OUString &, StgEntryType)
Definition: stgdir.cxx:901
void * GetEntry(sal_Int32 n, bool)
Definition: stgdir.cxx:876
StgDirStrm(StgIo &)
Definition: stgdir.cxx:698
void SetupEntry(sal_Int32, StgDirEntry *)
Definition: stgdir.cxx:731
virtual bool SetSize(sal_Int32) override
Definition: stgdir.cxx:803
virtual ~StgDirStrm() override
Definition: stgdir.cxx:724
StgDirEntry * GetRoot()
Definition: stgdir.hxx:96
static StgDirEntry * Find(StgDirEntry &, const OUString &)
Definition: stgdir.cxx:884
StgDirEntry * m_pRoot
Definition: stgdir.hxx:88
Definition: stgio.hxx:42
StgIterator(StgDirEntry &rStg)
Definition: stgdir.hxx:104
StgDirEntry * Next()
Definition: stgdir.hxx:106
StgDirEntry * First()
Definition: stgdir.hxx:105
StgEntryType
Definition: stgelem.hxx:85
StreamMode