Skip to content
LeviMC
English
AutoLightDark
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
176 ::Core::FileAccessType type,
177 ::Core::PathView rootPath,
178 bool usesFlatFiles,
179 bool isAccessedDirectly,
180 ::std::shared_ptr<::Core::FileStorageArea> parent
181 );
182
183 MCNAPI void _addReadOperation(bool succeeded, uint64 numBytesRead);
184
185 MCNAPI void _addWriteOperation(bool succeeded, uint64 numBytesWritten);
186
187 MCNAPI void _beginTransaction(::Core::FileSystemImpl* pTransaction, bool);
188
189 MCNAPI ::Core::Result _endTransaction(::Core::FileSystemImpl* pTransaction, bool fromChild);
190
191#ifdef LL_PLAT_C
192 MCNAPI void addObserver(::Core::FileStorageAreaObserver& observer);
193#endif
194
195 MCNAPI void checkUserStorage();
196 // NOLINTEND
197
198public:
199 // static functions
200 // NOLINTBEGIN
201 MCNAPI static ::Core::Result
202 _getStorageAreaForPathImpl(::std::shared_ptr<::Core::FileStorageArea>& fileStorageArea, ::Core::PathView path);
203
204#ifdef LL_PLAT_C
205 MCNAPI static void tickStorageAreas();
206#endif
207 // NOLINTEND
208
209public:
210 // static variables
211 // NOLINTBEGIN
212 MCNAPI static ::Bedrock::Threading::BasicLockbox<::std::vector<::Core::FileStats*>, ::std::mutex>&
214
215 MCNAPI static ::Core::StorageAreasTree& sStorageAreas();
216 // NOLINTEND
217
218public:
219 // constructor thunks
220 // NOLINTBEGIN
221 MCNAPI 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 MCNAPI void $dtor();
234 // NOLINTEND
235
236public:
237 // virtual function thunks
238 // NOLINTBEGIN
239 MCNAPI ::std::unique_ptr<::Core::FileSystemImpl>
240 $createTransaction(::Core::FileAccessType fileAccessType, ::Core::TransactionFlags);
241
242 MCNAPI void $setUsedSizeOverride(uint64 fileSize);
243
245
246 MCNAPI void $notifyChangeInFileSize(int64 changeInSize, int64 changeInAllocatedSize);
247
248 MCNAPI bool $handlesPendingWrites() const;
249
250 MCNAPI void $informPendingWriteSize(uint64, bool const);
251
252 MCNAPI uint64 $estimatePendingWriteDiskSize(uint64 rawFileSize) const;
253
254 MCNAPI void $informStorageAreaCopy(uint64);
255
256 MCNAPI bool $supportsExtendSize() const;
257
258 MCNAPI bool $canExtendSize() const;
259
261
262 MCNAPI ::Core::Result $getExtendSizeThreshold(uint64& outExtendSizeThreshold) const;
263
264 MCNAPI void $attemptExtendSize(int64 const& currentFreeSpace, ::std::function<void()> onCompleteCallback);
265
267 uint64 const expectedContentSize,
268 ::std::function<void()> successCallback,
269 ::std::function<void()> failureCallback
270 );
271
273
274 MCNAPI void $unloadFlatFileManifests(bool shouldClearManifests);
275
276 MCNAPI void $tick();
277
278 MCNAPI void $flushImmediately(::Core::PathView flushPath);
279
280 MCNAPI void $enableFlushToDisk(bool);
281
282 MCNAPI void $enableSequentialWrites(bool);
283
284 MCNAPI bool $checkCorrupt(bool);
285
286 MCNAPI ::Bedrock::NonOwnerPointer<::Core::FileIndexLru> $getFileIndexLru();
287
288 MCNAPI ::Core::FileStorageArea::FlushableLevelDbEnvType $getFlushableLevelDbEnvType() const;
289
290 MCNAPI uint64 $getTransactionWriteSizeLimit() const;
291
292 MCNAPI ::Core::Result $setSaveDataIcon(::Core::PathView);
293
294 MCNAPI bool $shouldAllowCommit() const;
295
296 MCNAPI void $trackBytesWritten(::Core::PathView targetPath, uint64 amount, ::Core::WriteOperation writeOperation);
297
298 MCNAPI void $trackWriteOperation(::Core::PathView targetPath, ::Core::WriteOperation writeOperation);
299
300 MCNAPI ::Core::FileStorageArea::StorageAreaSpaceInfo $getStorageAreaSpaceInfo();
301
302 MCNAPI bool $shouldRecordFileError(::Core::PathView path, ::std::error_code error) const;
303
304 MCNAPI ::Core::Result $_commit();
305
306 MCNAPI ::Core::Result $_onTransactionsEmpty(bool);
307
308 MCNAPI void $_onTeardown();
309
310
311 // NOLINTEND
312};
313
314} // namespace Core
Definition FileIndexLru.h:13
Definition FileStorageAreaObserver.h:7
MCAPI::Core::Result $setSaveDataIcon(::Core::PathView)
MCAPI void _addWriteOperation(bool succeeded, uint64 numBytesWritten)
MCAPI void $_onTeardown()
MCAPI void $trackWriteOperation(::Core::PathView targetPath, ::Core::WriteOperation writeOperation)
MCAPI void $clearUsedSizeOverride()
MCAPI::Core::FileStorageArea::StorageAreaSpaceInfo $getStorageAreaSpaceInfo()
static MCAPI ::Bedrock::Threading::BasicLockbox<::std::vector<::Core::FileStats * >, ::std::mutex > & sStorageAreaFileStats()
MCAPI ::Bedrock::NonOwnerPointer<::Core::FileIndexLru > $getFileIndexLru()
MCAPI uint64 $getAvailableUserStorageSize()
MCAPI void $preemptiveExtendSize(uint64 const expectedContentSize, ::std::function< void()> successCallback, ::std::function< void()> failureCallback)
MCAPI bool $shouldAllowCommit() const
MCAPI::Core::FileStorageArea::FlushableLevelDbEnvType $getFlushableLevelDbEnvType() const
MCAPI void $attemptExtendSize(int64 const &currentFreeSpace, ::std::function< void()> onCompleteCallback)
MCAPI::Core::Result _endTransaction(::Core::FileSystemImpl *pTransaction, bool fromChild)
MCAPI bool $canExtendSize() const
MCAPI::Core::Result $_commit()
MCAPI void $enableFlushToDisk(bool)
MCAPI void $trackBytesWritten(::Core::PathView targetPath, uint64 amount, ::Core::WriteOperation writeOperation)
static MCAPI ::Core::StorageAreasTree & sStorageAreas()
MCAPI::Core::Result $_onTransactionsEmpty(bool)
MCAPI uint64 $estimatePendingWriteDiskSize(uint64 rawFileSize) const
MCAPI bool $handlesPendingWrites() const
MCAPI::Core::Result $getExtendSizeThreshold(uint64 &outExtendSizeThreshold) const
MCAPI void $notifyChangeInFileSize(int64 changeInSize, int64 changeInAllocatedSize)
MCAPI FileStorageArea(::Core::FileAccessType type, ::Core::PathView rootPath, bool usesFlatFiles, bool isAccessedDirectly, ::std::shared_ptr<::Core::FileStorageArea > parent)
MCAPI void $informPendingWriteSize(uint64, bool const)
MCAPI void $setUsedSizeOverride(uint64 fileSize)
MCAPI void * $ctor(::Core::FileAccessType type, ::Core::PathView rootPath, bool usesFlatFiles, bool isAccessedDirectly, ::std::shared_ptr<::Core::FileStorageArea > parent)
MCAPI bool $shouldRecordFileError(::Core::PathView path, ::std::error_code error) const
MCAPI void _addReadOperation(bool succeeded, uint64 numBytesRead)
MCAPI bool $checkCorrupt(bool)
MCAPI void $resetCanAttemptExtendSize()
MCAPI void $enableSequentialWrites(bool)
MCAPI uint64 $getTransactionWriteSizeLimit() const
MCAPI void $unloadFlatFileManifests(bool shouldClearManifests)
MCAPI void checkUserStorage()
MCAPI ::std::unique_ptr<::Core::FileSystemImpl > $createTransaction(::Core::FileAccessType fileAccessType, ::Core::TransactionFlags)
static MCAPI ::Core::Result _getStorageAreaForPathImpl(::std::shared_ptr<::Core::FileStorageArea > &fileStorageArea, ::Core::PathView path)
MCAPI void _beginTransaction(::Core::FileSystemImpl *pTransaction, bool)
MCAPI void $flushImmediately(::Core::PathView flushPath)
MCAPI void $informStorageAreaCopy(uint64)
MCAPI bool $supportsExtendSize() const
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