Skip to content
LeviMC
English
AutoLightDark
LeviLamina
Loading...
Searching...
No Matches
FileSystem.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/deps/core/file/DirectoryIterationFlags.h"
7#include "mc/deps/core/file/FileBufferingMode.h"
8#include "mc/deps/core/file/PathBuffer.h"
9#include "mc/deps/core/string/BasicStackString.h"
10#include "mc/deps/core/utility/EnableNonOwnerReferences.h"
11#include "mc/platform/Result.h"
12#include "mc/platform/brstd/function_ref.h"
13
14// auto generated forward declare list
15// clang-format off
16namespace Core { class File; }
17namespace Core { class FileOpenMode; }
18namespace Core { class FileSizePresetToken; }
19namespace Core { class FileSystemImpl; }
20namespace Core { class PathView; }
21namespace Core { class Result; }
22namespace Core { struct DirectoryIterationItem; }
23namespace Core { struct ExcludedPath; }
24// clang-format on
25
26namespace Core {
27
29public:
30 // FileSystem inner types declare
31 // clang-format off
32 struct BasicFileData;
34 // clang-format on
35
36 // FileSystem inner types define
37 struct BasicFileData {
38 public:
39 // member variables
40 // NOLINTBEGIN
43 // NOLINTEND
44
45 public:
46 // prevent constructor by default
47 BasicFileData& operator=(BasicFileData const&);
48 BasicFileData(BasicFileData const&);
49 BasicFileData();
50 };
51
52 struct FileTransferProgress {
53 public:
54 // member variables
55 // NOLINTBEGIN
59 // NOLINTEND
60
61 public:
62 // prevent constructor by default
63 FileTransferProgress& operator=(FileTransferProgress const&);
64 FileTransferProgress(FileTransferProgress const&);
65 FileTransferProgress();
66 };
67
68public:
69 // virtual functions
70 // NOLINTBEGIN
71 virtual ::Core::Result openFile(
72 ::Core::PathView filePath,
73 ::Core::File& fileOut,
74 ::Core::FileOpenMode openMode,
75 ::Core::FileBufferingMode bufferingMode
76 ) = 0;
77
78 virtual bool fileExists(::Core::PathView filePath) = 0;
79
80 virtual ::Core::Result deleteFile(::Core::PathView filePath) = 0;
81
82 virtual ::Core::Result deleteFilePriority(::Core::PathView filePath) = 0;
83
84 virtual ::Core::Result getFileSize(::Core::PathView filePath, uint64* pFileSize) = 0;
85
86 virtual ::Core::Result renameFile(::Core::PathView sourceName, ::Core::PathView targetName) = 0;
87
88 virtual ::Core::Result createEmptyFile(::Core::PathView filePath) = 0;
89
90 virtual ::Core::Result copyFile(::Core::PathView sourceFileName, ::Core::PathView targetFileName) = 0;
91
92 virtual ::Core::Result copyFileWithLimit(::Core::PathView sourceFilePath, ::Core::PathView targetFilePath) = 0;
93
94 virtual ::Core::Result readFileData(::Core::PathView filePath, ::std::vector<uchar>& data) = 0;
95
96 virtual ::Bedrock::Result<::std::string> readFile(::Core::PathView filePath) = 0;
97
98 virtual ::Bedrock::Result<void> writeFile(::Core::PathView filePath, ::std::string_view data) = 0;
99
100 virtual ::Core::Result createOneDirectory(::Core::PathView directoryPath) = 0;
101
102 virtual ::Core::Result createOneDirectoryIfNotExisting(::Core::PathView dirName) = 0;
103
104 virtual ::Core::Result createDirectoryRecursively(::Core::PathView dirName) = 0;
105
106 virtual bool directoryExists(::Core::PathView dirName) = 0;
107
108 virtual ::Core::Result deleteEmptyDirectory(::Core::PathView dirPath) = 0;
109
110 virtual ::Core::Result deleteEmptyDirectoryRecursively(::Core::PathView dirPath) = 0;
111
112 virtual ::Core::Result deleteDirectoryAndContentsRecursively(::Core::PathView dirName) = 0;
113
114 virtual ::Core::Result deleteDirectoryContentsRecursively(::Core::PathView directoryName) = 0;
115
116 virtual ::Core::Result renameDirectory(::Core::PathView oldDirectoryName, ::Core::PathView newDirectoryName) = 0;
117
118 virtual ::Core::Result iterateOverDirectory(
119 ::Core::PathView dirName,
120 ::Core::DirectoryIterationFlags flags,
122 ) = 0;
123
124 virtual ::Core::Result
125 getDirectoryFiles(::std::vector<::Core::PathBuffer<::std::string>>& files, ::Core::PathView path) = 0;
126
127 virtual ::Core::Result getDirectoryFilesAndSizes(
128 ::std::vector<::Core::FileSystem::BasicFileData>& filesOut,
129 ::Core::PathView directoryPath
130 ) = 0;
131
132 virtual ::Core::Result getDirectoryFilesRecursively(
133 ::std::vector<::Core::PathBuffer<::std::string>>& files,
134 ::Core::PathView directoryPath
135 ) = 0;
136
137 virtual ::Core::Result getDirectoryFilesSizeRecursively(uint64& totalSize, ::Core::PathView directoryPath) = 0;
138
139 virtual ::Core::Result getDirectoryFilesAllocatedSizeRecursively(
140 uint64& totalSize,
141 uint64& totalAllocatedSize,
142 ::Core::PathView directoryPath
143 ) = 0;
144
145 virtual ::Core::Result copyDirectoryAndContentsRecursively(::Core::PathView from, ::Core::PathView to) = 0;
146
147 virtual ::Core::Result copyDirectoryAndContentsRecursivelyWithLimit(::Core::PathView from, ::Core::PathView to) = 0;
148
149 virtual bool isDirectoryPartiallyCopied(::Core::PathView directory) = 0;
150
151 virtual bool fileOrDirectoryExists(::Core::PathView fileOrDirectoryName) = 0;
152
153 virtual ::Core::Result getFileOrDirectorySize(::Core::PathView path, uint64* pFileSizeOut) = 0;
154
155 virtual ::Core::Result addIgnoredThrottlePath(::Core::PathView path) = 0;
156
157 virtual ::Core::Result removeIgnoredThrottlePath(::Core::PathView path) = 0;
158
159 virtual ::Core::Result isValidPath(::Core::PathView path) = 0;
160
161 virtual ::Core::Result getLastModificationTime(::Core::PathView filePath, int64* pLastModificationTime) = 0;
162
163 virtual ::Core::Result
164 copyTimeAndAccessRights(::Core::PathView sourceFilePath, ::Core::PathView targetFilePath) = 0;
165
166 virtual ::Core::Result
167 createFlatFile(::Core::PathView sourceDirectoryPath, ::Core::PathView targetDirectoryPath) = 0;
168
169 virtual bool isDirectoryPathAFlatFile(::Core::PathView directoryPath) = 0;
170
171 virtual ::Core::Result copyFlatFile(
172 ::Core::PathView flatFileParentDirectory,
173 ::Core::PathView targetDirectory,
174 ::std::vector<::Core::ExcludedPath> const& excludedDirectories,
175 ::std::vector<::Core::ExcludedPath> const& excludedFiles
176 ) = 0;
177
178 virtual ::Core::Result createDirectoryForFile(::Core::PathView filePath) = 0;
179
180 virtual ::Core::PathBuffer<::Core::BasicStackString<char, 1024>>
181 getUniqueFilePathForFile(::Core::PathView filePath) = 0;
182
183 virtual ::Core::PathBuffer<::Core::BasicStackString<char, 1024>>
184 getUniqueFilePathForDirectory(::Core::PathView directoryPath) = 0;
185
186 virtual ::Core::PathBuffer<::Core::BasicStackString<char, 1024>>
187 createUniquePathFromSeed(::Core::PathView basePath, ::std::function<::std::string(int)> seedGenerator) = 0;
188
189 virtual ::std::vector<::Core::PathBuffer<::std::string>> splitPathIntoFullPathSegments(::Core::PathView path) = 0;
190
191 virtual ::Core::Result readFileDataExt(
192 ::Core::PathView filePath,
193 uint64 filePosition,
194 uint64 bufferSize,
195 ::std::vector<uchar>& buffer,
196 uint64& bytesRead
197 ) = 0;
198
199 virtual ::Core::Result cleanPath_deprecated(
201 ::Core::PathView pathIn
202 ) = 0;
203
204 virtual ::Core::Result cleanPathSeparators_deprecated(
206 ::Core::PathView pathIn
207 ) = 0;
208
209 virtual bool checkStorageCorrupt(::Core::PathView path) = 0;
210
211 virtual ::std::unique_ptr<::Core::FileSizePresetToken>
212 presetFileInitialSize(::Core::PathView path, uint64 initialSize) = 0;
213
214 virtual ::Core::Result _getDirectoriesAndFileSizesRecursively(
215 ::Core::PathView directoryPath,
216 ::std::vector<::Core::PathBuffer<::std::string>>& directoriesOut,
217 ::std::vector<::Core::FileSystem::BasicFileData>& filesOut
218 ) = 0;
219
220 virtual ::Core::Result _copyDirectoryStructure(
221 ::Core::PathView from,
223 ::std::vector<::Core::PathBuffer<::std::string>> const& directories,
224 ::Core::FileSystemImpl* transaction
225 ) = 0;
226
227 virtual ::Core::Result _copyFilesWithLimit(
228 ::Core::PathView from,
230 ::std::vector<::Core::FileSystem::BasicFileData>& files,
231 uint64& currentFileBytesWritten,
232 uint64 const transactionLimit,
233 ::std::function<
235 fileTransferFunction
236 ) = 0;
237
238 virtual ::Core::Result _copyFlatFile(
239 ::Core::PathView flatFileParentDirectory,
240 ::Core::PathView targetDirectory,
241 ::std::vector<::Core::ExcludedPath> const& excludedDirectories,
242 ::std::vector<::Core::ExcludedPath> const& excludedFiles
243 ) = 0;
244
245 virtual ::std::optional<uint64> _checkFileInitialSize(::Core::PathView path) = 0;
246 // NOLINTEND
247
248public:
249 // static functions
250 // NOLINTBEGIN
251 MCNAPI static ::Core::FileSystem& get();
252 // NOLINTEND
253};
254
255} // namespace Core
Definition EnableNonOwnerReferences.h:7
Definition BasicStackString.h:8
Definition FileOpenMode.h:7
Definition FileSizePresetToken.h:7
Definition FileSystemImpl.h:30
Definition FileSystem.h:28
static MCAPI ::Core::FileSystem & get()
Definition File.h:20
Definition PathBuffer.h:8
Definition PathView.h:19
Definition Result.h:11
Definition function_ref.h:60
Definition DirectoryIterationItem.h:12
Definition ExcludedPath.h:7
Definition FileSystem.h:37
Definition FileSystem.h:52
Definition buffer.h:5
Definition Alias.h:14