LeviLamina
Loading...
Searching...
No Matches
FileStorageArea.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/deps/core/file/FileAccessType.h"
7#include "mc/deps/core/file/FileStats.h"
8#include "mc/deps/core/file/PathBuffer.h"
9#include "mc/deps/core/file/StorageAreaState.h"
10#include "mc/deps/core/file/WriteOperation.h"
11#include "mc/deps/core/file/file_system/TransactionFlags.h"
12#include "mc/deps/core/threading/BasicLockbox.h"
13#include "mc/deps/core/utility/NonOwnerPointer.h"
14#include "mc/deps/core/utility/SingleThreadedLock.h"
15#include "mc/deps/core/utility/Subject.h"
16
17// auto generated forward declare list
18// clang-format off
19namespace Bedrock::Threading { class Mutex; }
20namespace Core { class FileIndexLru; }
21namespace Core { class FileStorageAreaObserver; }
22namespace Core { class FileSystemImpl; }
23namespace Core { class FlatFileManifestTracker; }
24namespace Core { class PathView; }
25namespace Core { class Result; }
26namespace Core { class StorageAreaStateListener; }
27namespace Core { class StorageAreasTree; }
28// clang-format on
29
30namespace Core {
31
32class FileStorageArea : public ::std::enable_shared_from_this<::Core::FileStorageArea> {
33public:
34 // FileStorageArea inner types declare
35 // clang-format off
37 // clang-format on
38
39 // FileStorageArea inner types define
40 enum class FlushableLevelDbEnvType : int {
41 None = 0,
42 InMemory = 1,
43 StorageArea = 2,
44 };
45
46 struct StorageAreaSpaceInfo {
47 public:
48 // member variables
49 // NOLINTBEGIN
54 // NOLINTEND
55
56 public:
57 // prevent constructor by default
58 StorageAreaSpaceInfo& operator=(StorageAreaSpaceInfo const&);
59 StorageAreaSpaceInfo(StorageAreaSpaceInfo const&);
60 StorageAreaSpaceInfo();
61 };
62
63public:
64 // member variables
65 // NOLINTBEGIN
66 ::ll::TypedStorage<8, 80, ::std::recursive_mutex> mLock;
67 ::ll::TypedStorage<8, 24, ::std::vector<::Core::FileSystemImpl*>> mAllTransactions;
68 ::ll::TypedStorage<1, 1, bool> mCanAttemptExtendSave;
69 ::ll::TypedStorage<1, 1, bool> mCachedFileUsageSize;
70 ::ll::TypedStorage<8, 64, ::Core::FileStats> mTransactionStats;
71 ::ll::TypedStorage<8, 64, ::Core::FileStats> mTotalStats;
72 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::Core::FileStorageArea>> mParent;
73 ::ll::TypedStorage<4, 4, ::Core::FileAccessType> mAccessType;
74 ::ll::TypedStorage<8, 32, ::Core::PathBuffer<::std::string>> mRootPath;
75 ::ll::TypedStorage<8, 24, ::std::vector<::Core::FileSystemImpl*>> mWriteTransactions;
76 ::ll::TypedStorage<8, 32, ::Core::Subject<::Core::FileStorageAreaObserver, ::Core::SingleThreadedLock>> mSubject;
77 ::ll::TypedStorage<8, 144, ::Core::StorageAreaState> mState;
78 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mFileIOSuspended;
79 ::ll::TypedStorage<8, 88, ::std::condition_variable_any> mResumeSignal;
80 ::ll::TypedStorage<1, 1, bool> mLoggingEnabled;
81 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::Core::FlatFileManifestTracker>> mManifestTracker;
82 ::ll::TypedStorage<1, 1, bool> mIsAccessedDirectly;
83 // NOLINTEND
84
85public:
86 // prevent constructor by default
87 FileStorageArea();
88
89public:
90 // virtual functions
91 // NOLINTBEGIN
92 virtual ~FileStorageArea();
93
94 virtual ::std::unique_ptr<::Core::FileSystemImpl> createTransaction(::Core::FileAccessType) = 0;
95
96 virtual ::std::unique_ptr<::Core::FileSystemImpl>
97 createTransaction(::Core::FileAccessType fileAccessType, ::Core::TransactionFlags);
98
99 virtual bool supportsSizeQuery() const = 0;
100
101 virtual uint64 getTotalSize() const = 0;
102
103 virtual ::Core::Result getUsedSize(uint64&) = 0;
104
105 virtual void setUsedSizeOverride(uint64);
106
107 virtual void clearUsedSizeOverride();
108
109 virtual void notifyChangeInFileSize(int64 changeInSize, int64 changeInAllocatedSize);
110
111 virtual bool handlesPendingWrites() const;
112
113 virtual void informPendingWriteSize(uint64 numBytesWritePending, bool const fromResourcePack);
114
115 virtual uint64 estimatePendingWriteDiskSize(uint64 rawFileSize) const;
116
117 virtual void informStorageAreaCopy(uint64 storageAreaSize);
118
119 virtual bool supportsExtendSize() const;
120
121 virtual bool canExtendSize() const;
122
123 virtual void resetCanAttemptExtendSize();
124
125 virtual ::Core::Result getExtendSizeThreshold(uint64&) const;
126
127 virtual void attemptExtendSize(int64 const& currentFreeSpace, ::std::function<void()> onCompleteCallback);
128
129 virtual void preemptiveExtendSize(
130 uint64 const expectedContentSize,
131 ::std::function<void()> successCallback,
132 ::std::function<void()> failureCallback
133 );
134
135 virtual uint64 getAvailableUserStorageSize();
136
137 virtual void unloadFlatFileManifests(bool shouldClearManifests);
138
139 virtual void tick();
140
141 virtual void flushImmediately();
142
143 virtual void enableFlushToDisk(bool);
144
145 virtual void enableSequentialWrites(bool);
146
147 virtual bool checkCorrupt(bool handleCorruption);
148
149 virtual ::Bedrock::NonOwnerPointer<::Core::FileIndexLru> getFileIndexLru();
150
151 virtual ::Core::FileStorageArea::FlushableLevelDbEnvType getFlushableLevelDbEnvType() const;
152
153 virtual uint64 getTransactionWriteSizeLimit() const;
154
155 virtual ::Core::Result setSaveDataIcon(::Core::PathView);
156
157 virtual bool shouldAllowCommit() const;
158
159 virtual void trackBytesWritten(::Core::PathView targetPath, uint64 amount, ::Core::WriteOperation writeOperation);
160
161 virtual void trackWriteOperation(::Core::PathView targetPath, ::Core::WriteOperation writeOperation);
162
163 virtual ::Core::FileStorageArea::StorageAreaSpaceInfo getStorageAreaSpaceInfo();
164
165 virtual bool shouldRecordFileError(::Core::PathView, ::std::error_code) const;
166
167 virtual ::Core::Result _commit();
168
169 virtual ::Core::Result _onTransactionsEmpty(bool fromChild);
170
171 virtual void _onTeardown();
172 // NOLINTEND
173
174public:
175 // member functions
176 // NOLINTBEGIN
177 MCAPI FileStorageArea(
178 ::Core::FileAccessType type,
179 ::Core::PathView rootPath,
180 bool usesFlatFiles,
181 bool isAccessedDirectly,
182 ::std::shared_ptr<::Core::FileStorageArea> parent
183 );
184
185 MCAPI void _addReadOperation(bool succeeded, uint64 numBytesRead);
186
187 MCAPI void _addWriteOperation(bool succeeded, uint64 numBytesWritten);
188
189 MCAPI void _beginTransaction(::Core::FileSystemImpl* pTransaction, bool fromChild);
190
191 MCAPI ::Core::Result _endTransaction(::Core::FileSystemImpl* pTransaction, bool fromChild);
192
193 MCAPI_C void addStateListener(::Core::StorageAreaStateListener* l);
194
195 MCAPI bool canWrite() const;
196
197 MCAPI void checkUserStorage();
198
199 MCAPI void removeStateListener(::Core::StorageAreaStateListener* l);
200 // NOLINTEND
201
202public:
203 // static functions
204 // NOLINTBEGIN
205 MCAPI static ::Core::Result
206 _getStorageAreaForPathImpl(::std::shared_ptr<::Core::FileStorageArea>& fileStorageArea, ::Core::PathView path);
207
208 MCAPI_C static ::Core::Result
209 getStorageAreaForPath(::std::shared_ptr<::Core::FileStorageArea>& fileStorageArea, ::Core::PathView path);
210 // NOLINTEND
211
212public:
213 // static variables
214 // NOLINTBEGIN
215 MCAPI static ::Bedrock::Threading::BasicLockbox<::std::vector<::Core::FileStats*>, ::Bedrock::Threading::Mutex>&
216 sStorageAreaFileStats();
217
218 MCAPI static ::Core::StorageAreasTree& sStorageAreas();
219 // NOLINTEND
220
221public:
222 // constructor thunks
223 // NOLINTBEGIN
224 MCAPI void* $ctor(
225 ::Core::FileAccessType type,
226 ::Core::PathView rootPath,
227 bool usesFlatFiles,
228 bool isAccessedDirectly,
229 ::std::shared_ptr<::Core::FileStorageArea> parent
230 );
231 // NOLINTEND
232
233public:
234 // destructor thunk
235 // NOLINTBEGIN
236 MCAPI void $dtor();
237 // NOLINTEND
238
239public:
240 // virtual function thunks
241 // NOLINTBEGIN
242 MCFOLD ::std::unique_ptr<::Core::FileSystemImpl>
243 $createTransaction(::Core::FileAccessType fileAccessType, ::Core::TransactionFlags);
244
245 MCFOLD void $setUsedSizeOverride(uint64);
246
247 MCFOLD void $clearUsedSizeOverride();
248
249 MCAPI void $notifyChangeInFileSize(int64 changeInSize, int64 changeInAllocatedSize);
250
251 MCFOLD bool $handlesPendingWrites() const;
252
253 MCFOLD void $informPendingWriteSize(uint64 numBytesWritePending, bool const fromResourcePack);
254
255 MCFOLD uint64 $estimatePendingWriteDiskSize(uint64 rawFileSize) const;
256
257 MCFOLD void $informStorageAreaCopy(uint64 storageAreaSize);
258
259 MCFOLD bool $supportsExtendSize() const;
260
261 MCFOLD bool $canExtendSize() const;
262
263 MCAPI void $resetCanAttemptExtendSize();
264
265 MCAPI ::Core::Result $getExtendSizeThreshold(uint64&) const;
266
267 MCAPI void $attemptExtendSize(int64 const& currentFreeSpace, ::std::function<void()> onCompleteCallback);
268
269 MCAPI void $preemptiveExtendSize(
270 uint64 const expectedContentSize,
271 ::std::function<void()> successCallback,
272 ::std::function<void()> failureCallback
273 );
274
275 MCAPI uint64 $getAvailableUserStorageSize();
276
277 MCAPI void $unloadFlatFileManifests(bool shouldClearManifests);
278
279 MCFOLD void $tick();
280
281 MCFOLD void $flushImmediately();
282
283 MCFOLD void $enableFlushToDisk(bool);
284
285 MCFOLD void $enableSequentialWrites(bool);
286
287 MCFOLD bool $checkCorrupt(bool handleCorruption);
288
289 MCFOLD ::Bedrock::NonOwnerPointer<::Core::FileIndexLru> $getFileIndexLru();
290
291 MCFOLD ::Core::FileStorageArea::FlushableLevelDbEnvType $getFlushableLevelDbEnvType() const;
292
293 MCFOLD uint64 $getTransactionWriteSizeLimit() const;
294
295 MCAPI ::Core::Result $setSaveDataIcon(::Core::PathView);
296
297 MCAPI bool $shouldAllowCommit() const;
298
299 MCAPI void $trackBytesWritten(::Core::PathView targetPath, uint64 amount, ::Core::WriteOperation writeOperation);
300
301 MCAPI void $trackWriteOperation(::Core::PathView targetPath, ::Core::WriteOperation writeOperation);
302
303 MCAPI ::Core::FileStorageArea::StorageAreaSpaceInfo $getStorageAreaSpaceInfo();
304
305 MCFOLD bool $shouldRecordFileError(::Core::PathView, ::std::error_code) const;
306
307 MCFOLD ::Core::Result $_commit();
308
309 MCFOLD ::Core::Result $_onTransactionsEmpty(bool fromChild);
310
311 MCFOLD void $_onTeardown();
312
313
314 // NOLINTEND
315
316public:
317 // vftables
318 // NOLINTBEGIN
319 MCNAPI static void** $vftable();
320 // NOLINTEND
321};
322
323} // namespace Core
Definition Mutex.h:10
Definition FileIndexLru.h:13
Definition FileStorageAreaObserver.h:16
static MCAPI void ** $vftable()
Definition FileSystemImpl.h:30
Definition FlatFileManifestTracker.h:13
Definition PathView.h:17
Definition Result.h:11
Definition StorageAreaStateListener.h:16
Definition StorageAreasTree.h:16
Definition FileStorageArea.h:46
Definition Alias.h:14