Save game system changed between 4.14 and a follow up?

Something like this should work (might have errors since I haven’t tried compiling it):


void CopyAllSavedGamesToExternal(bool DeleteOriginalFiles)
{
#if PLATFORM_ANDROID
    extern FString GOBBFilePathBase;
    FString OriginalSaveDir = GOBBFilePathBase + "/UE4Game/" + FApp:GetProjectName() + FString("/Saved/SaveGames/");
    FString NewSaveDir = FPaths::ProjectSavedDir() / "SaveGames/";

    // do nothing if trying to copy to same directory
    if (OriginalSaveDir.Equals(NewSaveDir))
    {
        return;
    }

    IFileManager* FileManager = &IFileManager::Get();

    // do nothing if original savedir doesn't exist (never had files)
    if (!FileManager->DirectoryExists(*OriginalSaveDir))
    {
        return;
    }

    // iterate over all the files in original save directory
    TArray<FString> directoriesToIgnoreAndNotRecurse;
    FLocalTimestampDirectoryVisitor Visitor(FPlatformFileManager::Get().GetPlatformFile(), directoriesToIgnoreAndNotRecurse, directoriesToIgnoreAndNotRecurse, false);
    FileManager->IterateDirectory(*OriginalSaveDir, Visitor);

    for (TMap<FString, FDateTime>::TIterator TimestampIt(Visitor.FileTimes); TimestampIt; ++TimestampIt)
    {
        // read the file contents and write it if successful to external path
        TArray<uint8> MemFile;
        const FString SourceFilename = TimestampIt.Key();
        if (FFileHelper::LoadFileToArray(MemFile, *SourceFilename, 0))
        {
            FString DestFilename = NewSaveDir / FPaths::GetCleanFilename(*SourceFilename);
            FFileHelper::SaveArrayToFile(MemFile, *DestFilename);

            if (DeleteOriginalFiles)
            {
                FileManager->DeleteFile(*SourceFileName);
            }
        }
    }
#endif
}


You will also need to make a change to AndroidFile.cpp to PathToAndroidPaths(). Add another case for GOBBFilePathBase like this:


            if ((AllowLocal && AndroidPath.StartsWith(TEXT("/"))) ||
                AndroidPath.StartsWith(GFontPathBase) ||
                AndroidPath.StartsWith(TEXT("/system/etc/")) ||
                AndroidPath.StartsWith(GExternalFilePath.Left(AndroidPath.Len()) ||
                AndroidPath.StartsWith(GOBBFilePathBase.Left(AndroidPath.Len())))
            {
                // Absolute paths are only local.
                LocalPath = AndroidPath;
                AssetPath = AndroidPath;
            }