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