Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sot / source / sdstor / stgdir.hxx
blob3605c27ac03d46db57dfb39578cf21f4e1a4528b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SOT_SOURCE_SDSTOR_STGDIR_HXX
21 #define INCLUDED_SOT_SOURCE_SDSTOR_STGDIR_HXX
23 #include "stgavl.hxx"
24 #include "stgelem.hxx"
25 #include "stgstrms.hxx"
27 class StgIo;
28 class StgDirStrm;
30 class BaseStorageStream;
31 class StgDirEntry : public StgAvlNode
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
52 public:
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;
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
70 void SetDirty() { m_bDirty = true; }
71 bool IsDirty();
73 bool Commit();
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& );
85 class StgDirStrm : public StgDataStrm
87 friend class StgIterator;
88 StgDirEntry* m_pRoot; // root of dir tree
89 void SetupEntry( sal_Int32, StgDirEntry* );
90 public:
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
96 StgDirEntry* GetRoot() { return m_pRoot; }
97 static StgDirEntry* Find( StgDirEntry&, const OUString& );
98 StgDirEntry* Create( StgDirEntry&, const OUString&, StgEntryType );
101 class StgIterator : public StgAvlIterator
103 public:
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() ); }
109 #endif
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */