Using EasySave with custom file I/O

Easy Save 2 has been replaced by Easy Save 3, so is no longer supported.
Locked
Kain Shin
Posts: 3
Joined: Mon Nov 16, 2015 9:44 pm

Using EasySave with custom file I/O

Post by Kain Shin »

Hello,

We used Easy Save for our game (The Magic Circle) and are now in the process of porting this codebase to consoles.

Sony does not give direct access to the file system for the Playstation 4, but I still want to take advantage of Easy Save's JSON tag management.
The sample and plugin provided by Sony works by converting byte[] to and from files through the use of 'System.IO.MemoryStream', 'System.IO.BinaryWriter', and 'System.IO.BinaryReader'.

My strategy is to create ES2Writer and ES2Reader objects on the PS4 with just the ES2Settings parameter, but I do not have visibility into whether that would avoid any attempts at File I/O.
Is there any recommended course of action for this particular usage pattern?
User avatar
Joel
Moodkie Staff
Posts: 4846
Joined: Wed Nov 07, 2012 10:32 pm

Re: Using EasySave with custom file I/O

Post by Joel »

Hi there,

Although we don't officially support Playstation as we don't have a developer license at our end, many of our customers are using it by setting the save location for the ES2Reader/ES2Writer to Memory (which essentially turns it into a MemoryStream). i.e.
ES2Settings settings = new ES2Settings();
settings.saveLocation = ES2Settings.SaveLocation.Memory;

using( ES2Writer writer = ES2Writer.Create(settings) )
{
    writer.Write(123, "myTag");
    writer.Write("ABC", "myTag2");
    writer.Save();
    byte[] bytes = writer.stream.ReadAllBytes();
}
And using ES2Reader:
ES2Settings settings = new ES2Settings();
settings.saveLocation = ES2Settings.SaveLocation.Memory;

using( ES2Reader reader = ES2Reader.Create(bytes, settings) )
{
    int myInt = reader.Read<int>("myTag");
    string myString = reader.Read<string>("myTag2");
}
All the best,
Joel
Kain Shin
Posts: 3
Joined: Mon Nov 16, 2015 9:44 pm

Re: Using EasySave with custom file I/O

Post by Kain Shin »

Ah, that was what I was looking for. Thank you :)
Locked