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