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