Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void AUERConPluginProjectGameModeBase::WriteAccountData()
- {
- FString SaveDirectory = FString("E:/UESaves");
- FString FileName = FString("UE4Save.bin");
- FString TextToSave = FString("YoungWolf?db235ccsa432ds");
- bool bAllowOverwriting = false;
- IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile();
- FString FullPath = SaveDirectory + "/" + FileName;
- IFileHandle* FileHandle = PlatformFile.OpenWrite(*FullPath);
- if (FileHandle)
- {
- //FileHandle->Write((const uint8*)TCHAR_TO_ANSI(*TextToSave), TextToSave.Len());
- int32 size = TextToSave.Len();
- uint8* ByteArray = reinterpret_cast<uint8*>(FMemory::Malloc(size + 1));
- int32 sizeWritten = StringToBytes(TextToSave, ByteArray, size + 1);
- FileHandle->Write(ByteArray, sizeWritten);
- delete FileHandle;
- }
- }
- void AUERConPluginProjectGameModeBase::LoadAccountData()
- {
- FString SaveDirectory = FString("E:/UESaves");
- FString FileName = FString("UE4Save.bin");
- FString TextToSave = FString("YoungWolf?db235ccsa432ds");
- bool bAllowOverwriting = false;
- IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile();
- FString FullPath = SaveDirectory + "/" + FileName;
- IFileHandle* FileHandle = PlatformFile.OpenRead(*FullPath);
- if (FileHandle)
- {
- int64 size = GetFileSizeOf(FullPath);
- //Allocate uint8 buffer with size
- uint8* ByteArray = reinterpret_cast<uint8*>(FMemory::Malloc(size + 1));
- //Read Data to buffer
- FileHandle->Read(ByteArray, size);
- //Convert to decimal here..
- FString Converted = BytesToString(ByteArray, size);
- FString Fixed = FixString(Converted);
- GEngine->AddOnScreenDebugMessage(3, 5.0f, FColor::Yellow, Converted);
- delete FileHandle;
- }
- }
- int64 AUERConPluginProjectGameModeBase::GetFileSizeOf(FString FullPath)
- {
- int64 FileSize = 0;
- if (!FPlatformFileManager::Get().GetPlatformFile().FileExists(*FullPath))
- {
- GEngine->AddOnScreenDebugMessage(0, 5.0f, FColor::Red, TEXT("File not found!"));
- return 0;
- }
- FileSize = FPlatformFileManager::Get().GetPlatformFile().FileSize(*FullPath);
- return FileSize;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement