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