void FLauncherProfileManager::SaveProfile(const ILauncherProfileRef& Profile) { if (Profile->GetId().IsValid()) { FString ProfileFileName = GetProfileFolder() / Profile->GetId().ToString() + TEXT(".ulp"); FArchive* ProfileFileWriter = IFileManager::Get().CreateFileWriter(*ProfileFileName); if (ProfileFileWriter != nullptr) { Profile->Serialize(*ProfileFileWriter); delete ProfileFileWriter; } } }
void FLauncherProfileManager::RemoveProfile( const ILauncherProfileRef& Profile ) { AllProfiles.Remove(Profile); if (SavedProfiles.Remove(Profile) > 0) { if (Profile->GetId().IsValid()) { // delete the persisted profile on disk FString ProfileFileName = GetProfileFolder() / Profile->GetId().ToString() + TEXT(".ulp"); // delete the profile IFileManager::Get().Delete(*ProfileFileName); ProfileRemovedDelegate.Broadcast(Profile); } } }
bool FLauncherProfileManager::SaveJSONProfile(const ILauncherProfileRef& Profile) { if (Profile->GetId().IsValid()) { FString Text; TSharedRef< TJsonWriter<> > Writer = TJsonWriterFactory<>::Create(&Text); Profile->Save(Writer.Get()); Writer->Close(); return FFileHelper::SaveStringToFile(Text, *Profile->GetFilePath()); } return false; }
bool FLauncherProfileManager::SaveProfile(const ILauncherProfileRef& Profile) { if (Profile->GetId().IsValid()) { FString ProfileFileName = Profile->GetFilePath(); FArchive* ProfileFileWriter = IFileManager::Get().CreateFileWriter(*ProfileFileName); if (ProfileFileWriter != nullptr) { Profile->Serialize(*ProfileFileWriter); delete ProfileFileWriter; return true; } } return false; }
void FLauncherProfileManager::AddProfile( const ILauncherProfileRef& Profile ) { if (!SavedProfiles.Contains(Profile)) { // replace the existing profile ILauncherProfilePtr ExistingProfile = GetProfile(Profile->GetId()); if (ExistingProfile.IsValid()) { RemoveProfile(ExistingProfile.ToSharedRef()); } if (!Profile->GetDeployedDeviceGroup().IsValid()) { Profile->SetDeployedDeviceGroup(AddNewDeviceGroup()); } // add the new profile SavedProfiles.Add(Profile); AllProfiles.Add(Profile); ProfileAddedDelegate.Broadcast(Profile); } }