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
272 virtual bool prepareEditorProjectForSaveSnapshot(
273 ::Level& level,
274 ::Core::PathBuffer<::std::string>& generatedLevelDataFile
275 ) = 0;
276 // NOLINTEND
277 };
278
279 struct InterventionPublishers {
280 public:
281 // InterventionPublishers inner types define
282 using BeginSignature = void(::FileArchiver::ExportType, ::std::string const&, ::Core::Path const&);
283
284 using CleanupSignature = void(::FileArchiver::ExportType);
285
286 using CopyCompleteSignature =
287 void(::FileArchiver::ExportType, ::Core::PathBuffer<::Core::BasicStackString<char, 1024>> const&);
288
289 using LevelDataFinalizeSignature = void(::FileArchiver::ExportType, ::LevelData&);
290
291 using LevelDataMutationSignature = void(::FileArchiver::ExportType, ::LevelData&);
292
293 using PreFileRemovalSignature =
294 void(::FileArchiver::ExportType, ::Core::PathBuffer<::Core::BasicStackString<char, 1024>> const&);
295
296 using PrePackageSignature =
297 void(::FileArchiver::ExportType, ::Core::PathBuffer<::Core::BasicStackString<char, 1024>> const&);
298
299 public:
300 // member variables
301 // NOLINTBEGIN
302 ::ll::TypedStorage<
303 8,
304 128,
306 void(::FileArchiver::ExportType, ::std::string const&, ::Core::Path const&),
308 0>>
309 mBegin;
310 ::ll::TypedStorage<
311 8,
312 128,
314 void(::FileArchiver::ExportType, ::Core::PathBuffer<::Core::BasicStackString<char, 1024>> const&),
316 0>>
317 mCopyComplete;
318 ::ll::TypedStorage<
319 8,
320 128,
322 void(::FileArchiver::ExportType, ::LevelData&),
324 0>>
325 mLevelDataMutation;
326 ::ll::TypedStorage<
327 8,
328 128,
330 void(::FileArchiver::ExportType, ::Core::PathBuffer<::Core::BasicStackString<char, 1024>> const&),
332 0>>
333 mPreFileRemoval;
334 ::ll::TypedStorage<
335 8,
336 128,
338 void(::FileArchiver::ExportType, ::LevelData&),
340 0>>
341 mLevelDataFinalize;
342 ::ll::TypedStorage<
343 8,
344 128,
346 void(::FileArchiver::ExportType, ::Core::PathBuffer<::Core::BasicStackString<char, 1024>> const&),
348 0>>
349 mPrePackage;
350 ::ll::TypedStorage<
351 8,
352 128,
353 ::Bedrock::PubSub::
354 Publisher<void(::FileArchiver::ExportType), ::Bedrock::PubSub::ThreadModel::MultiThreaded, 0>>
355 mCleanup;
356 // NOLINTEND
357
358 public:
359 // member functions
360 // NOLINTBEGIN
361 MCAPI InterventionPublishers();
362 // NOLINTEND
363
364 public:
365 // constructor thunks
366 // NOLINTBEGIN
367 MCAPI void* $ctor();
368 // NOLINTEND
369 };
370
371 using OperationCallback = ::std::function<void(::FileArchiver::Result&)>;
372
373public:
374 // member variables
375 // NOLINTBEGIN
376 ::ll::TypedStorage<8, 192, ::FileArchiver::ProgressReporter> mProgress;
377 ::ll::TypedStorage<8, 80, ::Bedrock::Threading::Mutex> mStateLock;
378 ::ll::TypedStorage<4, 4, ::FileArchiver::State> mCurrentState;
379 ::ll::TypedStorage<8, 24, ::Bedrock::NotNullNonOwnerPtr<::Core::FilePathManager>> mFilePathManager;
380 ::ll::TypedStorage<8, 64, ::std::function<void(::std::string const&)>> mDisplayMessageCallback;
381 ::ll::TypedStorage<8, 24, ::Bedrock::NotNullNonOwnerPtr<::IResourcePackRepository>> mResourcePackRepository;
382 ::ll::TypedStorage<8, 8, ::ILevelListCache&> mLevelListCache;
383 ::ll::TypedStorage<8, 8, ::LevelStorageSource&> mLevelStorageSource;
384 ::ll::TypedStorage<8, 24, ::std::vector<::Core::PathBuffer<::std::string>>> mSuccessfullyFiledArchives;
385 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::TaskGroup>> mIOTaskGroup;
386 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::FileArchiver::IWorldConverter>> mWorldConverter;
387 ::ll::TypedStorage<1, 1, bool> mIsEditorModeEnabled;
388 ::ll::TypedStorage<8, 24, ::Bedrock::NotNullNonOwnerPtr<::IContentKeyProvider const>> mKeyProvider;
389 ::ll::TypedStorage<8, 24, ::Bedrock::NotNullNonOwnerPtr<::LevelDbEnv>> mLevelDbEnv;
390 ::ll::TypedStorage<8, 64, ::std::unordered_map<::std::string, ::FileArchiver::EduCloudImportInfo>>
391 mEduCloudImportInfo;
392 // NOLINTEND
393
394public:
395 // prevent constructor by default
396 FileArchiver& operator=(FileArchiver const&);
397 FileArchiver(FileArchiver const&);
398 FileArchiver();
399
400public:
401 // virtual functions
402 // NOLINTBEGIN
403 virtual ~FileArchiver() /*override*/ = default;
404
405 virtual ::std::shared_ptr<::FilePickerSettings>
406 generateFilePickerSettings(::std::vector<::FileArchiver::ExportType> const& types, ::std::string const&) const;
407 // NOLINTEND
408
409public:
410 // member functions
411 // NOLINTBEGIN
412 MCAPI FileArchiver(
413 ::Scheduler& scheduler,
414 ::ILevelListCache& levelListCache,
415 ::LevelStorageSource& levelStorageSource,
416 ::Bedrock::NotNullNonOwnerPtr<::Core::FilePathManager> const& pathManager,
417 ::Bedrock::NotNullNonOwnerPtr<::IResourcePackRepository> const& resourcePackRepository,
418 bool isEditorModeEnabled,
419 ::std::unique_ptr<::FileArchiver::IWorldConverter> worldConverter,
420 ::Bedrock::NotNullNonOwnerPtr<::IContentKeyProvider const> keyProvider,
421 ::Bedrock::NotNullNonOwnerPtr<::LevelDbEnv> levelDbEnv,
422 ::std::function<void(::std::string const&)> displayMessageFunction
423 );
424
425 MCAPI void _clearArchiverState();
426
427 MCAPI void
428 _copyPackToTemp(::PackInstance const& packInstance, ::Core::Path const& tempPath, ::FileArchiver::Result& result);
429
430 MCAPI ::Bedrock::Threading::Async<::FileArchiver::Result> _enqueueExportWorldTasks(
431 ::Core::Path const& outputFilePath,
432 ::std::string const& worldId,
433 bool isBundle,
434 ::FileArchiver::ExportType exportType,
435 ::FileArchiver::ShowToast const showToast,
437 ::gsl::not_null<::std::shared_ptr<::FileArchiver::InterventionPublishers>> interventionPublishers,
438 ::std::function<void(::FileArchiver::Result&)> cleanupTask,
439 ::std::optional<::FileArchiver::WorldConverterExportSettings> const exportSetting,
440 ::Core::Path const& targetFolder
441 );
442
443 MCAPI void _exportLevelFiles(
444 ::Core::Path const& outputFilePath,
445 bool isBundle,
446 ::std::shared_ptr<::FileArchiver::ExportData> exportData,
447 ::Core::Path const& worldPath
448 );
449
450#ifdef LL_PLAT_C
451 MCAPI bool _importWorld(
452 ::Core::Path const& archivedWorldFile,
453 ::FileArchiver::Result& currentResult,
454 ::std::string const& importLevelId
455 );
456#endif
457
458 MCAPI void _printLevelResultMessage(::FileArchiver::Result const& result);
459
460#ifdef LL_PLAT_C
461 MCAPI void _printLevelStartMessage();
462#endif
463
464 MCAPI void _printMessage(::std::string const& message);
465
466 MCAPI ::FileArchiver::Result _tryBeginExportLevel(
467 ::std::string const& levelId,
468 ::Core::Path const& exportFilePath,
469 ::FileArchiver::ShowToast const showToast
470 );
471
472 MCAPI bool _validatePremiumUpgradePacks(::Core::Path const& filePath);
473
474#ifdef LL_PLAT_C
475 MCAPI ::std::string copyLevel(::std::string const& worldId, ::Core::Path const& targetFolder);
476
477 MCAPI ::Bedrock::Threading::Async<::FileArchiver::CopyWorldResult> copyLevelAsync(::std::string const& worldId);
478#endif
479
480 MCAPI ::Bedrock::Threading::Async<::FileArchiver::Result> exportCurrentEditorLevel(
481 ::Level* level,
482 ::Core::Path const& exportFilePath,
483 ::gsl::not_null<::std::shared_ptr<::FileArchiver::InterventionPublishers>> interventionPublishers,
484 ::std::optional<::FileArchiver::WorldConverterExportSettings> exportSetting,
485 ::FileArchiver::ExportType exportType,
486 ::FileArchiver::ShowToast toast
487 );
488
489 MCAPI void exportCurrentLevel(
490 ::Level* level,
491 bool isBundle,
492 ::FileArchiver::ExportType exportType,
493 ::Core::Path const& exportFilePath,
494 ::std::function<void(::FileArchiver::Result&)> exportCallback,
495 ::gsl::not_null<::std::shared_ptr<::FileArchiver::InterventionPublishers>> interventionPublishers
496 );
497
498#ifdef LL_PLAT_C
499 MCAPI void exportLevel(
500 ::std::string const& worldId,
501 bool isBundle,
502 ::FileArchiver::ExportType exportType,
503 ::Core::Path const& exportFilePath,
504 ::std::function<void(::FileArchiver::Result&)> exportCallback,
505 ::FileArchiver::ShowToast showToast,
506 ::gsl::not_null<::std::shared_ptr<::FileArchiver::InterventionPublishers>> interventionPublishers
507 );
508#endif
509
510 MCAPI void exportPack(
511 ::Core::Path const& path,
512 ::Core::Path const& exportFilePath,
513 ::std::function<void(::FileArchiver::Result&)> exportCallback
514 );
515
516#ifdef LL_PLAT_C
517 MCAPI ::Bedrock::Threading::Async<::FileArchiver::Result> importLevel(
518 ::Core::Path const& archivedWorldFile,
519 bool suppressStartMessage,
520 bool suppressEndMessage,
521 ::std::string const& levelId
522 );
523
524 MCAPI void importLevel(
525 ::Core::Path const& archivedWorldFile,
526 ::std::function<void(::FileArchiver::Result&)> importCallback,
527 bool suppressStartMessage,
528 bool suppressEndMessage,
529 ::std::string const& levelId
530 );
531
532 MCAPI void setEduCloudImportInfo(
533 ::std::string const& worldId,
534 ::std::string const& cTag,
535 ::std::string const& name,
536 ::std::string const& oid,
537 bool allowMultiplayer
538 );
539#endif
540 // NOLINTEND
541
542public:
543 // static functions
544 // NOLINTBEGIN
545 MCAPI static void _revertPremiumUpgradePacks(::Core::Path const& filePath);
546
547#ifdef LL_PLAT_C
548 MCAPI static void _sanitizeWorld(::Core::Path const& newWorldPath);
549#endif
550 // NOLINTEND
551
552public:
553 // static variables
554 // NOLINTBEGIN
555#ifdef LL_PLAT_C
556 MCAPI static ::std::string const& EXTENSION_ADDON();
557#endif
558
559 MCAPI static ::std::string const& EXTENSION_PROJECT();
560
561 MCAPI static ::std::string const& EXTENSION_RESOURCEPACK();
562
563 MCAPI static ::std::string const& EXTENSION_TEMPLATE();
564
565 MCAPI static ::std::string const& EXTENSION_VANILLA();
566
567 MCAPI static ::std::string const& IMPORT_LOCK_FILE();
568 // NOLINTEND
569
570public:
571 // constructor thunks
572 // NOLINTBEGIN
573 MCAPI void* $ctor(
574 ::Scheduler& scheduler,
575 ::ILevelListCache& levelListCache,
576 ::LevelStorageSource& levelStorageSource,
577 ::Bedrock::NotNullNonOwnerPtr<::Core::FilePathManager> const& pathManager,
578 ::Bedrock::NotNullNonOwnerPtr<::IResourcePackRepository> const& resourcePackRepository,
579 bool isEditorModeEnabled,
580 ::std::unique_ptr<::FileArchiver::IWorldConverter> worldConverter,
581 ::Bedrock::NotNullNonOwnerPtr<::IContentKeyProvider const> keyProvider,
582 ::Bedrock::NotNullNonOwnerPtr<::LevelDbEnv> levelDbEnv,
583 ::std::function<void(::std::string const&)> displayMessageFunction
584 );
585 // NOLINTEND
586
587public:
588 // virtual function thunks
589 // NOLINTBEGIN
590 MCAPI ::std::shared_ptr<::FilePickerSettings>
591 $generateFilePickerSettings(::std::vector<::FileArchiver::ExportType> const& types, ::std::string const&) const;
592
593
594 // NOLINTEND
595};
Definition EnableNonOwnerReferences.h:7
Definition Publisher.h:25
Definition Async.h:8
Definition BasicStackString.h:8
Definition FilePathManager.h:18
Definition PathBuffer.h:8
Definition Path.h:11
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:55
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:61
Definition FileArchiver.h:72
Definition FileArchiver.h:116
Definition FileArchiver.h:227
Definition FileArchiver.h:128
Definition FileArchiver.h:279
Definition FileArchiver.h:191
Definition FileArchiver.h:242