This code should work for any platform.
.h
/** returns a list of all save games in /Saved/SaveGames folder, without the .sav extension (filename only) */
UFUNCTION(BlueprintPure, Category = Game)
static TArray<FString> GetAllSaveGameSlotNames();
.cpp
#include "Paths.h"
#include "PlatformFile.h"
#include "PlatformFilemanager.h"
TArray<FString> USnakesBlueprintFunctionLibrary::GetAllSaveGameSlotNames()
{
//////////////////////////////////////////////////////////////////////////////
class FFindSavesVisitor : public IPlatformFile::FDirectoryVisitor
{
public:
FFindSavesVisitor() {}
virtual bool Visit(const TCHAR* FilenameOrDirectory, bool bIsDirectory)
{
if (!bIsDirectory)
{
FString FullFilePath(FilenameOrDirectory);
if (FPaths::GetExtension(FullFilePath) == TEXT("sav"))
{
FString CleanFilename = FPaths::GetBaseFilename(FullFilePath);
CleanFilename = CleanFilename.Replace(TEXT(".sav"), TEXT(""));
SavesFound.Add(CleanFilename);
}
}
return true;
}
TArray<FString> SavesFound;
};
//////////////////////////////////////////////////////////////////////////////
TArray<FString> Saves;
const FString SavesFolder = FPaths::GameSavedDir() + TEXT("SaveGames");
if (!SavesFolder.IsEmpty())
{
FFindSavesVisitor Visitor;
FPlatformFileManager::Get().GetPlatformFile().IterateDirectory(*SavesFolder, Visitor);
Saves = Visitor.SavesFound;
}
return Saves;
}
If you don’t know what to do with this, look up in the wiki: “C++ blueprint function library tutorial”.