32class FileStorageArea :
public ::std::enable_shared_from_this<::Core::FileStorageArea> {
40 enum class FlushableLevelDbEnvType :
int {
46 struct StorageAreaSpaceInfo {
58 StorageAreaSpaceInfo& operator=(StorageAreaSpaceInfo
const&);
59 StorageAreaSpaceInfo(StorageAreaSpaceInfo
const&);
60 StorageAreaSpaceInfo();
66 ::ll::TypedStorage<8, 80, ::std::recursive_mutex> mLock;
67 ::ll::TypedStorage<8, 24, ::std::vector<::Core::FileSystemImpl*>> mAllTransactions;
68 ::ll::TypedStorage<1, 1, bool> mCanAttemptExtendSave;
69 ::ll::TypedStorage<1, 1, bool> mCachedFileUsageSize;
70 ::ll::TypedStorage<8, 64, ::Core::FileStats> mTransactionStats;
71 ::ll::TypedStorage<8, 64, ::Core::FileStats> mTotalStats;
72 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::Core::FileStorageArea>> mParent;
73 ::ll::TypedStorage<4, 4, ::Core::FileAccessType> mAccessType;
74 ::ll::TypedStorage<8, 32, ::Core::PathBuffer<::std::string>> mRootPath;
75 ::ll::TypedStorage<8, 24, ::std::vector<::Core::FileSystemImpl*>> mWriteTransactions;
76 ::ll::TypedStorage<8, 32, ::Core::Subject<::Core::FileStorageAreaObserver, ::Core::SingleThreadedLock>> mSubject;
77 ::ll::TypedStorage<8, 144, ::Core::StorageAreaState> mState;
78 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mFileIOSuspended;
79 ::ll::TypedStorage<8, 88, ::std::condition_variable_any> mResumeSignal;
80 ::ll::TypedStorage<1, 1, bool> mLoggingEnabled;
81 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::Core::FlatFileManifestTracker>> mManifestTracker;
82 ::ll::TypedStorage<1, 1, bool> mIsAccessedDirectly;
92 virtual ~FileStorageArea();
94 virtual ::std::unique_ptr<::Core::FileSystemImpl> createTransaction(::Core::FileAccessType) = 0;
96 virtual ::std::unique_ptr<::Core::FileSystemImpl>
97 createTransaction(::Core::FileAccessType fileAccessType, ::Core::TransactionFlags);
99 virtual bool supportsSizeQuery()
const = 0;
101 virtual uint64 getTotalSize()
const = 0;
103 virtual ::Core::Result getUsedSize(uint64&) = 0;
105 virtual void setUsedSizeOverride(uint64);
107 virtual void clearUsedSizeOverride();
109 virtual void notifyChangeInFileSize(int64 changeInSize, int64 changeInAllocatedSize);
111 virtual bool handlesPendingWrites()
const;
113 virtual void informPendingWriteSize(uint64 numBytesWritePending,
bool const fromResourcePack);
115 virtual uint64 estimatePendingWriteDiskSize(uint64 rawFileSize)
const;
117 virtual void informStorageAreaCopy(uint64 storageAreaSize);
119 virtual bool supportsExtendSize()
const;
121 virtual bool canExtendSize()
const;
123 virtual void resetCanAttemptExtendSize();
125 virtual ::Core::Result getExtendSizeThreshold(uint64&)
const;
127 virtual void attemptExtendSize(int64
const& currentFreeSpace, ::std::function<
void()> onCompleteCallback);
129 virtual void preemptiveExtendSize(
130 uint64
const expectedContentSize,
131 ::std::function<
void()> successCallback,
132 ::std::function<
void()> failureCallback
135 virtual uint64 getAvailableUserStorageSize();
137 virtual void unloadFlatFileManifests(
bool shouldClearManifests);
141 virtual void flushImmediately();
143 virtual void enableFlushToDisk(
bool);
145 virtual void enableSequentialWrites(
bool);
147 virtual bool checkCorrupt(
bool handleCorruption);
149 virtual ::Bedrock::NonOwnerPointer<::Core::FileIndexLru> getFileIndexLru();
151 virtual ::Core::FileStorageArea::FlushableLevelDbEnvType getFlushableLevelDbEnvType()
const;
153 virtual uint64 getTransactionWriteSizeLimit()
const;
157 virtual bool shouldAllowCommit()
const;
159 virtual void trackBytesWritten(
::Core::PathView targetPath, uint64 amount, ::Core::WriteOperation writeOperation);
161 virtual void trackWriteOperation(
::Core::PathView targetPath, ::Core::WriteOperation writeOperation);
163 virtual ::Core::FileStorageArea::StorageAreaSpaceInfo getStorageAreaSpaceInfo();
165 virtual bool shouldRecordFileError(
::Core::PathView, ::std::error_code)
const;
167 virtual ::Core::Result _commit();
169 virtual ::Core::Result _onTransactionsEmpty(
bool fromChild);
171 virtual void _onTeardown();
177 MCAPI FileStorageArea(
178 ::Core::FileAccessType type,
181 bool isAccessedDirectly,
182 ::std::shared_ptr<::Core::FileStorageArea> parent
185 MCAPI
void _addReadOperation(
bool succeeded, uint64 numBytesRead);
187 MCAPI
void _addWriteOperation(
bool succeeded, uint64 numBytesWritten);
195 MCAPI
bool canWrite()
const;
197 MCAPI
void checkUserStorage();
205 MCAPI static ::Core::Result
206 _getStorageAreaForPathImpl(::std::shared_ptr<::Core::FileStorageArea>& fileStorageArea,
::Core::PathView path);
208 MCAPI_C static ::Core::Result
209 getStorageAreaForPath(::std::shared_ptr<::Core::FileStorageArea>& fileStorageArea,
::Core::PathView path);
216 sStorageAreaFileStats();
218 MCAPI static ::Core::StorageAreasTree& sStorageAreas();
225 ::Core::FileAccessType type,
228 bool isAccessedDirectly,
229 ::std::shared_ptr<::Core::FileStorageArea> parent
242 MCFOLD ::std::unique_ptr<::Core::FileSystemImpl>
243 $createTransaction(::Core::FileAccessType fileAccessType, ::Core::TransactionFlags);
245 MCFOLD
void $setUsedSizeOverride(uint64);
247 MCFOLD
void $clearUsedSizeOverride();
249 MCAPI
void $notifyChangeInFileSize(int64 changeInSize, int64 changeInAllocatedSize);
251 MCFOLD
bool $handlesPendingWrites()
const;
253 MCFOLD
void $informPendingWriteSize(uint64 numBytesWritePending,
bool const fromResourcePack);
255 MCFOLD uint64 $estimatePendingWriteDiskSize(uint64 rawFileSize)
const;
257 MCFOLD
void $informStorageAreaCopy(uint64 storageAreaSize);
259 MCFOLD
bool $supportsExtendSize()
const;
261 MCFOLD
bool $canExtendSize()
const;
263 MCAPI
void $resetCanAttemptExtendSize();
265 MCAPI ::Core::Result $getExtendSizeThreshold(uint64&)
const;
267 MCAPI
void $attemptExtendSize(int64
const& currentFreeSpace, ::std::function<
void()> onCompleteCallback);
269 MCAPI
void $preemptiveExtendSize(
270 uint64
const expectedContentSize,
271 ::std::function<
void()> successCallback,
272 ::std::function<
void()> failureCallback
275 MCAPI uint64 $getAvailableUserStorageSize();
277 MCAPI
void $unloadFlatFileManifests(
bool shouldClearManifests);
281 MCFOLD
void $flushImmediately();
283 MCFOLD
void $enableFlushToDisk(
bool);
285 MCFOLD
void $enableSequentialWrites(
bool);
287 MCFOLD
bool $checkCorrupt(
bool handleCorruption);
289 MCFOLD ::Bedrock::NonOwnerPointer<::Core::FileIndexLru> $getFileIndexLru();
291 MCFOLD ::Core::FileStorageArea::FlushableLevelDbEnvType $getFlushableLevelDbEnvType()
const;
293 MCFOLD uint64 $getTransactionWriteSizeLimit()
const;
297 MCAPI
bool $shouldAllowCommit()
const;
299 MCAPI
void $trackBytesWritten(
::Core::PathView targetPath, uint64 amount, ::Core::WriteOperation writeOperation);
301 MCAPI
void $trackWriteOperation(
::Core::PathView targetPath, ::Core::WriteOperation writeOperation);
303 MCAPI ::Core::FileStorageArea::StorageAreaSpaceInfo $getStorageAreaSpaceInfo();
305 MCFOLD
bool $shouldRecordFileError(
::Core::PathView, ::std::error_code)
const;
307 MCFOLD ::Core::Result $_commit();
309 MCFOLD ::Core::Result $_onTransactionsEmpty(
bool fromChild);
311 MCFOLD
void $_onTeardown();