30class FileStorageArea :
public ::std::enable_shared_from_this<::Core::FileStorageArea> {
38 enum class FlushableLevelDbEnvType :
int {
44 struct StorageAreaSpaceInfo {
56 StorageAreaSpaceInfo& operator=(StorageAreaSpaceInfo
const&);
57 StorageAreaSpaceInfo(StorageAreaSpaceInfo
const&);
58 StorageAreaSpaceInfo();
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;
90 virtual ~FileStorageArea();
92 virtual ::std::unique_ptr<::Core::FileSystemImpl> createTransaction(::Core::FileAccessType accessType) = 0;
94 virtual ::std::unique_ptr<::Core::FileSystemImpl>
95 createTransaction(::Core::FileAccessType fileAccessType, ::Core::TransactionFlags);
97 virtual bool supportsSizeQuery()
const = 0;
99 virtual uint64 getTotalSize()
const = 0;
101 virtual ::Core::Result getUsedSize(uint64& outUsedSize) = 0;
103 virtual void setUsedSizeOverride(uint64 fileSize);
105 virtual void clearUsedSizeOverride();
107 virtual void notifyChangeInFileSize(int64 changeInSize, int64 changeInAllocatedSize);
109 virtual bool handlesPendingWrites()
const;
111 virtual void informPendingWriteSize(uint64,
bool const);
113 virtual uint64 estimatePendingWriteDiskSize(uint64 rawFileSize)
const;
115 virtual void informStorageAreaCopy(uint64);
117 virtual bool supportsExtendSize()
const;
119 virtual bool canExtendSize()
const;
121 virtual void resetCanAttemptExtendSize();
123 virtual ::Core::Result getExtendSizeThreshold(uint64& outExtendSizeThreshold)
const;
125 virtual void attemptExtendSize(int64
const& currentFreeSpace, ::std::function<
void()> onCompleteCallback);
127 virtual void preemptiveExtendSize(
128 uint64
const expectedContentSize,
129 ::std::function<
void()> successCallback,
130 ::std::function<
void()> failureCallback
133 virtual uint64 getAvailableUserStorageSize();
135 virtual void unloadFlatFileManifests(
bool shouldClearManifests);
141 virtual void enableFlushToDisk(
bool);
143 virtual void enableSequentialWrites(
bool);
145 virtual bool checkCorrupt(
bool);
147 virtual ::Bedrock::NonOwnerPointer<::Core::FileIndexLru> getFileIndexLru();
149 virtual ::Core::FileStorageArea::FlushableLevelDbEnvType getFlushableLevelDbEnvType()
const;
151 virtual uint64 getTransactionWriteSizeLimit()
const;
155 virtual bool shouldAllowCommit()
const;
157 virtual void trackBytesWritten(
::Core::PathView targetPath, uint64 amount, ::Core::WriteOperation writeOperation);
159 virtual void trackWriteOperation(
::Core::PathView targetPath, ::Core::WriteOperation writeOperation);
161 virtual ::Core::FileStorageArea::StorageAreaSpaceInfo getStorageAreaSpaceInfo();
163 virtual bool shouldRecordFileError(
::Core::PathView path, ::std::error_code error)
const;
165 virtual ::Core::Result _commit();
167 virtual ::Core::Result _onTransactionsEmpty(
bool);
169 virtual void _onTeardown();
175 MCAPI FileStorageArea(
176 ::Core::FileAccessType type,
179 bool isAccessedDirectly,
180 ::std::shared_ptr<::Core::FileStorageArea> parent
183 MCAPI
void _addReadOperation(
bool succeeded, uint64 numBytesRead);
185 MCAPI
void _addWriteOperation(
bool succeeded, uint64 numBytesWritten);
195 MCAPI
void checkUserStorage();
201 MCAPI static ::Core::Result
202 _getStorageAreaForPathImpl(::std::shared_ptr<::Core::FileStorageArea>& fileStorageArea,
::Core::PathView path);
205 MCAPI
static void tickStorageAreas();
212 MCAPI static ::Bedrock::Threading::BasicLockbox<::std::vector<::Core::FileStats*>, ::std::mutex>&
213 sStorageAreaFileStats();
215 MCAPI static ::Core::StorageAreasTree& sStorageAreas();
222 ::Core::FileAccessType type,
225 bool isAccessedDirectly,
226 ::std::shared_ptr<::Core::FileStorageArea> parent
239 MCFOLD ::std::unique_ptr<::Core::FileSystemImpl>
240 $createTransaction(::Core::FileAccessType fileAccessType, ::Core::TransactionFlags);
242 MCFOLD
void $setUsedSizeOverride(uint64 fileSize);
244 MCFOLD
void $clearUsedSizeOverride();
246 MCAPI
void $notifyChangeInFileSize(int64 changeInSize, int64 changeInAllocatedSize);
248 MCFOLD
bool $handlesPendingWrites()
const;
250 MCFOLD
void $informPendingWriteSize(uint64,
bool const);
252 MCFOLD uint64 $estimatePendingWriteDiskSize(uint64 rawFileSize)
const;
254 MCFOLD
void $informStorageAreaCopy(uint64);
256 MCFOLD
bool $supportsExtendSize()
const;
258 MCFOLD
bool $canExtendSize()
const;
260 MCAPI
void $resetCanAttemptExtendSize();
262 MCAPI ::Core::Result $getExtendSizeThreshold(uint64& outExtendSizeThreshold)
const;
264 MCAPI
void $attemptExtendSize(int64
const& currentFreeSpace, ::std::function<
void()> onCompleteCallback);
266 MCAPI
void $preemptiveExtendSize(
267 uint64
const expectedContentSize,
268 ::std::function<
void()> successCallback,
269 ::std::function<
void()> failureCallback
272 MCAPI uint64 $getAvailableUserStorageSize();
274 MCAPI
void $unloadFlatFileManifests(
bool shouldClearManifests);
280 MCFOLD
void $enableFlushToDisk(
bool);
282 MCFOLD
void $enableSequentialWrites(
bool);
284 MCFOLD
bool $checkCorrupt(
bool);
286 MCFOLD ::Bedrock::NonOwnerPointer<::Core::FileIndexLru> $getFileIndexLru();
288 MCFOLD ::Core::FileStorageArea::FlushableLevelDbEnvType $getFlushableLevelDbEnvType()
const;
290 MCFOLD uint64 $getTransactionWriteSizeLimit()
const;
294 MCAPI
bool $shouldAllowCommit()
const;
296 MCAPI
void $trackBytesWritten(
::Core::PathView targetPath, uint64 amount, ::Core::WriteOperation writeOperation);
298 MCAPI
void $trackWriteOperation(
::Core::PathView targetPath, ::Core::WriteOperation writeOperation);
300 MCAPI ::Core::FileStorageArea::StorageAreaSpaceInfo $getStorageAreaSpaceInfo();
302 MCFOLD
bool $shouldRecordFileError(
::Core::PathView path, ::std::error_code error)
const;
304 MCFOLD ::Core::Result $_commit();
306 MCFOLD ::Core::Result $_onTransactionsEmpty(
bool);
308 MCFOLD
void $_onTeardown();