LeviLamina
Loading...
Searching...
No Matches
FileArchiver.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/deps/core/file/PathBuffer.h"
7#include "mc/deps/core/file/ZipProgress.h"
8#include "mc/deps/core/string/BasicStackString.h"
9#include "mc/deps/core/threading/Async.h"
10#include "mc/deps/core/utility/EnableNonOwnerReferences.h"
11#include "mc/deps/core/utility/NonOwnerPointer.h"
12#include "mc/deps/core/utility/UniqueOwnerPointer.h"
13#include "mc/deps/core/utility/pub_sub/Publisher.h"
14#include "mc/platform/threading/Mutex.h"
15#include "mc/world/level/FileArchiverOutcome.h"
16
17// auto generated forward declare list
18// clang-format off
21class ILevelListCache;
23class Level;
24class LevelData;
25class LevelDbEnv;
26class LevelStorage;
27class PackInstance;
28class Scheduler;
29class TaskGroup;
30namespace Bedrock::PubSub::ThreadModel { struct MultiThreaded; }
31namespace Core { class FilePathManager; }
32namespace Core { class Path; }
33// clang-format on
34
35class FileArchiver : public ::Bedrock::EnableNonOwnerReferences {
36public:
37 // FileArchiver inner types declare
38 // clang-format off
39 struct CopyWorldResult;
40 struct EduCloudImportInfo;
41 struct ImportWorldsResult;
42 class ProgressReporter;
43 struct Result;
44 struct ExportData;
45 class IWorldConverter;
47 // clang-format on
48
49 // FileArchiver inner types define
50 enum class ExportType : int {
51 Level = 0,
52 Template = 1,
53 Project = 2,
54 PlayableEditorLevel = 3,
55 PackagedLevel = 4,
56 };
57
58 enum class ShowToast : int {
59 Enabled = 0,
60 Disabled = 1,
61 };
62
63 enum class State : int {
64 Idle = 0,
65 Importing = 1,
66 Exporting = 2,
67 };
68
70 public:
71 // member variables
72 // NOLINTBEGIN
73 ::ll::TypedStorage<4, 4, ::FileArchiverOutcome> outcome;
74 ::ll::TypedStorage<8, 32, ::std::string> copiedLevelId;
75 ::ll::TypedStorage<8, 32, ::Core::PathBuffer<::std::string>> copiedLevelPath;
76 // NOLINTEND
77
78 public:
79 // member functions
80 // NOLINTBEGIN
81
82 // NOLINTEND
83
84 public:
85 // destructor thunk
86 // NOLINTBEGIN
87 MCFOLD_C void $dtor();
88 // NOLINTEND
89 };
90
92 public:
93 // member variables
94 // NOLINTBEGIN
95 ::ll::TypedStorage<1, 1, bool> isCloudImport;
96 ::ll::TypedStorage<1, 1, bool> allowMultiplayer;
97 ::ll::TypedStorage<8, 32, ::std::string> educationOid;
98 ::ll::TypedStorage<8, 32, ::std::string> cTag;
99 ::ll::TypedStorage<8, 32, ::std::string> name;
100 // NOLINTEND
101
102 public:
103 // member functions
104 // NOLINTBEGIN
105 MCAPI ~EduCloudImportInfo();
106 // NOLINTEND
107
108 public:
109 // destructor thunk
110 // NOLINTBEGIN
111 MCFOLD void $dtor();
112 // NOLINTEND
113 };
114
116 public:
117 // ImportWorldsResult inner types declare
118 // clang-format off
119 struct ImportWorldResult;
120 // clang-format on
121
122 // ImportWorldsResult inner types define
124 public:
125 // member variables
126 // NOLINTBEGIN
127 ::ll::TypedStorage<4, 4, ::FileArchiverOutcome> outcome;
128 ::ll::TypedStorage<8, 32, ::Core::PathBuffer<::std::string>> path;
129 // NOLINTEND
130 };
131
132 public:
133 // member variables
134 // NOLINTBEGIN
135 ::ll::TypedStorage<4, 4, ::FileArchiverOutcome> outcome;
136 ::ll::TypedStorage<8, 24, ::std::vector<::FileArchiver::ImportWorldsResult::ImportWorldResult>> worlds;
137 // NOLINTEND
138 };
139
141 public:
142 // member variables
143 // NOLINTBEGIN
144 ::ll::TypedStorage<8, 80, ::Bedrock::Threading::Mutex> mProgressLock;
145 ::ll::TypedStorage<8, 32, ::std::string> mProgressTitle;
146 ::ll::TypedStorage<8, 32, ::std::string> mProgressMessage;
147 // NOLINTEND
148
149 public:
150 // virtual functions
151 // NOLINTBEGIN
152 virtual ~ProgressReporter() /*override*/;
153
154 virtual void clear() /*override*/;
155 // NOLINTEND
156
157 public:
158 // destructor thunk
159 // NOLINTBEGIN
160 MCAPI void $dtor();
161 // NOLINTEND
162
163 public:
164 // virtual function thunks
165 // NOLINTBEGIN
166 MCAPI void $clear();
167
168
169 // NOLINTEND
170
171 public:
172 // vftables
173 // NOLINTBEGIN
174 MCNAPI static void** $vftableForZipProgress();
175
177 // NOLINTEND
178 };
179
180 struct Result {
181 public:
182 // member variables
183 // NOLINTBEGIN
184 ::ll::TypedStorage<4, 4, ::FileArchiverOutcome> outcome;
185 ::ll::TypedStorage<8, 32, ::Core::PathBuffer<::std::string>> fileName;
186 ::ll::TypedStorage<8, 32, ::Core::PathBuffer<::std::string>> levelId;
187 ::ll::TypedStorage<8, 32, ::Core::PathBuffer<::std::string>> originalLevelId;
188 // NOLINTEND
189
190 public:
191 // member functions
192 // NOLINTBEGIN
193 MCAPI ~Result();
194 // NOLINTEND
195
196 public:
197 // destructor thunk
198 // NOLINTBEGIN
199 MCFOLD void $dtor();
200 // NOLINTEND
201 };
202
203 struct ExportData {
204 public:
205 // member variables
206 // NOLINTBEGIN
207 ::ll::TypedStorage<4, 4, ::FileArchiver::ExportType> mExportType;
208 ::ll::TypedStorage<8, 32, ::std::string> mLevelId;
209 ::ll::TypedStorage<8, 8, uint64> mTotalFileCount;
210 ::ll::TypedStorage<8, 104, ::FileArchiver::Result> mResult;
211 ::ll::TypedStorage<8, 16, ::Bedrock::UniqueOwnerPointer<::LevelStorage>> mLevelStorage;
212 ::ll::TypedStorage<8, 8, ::LevelData*> mLevelData;
213 // NOLINTEND
214
215 public:
216 // member functions
217 // NOLINTBEGIN
218 MCAPI ExportData();
219 // NOLINTEND
220
221 public:
222 // constructor thunks
223 // NOLINTBEGIN
224 MCAPI void* $ctor();
225 // NOLINTEND
226 };
227
229 public:
230 // virtual functions
231 // NOLINTBEGIN
232 virtual ~IWorldConverter() = default;
233
234 virtual void enqueueConvertImportingWorldTasks(
235 ::std::shared_ptr<::FileArchiver::Result>&,
236 ::Bedrock::NotNullNonOwnerPtr<::FileArchiver::ProgressReporter>,
238 ) = 0;
239
240 virtual bool shouldCopyWorldForConversion(::std::string const&) const = 0;
241
242 virtual void enqueueConvertExportingWorldTasks(
243 ::std::shared_ptr<::FileArchiver::ExportData>&,
244 ::Bedrock::NotNullNonOwnerPtr<::FileArchiver::ProgressReporter>,
246 ::gsl::not_null<::std::shared_ptr<::FileArchiver::InterventionPublishers>>
247 ) = 0;
248 // NOLINTEND
249
250 public:
251 // virtual function thunks
252 // NOLINTBEGIN
253
254 // NOLINTEND
255 };
256
257 struct InterventionPublishers {
258 public:
259 // InterventionPublishers inner types define
260 using BeginSignature = void(::FileArchiver::ExportType, ::std::string const&, ::Core::Path const&);
261
262 using CleanupSignature = void(::FileArchiver::ExportType);
263
264 using CopyCompleteSignature =
265 void(::FileArchiver::ExportType, ::Core::PathBuffer<::Core::BasicStackString<char, 1024>> const&);
266
267 using LevelDataFinalizeSignature = void(::FileArchiver::ExportType, ::LevelData&);
268
269 using LevelDataMutationSignature = void(::FileArchiver::ExportType, ::LevelData&);
270
271 using PreFileRemovalSignature =
272 void(::FileArchiver::ExportType, ::Core::PathBuffer<::Core::BasicStackString<char, 1024>> const&);
273
274 using PrePackageSignature =
275 void(::FileArchiver::ExportType, ::Core::PathBuffer<::Core::BasicStackString<char, 1024>> const&);
276
277 public:
278 // member variables
279 // NOLINTBEGIN
280 ::ll::TypedStorage<
281 8,
282 128,
284 void(::FileArchiver::ExportType, ::std::string const&, ::Core::Path const&),
286 0>>
287 mBegin;
288 ::ll::TypedStorage<
289 8,
290 128,
292 void(::FileArchiver::ExportType, ::Core::PathBuffer<::Core::BasicStackString<char, 1024>> const&),
294 0>>
295 mCopyComplete;
296 ::ll::TypedStorage<
297 8,
298 128,
300 void(::FileArchiver::ExportType, ::LevelData&),
302 0>>
303 mLevelDataMutation;
304 ::ll::TypedStorage<
305 8,
306 128,
308 void(::FileArchiver::ExportType, ::Core::PathBuffer<::Core::BasicStackString<char, 1024>> const&),
310 0>>
311 mPreFileRemoval;
312 ::ll::TypedStorage<
313 8,
314 128,
316 void(::FileArchiver::ExportType, ::LevelData&),
318 0>>
319 mLevelDataFinalize;
320 ::ll::TypedStorage<
321 8,
322 128,
324 void(::FileArchiver::ExportType, ::Core::PathBuffer<::Core::BasicStackString<char, 1024>> const&),
326 0>>
327 mPrePackage;
328 ::ll::TypedStorage<
329 8,
330 128,
331 ::Bedrock::PubSub::
332 Publisher<void(::FileArchiver::ExportType), ::Bedrock::PubSub::ThreadModel::MultiThreaded, 0>>
333 mCleanup;
334 // NOLINTEND
335
336 public:
337 // member functions
338 // NOLINTBEGIN
339 MCAPI InterventionPublishers();
340 // NOLINTEND
341
342 public:
343 // constructor thunks
344 // NOLINTBEGIN
345 MCAPI void* $ctor();
346 // NOLINTEND
347 };
348
349 using OperationCallback = ::std::function<void(::FileArchiver::Result&)>;
350
351public:
352 // member variables
353 // NOLINTBEGIN
354 ::ll::TypedStorage<8, 192, ::FileArchiver::ProgressReporter> mProgress;
355 ::ll::TypedStorage<8, 80, ::Bedrock::Threading::Mutex> mStateLock;
356 ::ll::TypedStorage<4, 4, ::FileArchiver::State> mCurrentState;
357 ::ll::TypedStorage<8, 24, ::Bedrock::NotNullNonOwnerPtr<::Core::FilePathManager>> mFilePathManager;
358 ::ll::TypedStorage<8, 64, ::std::function<void(::std::string const&)>> mDisplayMessageCallback;
359 ::ll::TypedStorage<8, 24, ::Bedrock::NotNullNonOwnerPtr<::IResourcePackRepository>> mResourcePackRepository;
360 ::ll::TypedStorage<8, 8, ::ILevelListCache&> mLevelListCache;
361 ::ll::TypedStorage<8, 24, ::std::vector<::Core::PathBuffer<::std::string>>> mSuccessfullyFiledArchives;
362 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::TaskGroup>> mIOTaskGroup;
363 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::FileArchiver::IWorldConverter>> mWorldConverter;
364 ::ll::TypedStorage<1, 1, bool> mIsEditorModeEnabled;
365 ::ll::TypedStorage<8, 24, ::Bedrock::NotNullNonOwnerPtr<::IContentKeyProvider const>> mKeyProvider;
366 ::ll::TypedStorage<8, 24, ::Bedrock::NotNullNonOwnerPtr<::LevelDbEnv>> mLevelDbEnv;
367 ::ll::TypedStorage<8, 64, ::std::unordered_map<::std::string, ::FileArchiver::EduCloudImportInfo>>
368 mEduCloudImportInfo;
369 // NOLINTEND
370
371public:
372 // prevent constructor by default
373 FileArchiver& operator=(FileArchiver const&);
374 FileArchiver(FileArchiver const&);
375 FileArchiver();
376
377public:
378 // virtual functions
379 // NOLINTBEGIN
380 virtual ~FileArchiver() /*override*/;
381
382 virtual ::std::shared_ptr<::FilePickerSettings>
383 generateFilePickerSettings(::std::vector<::FileArchiver::ExportType> const& types, ::std::string const&) const;
384 // NOLINTEND
385
386public:
387 // member functions
388 // NOLINTBEGIN
389 MCAPI FileArchiver(
390 ::Scheduler& scheduler,
391 ::ILevelListCache& levelListCache,
392 ::Bedrock::NotNullNonOwnerPtr<::Core::FilePathManager> const& pathManager,
393 ::Bedrock::NotNullNonOwnerPtr<::IResourcePackRepository> const& resourcePackRepository,
394 bool isEditorModeEnabled,
395 ::std::unique_ptr<::FileArchiver::IWorldConverter> worldConverter,
396 ::Bedrock::NotNullNonOwnerPtr<::IContentKeyProvider const> keyProvider,
397 ::Bedrock::NotNullNonOwnerPtr<::LevelDbEnv> levelDbEnv,
398 ::std::function<void(::std::string const&)> displayMessageFunction
399 );
400
401 MCAPI void _clearArchiverState();
402
403 MCAPI void
404 _copyPackToTemp(::PackInstance const& packInstance, ::Core::Path const& tempPath, ::FileArchiver::Result& result);
405
406 MCAPI ::Bedrock::Threading::Async<::FileArchiver::Result> _enqueueExportWorldTasks(
407 ::Core::Path const& outputFilePath,
408 ::std::string const& worldId,
409 bool isBundle,
410 ::FileArchiver::ExportType exportType,
411 ::FileArchiver::ShowToast showToast,
413 ::gsl::not_null<::std::shared_ptr<::FileArchiver::InterventionPublishers>> interventionPublishers,
414 ::std::function<void(::FileArchiver::Result&)> cleanupTask
415 );
416
417 MCAPI void _exportLevelFiles(
418 ::Core::Path const& outputFilePath,
419 bool isBundle,
420 ::std::shared_ptr<::FileArchiver::ExportData> exportData
421 );
422
423 MCAPI_C bool _importLegacyWorld(::Core::Path const& archivedWorldFile, ::FileArchiver::Result& currentResult);
424
425 MCAPI_C bool _importWorld(
426 ::Core::Path const& archivedWorldFile,
427 ::FileArchiver::Result& currentResult,
428 ::std::string const& importLevelId
429 );
430
431 MCAPI void _printLevelResultMessage(::FileArchiver::Result const& result);
432
433 MCAPI void _printLevelStartMessage();
434
435 MCAPI void _printMessage(::std::string const& message);
436
437 MCAPI ::FileArchiverOutcome
438 _processWorldForTemplate(::std::shared_ptr<::FileArchiver::ExportData> const& exportData);
439
440 MCAPI void _revertPremiumUpgradePacks(::Core::Path const& filePath);
441
442 MCAPI_C void _sanitizeWorld(::Core::Path const& newWorldPath);
443
444 MCAPI ::FileArchiver::Result _tryBeginExportLevel(
445 ::std::string const& levelId,
446 ::Core::Path const& exportFilePath,
447 ::FileArchiver::ShowToast showToast
448 );
449
450 MCAPI bool _validatePremiumUpgradePacks(::Core::Path const& filePath);
451
452 MCAPI ::std::string copyLevel(::std::string const& worldId);
453
454 MCAPI_C ::Bedrock::Threading::Async<::FileArchiver::CopyWorldResult> copyLevelAsync(::std::string const& worldId);
455
456 MCAPI ::Bedrock::Threading::Async<::FileArchiver::Result> exportCurrentEditorLevel(
457 ::Level* level,
458 ::Core::Path const& exportFilePath,
459 ::gsl::not_null<::std::shared_ptr<::FileArchiver::InterventionPublishers>> interventionPublishers,
460 ::FileArchiver::ExportType exportType,
461 ::FileArchiver::ShowToast toast
462 );
463
464 MCAPI ::Bedrock::Threading::Async<::FileArchiver::Result> exportCurrentLevel(
465 ::Level* level,
466 bool isBundle,
467 ::FileArchiver::ExportType exportType,
468 ::Core::Path const& exportFilePath,
469 ::gsl::not_null<::std::shared_ptr<::FileArchiver::InterventionPublishers>> interventionPublishers
470 );
471
472 MCAPI void exportCurrentLevel(
473 ::Level* level,
474 bool isBundle,
475 ::FileArchiver::ExportType exportType,
476 ::Core::Path const& exportFilePath,
477 ::std::function<void(::FileArchiver::Result&)> exportCallback,
478 ::gsl::not_null<::std::shared_ptr<::FileArchiver::InterventionPublishers>> interventionPublishers
479 );
480
481 MCAPI_C ::Bedrock::Threading::Async<::FileArchiver::Result> exportLevel(
482 ::std::string const& worldId,
483 bool isBundle,
484 ::FileArchiver::ExportType exportType,
485 ::FileArchiver::ShowToast showToast,
486 ::Core::Path const& exportFilePath,
487 ::gsl::not_null<::std::shared_ptr<::FileArchiver::InterventionPublishers>> interventionPublishers
488 );
489
490 MCAPI_C void exportLevel(
491 ::std::string const& worldId,
492 bool isBundle,
493 ::FileArchiver::ExportType exportType,
494 ::Core::Path const& exportFilePath,
495 ::std::function<void(::FileArchiver::Result&)> exportCallback,
496 ::FileArchiver::ShowToast showToast,
497 ::gsl::not_null<::std::shared_ptr<::FileArchiver::InterventionPublishers>> interventionPublishers
498 );
499
500 MCAPI ::Bedrock::Threading::Async<::FileArchiver::Result>
501 exportPack(::Core::Path const& path, ::Core::Path const& exportFilePath);
502
503 MCAPI void exportPack(
504 ::Core::Path const& path,
505 ::Core::Path const& exportFilePath,
506 ::std::function<void(::FileArchiver::Result&)> exportCallback
507 );
508
509 MCAPI ::FileArchiver::State getCurrentState();
510
511 MCAPI ::Bedrock::NotNullNonOwnerPtr<::FileArchiver::ProgressReporter> getProgressReporter();
512
513 MCAPI_C ::Bedrock::Threading::Async<::FileArchiver::Result> importLevel(
514 ::Core::Path const& archivedWorldFile,
515 bool suppressStartMessage,
516 bool suppressEndMessage,
517 ::std::string const& levelId
518 );
519
520 MCAPI_C void importLevel(
521 ::Core::Path const& archivedWorldFile,
522 ::std::function<void(::FileArchiver::Result&)> importCallback,
523 bool suppressStartMessage,
524 bool suppressEndMessage,
525 ::std::string const& levelId
526 );
527
528 MCAPI_S void setWorldConverter(::std::unique_ptr<::FileArchiver::IWorldConverter> worldConverter);
529 // NOLINTEND
530
531public:
532 // static variables
533 // NOLINTBEGIN
534 MCAPI static ::std::string const& EXTENSION_ADDON();
535
536 MCAPI static ::std::string const& EXTENSION_EDITOR_ADDON();
537
538 MCAPI static ::std::string const& EXTENSION_PROJECT();
539
540 MCAPI static ::std::string const& EXTENSION_RESOURCEPACK();
541
542 MCAPI static ::std::string const& EXTENSION_TEMPLATE();
543
544 MCAPI static ::std::string const& EXTENSION_VANILLA();
545
546 MCAPI static ::std::string const& IMPORT_LOCK_FILE();
547 // NOLINTEND
548
549public:
550 // constructor thunks
551 // NOLINTBEGIN
552 MCAPI void* $ctor(
553 ::Scheduler& scheduler,
554 ::ILevelListCache& levelListCache,
555 ::Bedrock::NotNullNonOwnerPtr<::Core::FilePathManager> const& pathManager,
556 ::Bedrock::NotNullNonOwnerPtr<::IResourcePackRepository> const& resourcePackRepository,
557 bool isEditorModeEnabled,
558 ::std::unique_ptr<::FileArchiver::IWorldConverter> worldConverter,
559 ::Bedrock::NotNullNonOwnerPtr<::IContentKeyProvider const> keyProvider,
560 ::Bedrock::NotNullNonOwnerPtr<::LevelDbEnv> levelDbEnv,
561 ::std::function<void(::std::string const&)> displayMessageFunction
562 );
563 // NOLINTEND
564
565public:
566 // destructor thunk
567 // NOLINTBEGIN
568 MCAPI void $dtor();
569 // NOLINTEND
570
571public:
572 // virtual function thunks
573 // NOLINTBEGIN
574 MCAPI ::std::shared_ptr<::FilePickerSettings>
575 $generateFilePickerSettings(::std::vector<::FileArchiver::ExportType> const& types, ::std::string const&) const;
576
577
578 // NOLINTEND
579
580public:
581 // vftables
582 // NOLINTBEGIN
583 MCNAPI static void** $vftable();
584 // NOLINTEND
585};
Definition EnableNonOwnerReferences.h:7
Definition Publisher.h:8
Definition Async.h:8
Definition BasicStackString.h:8
Definition FilePathManager.h:18
Definition PathBuffer.h:8
Definition Path.h:10
Definition ZipProgress.h:7
Definition FileArchiver.h:228
Definition FileArchiver.h:140
static MCAPI void ** $vftableForZipProgress()
static MCAPI void ** $vftableForEnableNonOwnerReferences()
static MCAPI void ** $vftable()
Definition FilePickerSettings.h:5
Definition IContentKeyProvider.h:13
Definition ILevelListCache.h:27
Definition IResourcePackRepository.h:34
Definition LevelData.h:50
Definition LevelDbEnv.h:8
Definition LevelStorage.h:25
Definition Level.h:249
Definition PackInstance.h:16
Definition Scheduler.h:14
Definition TaskGroup.h:53
Definition FileArchiver.h:69
Definition FileArchiver.h:91
Definition FileArchiver.h:203
Definition FileArchiver.h:115
Definition FileArchiver.h:257
Definition FileArchiver.h:180