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);
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 writeOperation);
160 virtual void trackWriteOperation(
::Core::PathView targetPath, ::Core::WriteOperation 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);
196 MCAPI
void checkUserStorage();
202 MCAPI static ::Core::Result
203 _getStorageAreaForPathImpl(::std::shared_ptr<::Core::FileStorageArea>& fileStorageArea,
::Core::PathView path);
206 MCAPI
static void tickStorageAreas();
214 sStorageAreaFileStats();
216 MCAPI static ::Core::StorageAreasTree& sStorageAreas();
223 ::Core::FileAccessType type,
226 bool isAccessedDirectly,
227 ::std::shared_ptr<::Core::FileStorageArea> parent
240 MCFOLD ::std::unique_ptr<::Core::FileSystemImpl>
241 $createTransaction(::Core::FileAccessType fileAccessType, ::Core::TransactionFlags);
243 MCFOLD
void $setUsedSizeOverride(uint64 fileSize);
245 MCFOLD
void $clearUsedSizeOverride();
247 MCAPI
void $notifyChangeInFileSize(int64 changeInSize, int64 changeInAllocatedSize);
249 MCFOLD
bool $handlesPendingWrites()
const;
251 MCFOLD
void $informPendingWriteSize(uint64,
bool const);
253 MCFOLD uint64 $estimatePendingWriteDiskSize(uint64 rawFileSize)
const;
255 MCFOLD
void $informStorageAreaCopy(uint64);
257 MCFOLD
bool $supportsExtendSize()
const;
259 MCFOLD
bool $canExtendSize()
const;
261 MCAPI
void $resetCanAttemptExtendSize();
263 MCAPI ::Core::Result $getExtendSizeThreshold(uint64& outExtendSizeThreshold)
const;
265 MCAPI
void $attemptExtendSize(int64
const& currentFreeSpace, ::std::function<
void()> onCompleteCallback);
267 MCAPI
void $preemptiveExtendSize(
268 uint64
const expectedContentSize,
269 ::std::function<
void()> successCallback,
270 ::std::function<
void()> failureCallback
273 MCAPI uint64 $getAvailableUserStorageSize();
275 MCAPI
void $unloadFlatFileManifests(
bool shouldClearManifests);
281 MCFOLD
void $enableFlushToDisk(
bool);
283 MCFOLD
void $enableSequentialWrites(
bool);
285 MCFOLD
bool $checkCorrupt(
bool);
287 MCFOLD ::Bedrock::NonOwnerPointer<::Core::FileIndexLru> $getFileIndexLru();
289 MCFOLD ::Core::FileStorageArea::FlushableLevelDbEnvType $getFlushableLevelDbEnvType()
const;
291 MCFOLD uint64 $getTransactionWriteSizeLimit()
const;
295 MCAPI
bool $shouldAllowCommit()
const;
297 MCAPI
void $trackBytesWritten(
::Core::PathView targetPath, uint64 amount, ::Core::WriteOperation writeOperation);
299 MCAPI
void $trackWriteOperation(
::Core::PathView targetPath, ::Core::WriteOperation writeOperation);
301 MCAPI ::Core::FileStorageArea::StorageAreaSpaceInfo $getStorageAreaSpaceInfo();
303 MCFOLD
bool $shouldRecordFileError(
::Core::PathView path, ::std::error_code error)
const;
305 MCFOLD ::Core::Result $_commit();
307 MCFOLD ::Core::Result $_onTransactionsEmpty(
bool);
309 MCFOLD
void $_onTeardown();