31class FileStorageArea :
public ::std::enable_shared_from_this<::Core::FileStorageArea> {
39 enum class FlushableLevelDbEnvType :
int {
45 struct StorageAreaSpaceInfo {
57 StorageAreaSpaceInfo& operator=(StorageAreaSpaceInfo
const&);
58 StorageAreaSpaceInfo(StorageAreaSpaceInfo
const&);
59 StorageAreaSpaceInfo();
65 ::ll::TypedStorage<8, 80, ::std::recursive_mutex> mLock;
66 ::ll::TypedStorage<8, 24, ::std::vector<::Core::FileSystemImpl*>> mAllTransactions;
67 ::ll::TypedStorage<1, 1, bool> mCanAttemptExtendSave;
68 ::ll::TypedStorage<1, 1, bool> mCachedFileUsageSize;
69 ::ll::TypedStorage<8, 64, ::Core::FileStats> mTransactionStats;
70 ::ll::TypedStorage<8, 64, ::Core::FileStats> mTotalStats;
71 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::Core::FileStorageArea>> mParent;
72 ::ll::TypedStorage<4, 4, ::Core::FileAccessType> mAccessType;
73 ::ll::TypedStorage<8, 32, ::Core::PathBuffer<::std::string>> mRootPath;
74 ::ll::TypedStorage<8, 24, ::std::vector<::Core::FileSystemImpl*>> mWriteTransactions;
75 ::ll::TypedStorage<8, 32, ::Core::Subject<::Core::FileStorageAreaObserver, ::Core::SingleThreadedLock>> mSubject;
76 ::ll::TypedStorage<8, 144, ::Core::StorageAreaState> mState;
77 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mFileIOSuspended;
78 ::ll::TypedStorage<8, 88, ::std::condition_variable_any> mResumeSignal;
79 ::ll::TypedStorage<1, 1, bool> mLoggingEnabled;
80 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::Core::FlatFileManifestTracker>> mManifestTracker;
81 ::ll::TypedStorage<1, 1, bool> mIsAccessedDirectly;
91 virtual ~FileStorageArea();
93 virtual ::std::unique_ptr<::Core::FileSystemImpl> createTransaction(::Core::FileAccessType accessType) = 0;
95 virtual ::std::unique_ptr<::Core::FileSystemImpl>
96 createTransaction(::Core::FileAccessType fileAccessType, ::Core::TransactionFlags);
98 virtual bool supportsSizeQuery()
const = 0;
100 virtual uint64 getTotalSize()
const = 0;
102 virtual ::Core::Result getUsedSize(uint64& outUsedSize) = 0;
104 virtual void setUsedSizeOverride(uint64 fileSize);
106 virtual void clearUsedSizeOverride();
108 virtual void notifyChangeInFileSize(int64 changeInSize, int64 changeInAllocatedSize);
110 virtual bool handlesPendingWrites()
const;
112 virtual void informPendingWriteSize(uint64,
bool const);
114 virtual uint64 estimatePendingWriteDiskSize(uint64 rawFileSize)
const;
116 virtual void informStorageAreaCopy(uint64);
118 virtual bool supportsExtendSize()
const;
120 virtual bool canExtendSize()
const;
122 virtual void resetCanAttemptExtendSize();
124 virtual ::Core::Result getExtendSizeThreshold(uint64& outExtendSizeThreshold)
const;
126 virtual void attemptExtendSize(int64
const& currentFreeSpace, ::std::function<
void()> onCompleteCallback);
128 virtual void preemptiveExtendSize(
129 uint64
const expectedContentSize,
130 ::std::function<
void()> successCallback,
131 ::std::function<
void()> failureCallback
134 virtual uint64 getAvailableUserStorageSize();
136 virtual void unloadFlatFileManifests(
bool shouldClearManifests);
140 virtual void flushImmediately();
142 virtual void enableFlushToDisk(
bool);
144 virtual void enableSequentialWrites(
bool);
146 virtual bool checkCorrupt(
bool);
148 virtual ::Bedrock::NonOwnerPointer<::Core::FileIndexLru> getFileIndexLru();
150 virtual ::Core::FileStorageArea::FlushableLevelDbEnvType getFlushableLevelDbEnvType()
const;
152 virtual uint64 getTransactionWriteSizeLimit()
const;
156 virtual bool shouldAllowCommit()
const;
158 virtual void trackBytesWritten(
::Core::PathView targetPath, uint64 amount, ::Core::WriteOperation);
160 virtual void trackWriteOperation(
::Core::PathView targetPath, ::Core::WriteOperation);
162 virtual ::Core::FileStorageArea::StorageAreaSpaceInfo getStorageAreaSpaceInfo();
164 virtual bool shouldRecordFileError(
::Core::PathView path, ::std::error_code error)
const;
166 virtual ::Core::Result _commit();
168 virtual ::Core::Result _onTransactionsEmpty(
bool);
170 virtual void _onTeardown();
176 MCAPI FileStorageArea(
177 ::Core::FileAccessType type,
180 bool isAccessedDirectly,
181 ::std::shared_ptr<::Core::FileStorageArea> parent
184 MCAPI
void _addReadOperation(
bool succeeded, uint64 numBytesRead);
186 MCAPI
void _addWriteOperation(
bool succeeded, uint64 numBytesWritten);
200 MCAPI
void checkUserStorage();
203 MCAPI uint64 getRestrictedMaximumFileSize()
const;
206 MCFOLD ::Core::PathBuffer<::std::string>
const& getRootPath()
const;
209 MCAPI
void setLoggingEnabled(
bool enabled);
211 MCAPI
bool supportsFlatFiles()
const;
218 MCAPI static ::Core::Result
219 _getStorageAreaForPathImpl(::std::shared_ptr<::Core::FileStorageArea>& fileStorageArea,
::Core::PathView path);
221 MCAPI static ::Core::Result
222 getStorageAreaForPath(::std::shared_ptr<::Core::FileStorageArea>& fileStorageArea,
::Core::PathView path);
225 MCAPI
static void getTotalBytesWrittenAndReadFromAllStorageAreas(uint64& outBytesWritten, uint64& outBytesRead);
228 MCAPI
static void teardown();
231 MCAPI
static void tickStorageAreas();
233 MCAPI static ::Core::Result unloadAllStorageAreaFlatFileManifests(
bool isInGame);
241 sStorageAreaFileStats();
243 MCAPI static ::Core::StorageAreasTree& sStorageAreas();
250 ::Core::FileAccessType type,
253 bool isAccessedDirectly,
254 ::std::shared_ptr<::Core::FileStorageArea> parent
267 MCFOLD ::std::unique_ptr<::Core::FileSystemImpl>
268 $createTransaction(::Core::FileAccessType fileAccessType, ::Core::TransactionFlags);
270 MCFOLD
void $setUsedSizeOverride(uint64 fileSize);
272 MCFOLD
void $clearUsedSizeOverride();
274 MCAPI
void $notifyChangeInFileSize(int64 changeInSize, int64 changeInAllocatedSize);
276 MCFOLD
bool $handlesPendingWrites()
const;
278 MCFOLD
void $informPendingWriteSize(uint64,
bool const);
280 MCFOLD uint64 $estimatePendingWriteDiskSize(uint64 rawFileSize)
const;
282 MCFOLD
void $informStorageAreaCopy(uint64);
284 MCFOLD
bool $supportsExtendSize()
const;
286 MCFOLD
bool $canExtendSize()
const;
288 MCAPI
void $resetCanAttemptExtendSize();
290 MCAPI ::Core::Result $getExtendSizeThreshold(uint64& outExtendSizeThreshold)
const;
292 MCAPI
void $attemptExtendSize(int64
const& currentFreeSpace, ::std::function<
void()> onCompleteCallback);
294 MCAPI
void $preemptiveExtendSize(
295 uint64
const expectedContentSize,
296 ::std::function<
void()> successCallback,
297 ::std::function<
void()> failureCallback
300 MCAPI uint64 $getAvailableUserStorageSize();
302 MCAPI
void $unloadFlatFileManifests(
bool shouldClearManifests);
306 MCFOLD
void $flushImmediately();
308 MCFOLD
void $enableFlushToDisk(
bool);
310 MCFOLD
void $enableSequentialWrites(
bool);
312 MCFOLD
bool $checkCorrupt(
bool);
314 MCFOLD ::Bedrock::NonOwnerPointer<::Core::FileIndexLru> $getFileIndexLru();
316 MCFOLD ::Core::FileStorageArea::FlushableLevelDbEnvType $getFlushableLevelDbEnvType()
const;
318 MCFOLD uint64 $getTransactionWriteSizeLimit()
const;
322 MCAPI
bool $shouldAllowCommit()
const;
324 MCAPI
void $trackBytesWritten(
::Core::PathView targetPath, uint64 amount, ::Core::WriteOperation);
326 MCAPI
void $trackWriteOperation(
::Core::PathView targetPath, ::Core::WriteOperation);
328 MCAPI ::Core::FileStorageArea::StorageAreaSpaceInfo $getStorageAreaSpaceInfo();
330 MCAPI
bool $shouldRecordFileError(
::Core::PathView path, ::std::error_code error)
const;
332 MCFOLD ::Core::Result $_commit();
334 MCFOLD ::Core::Result $_onTransactionsEmpty(
bool);
336 MCFOLD
void $_onTeardown();