Exemple #1
0
 private bool DeleteFileSwitch(string fileName)
 {
     nn.fs.EntryType entryType = 0; //init to a dummy value (C# requirement)
     nn.fs.FileSystem.GetEntryType(ref entryType, saveDataPath);
     nn.Result result = nn.fs.File.Delete(saveDataPath + fileName);
     return(result.IsSuccess());
 }
Exemple #2
0
    private bool LoadInternalSwitch(ref byte[] loadedData, string fileName, int loadBufferSizeInBytes)
    {
#if (UNITY_SWITCH && !UNITY_EDITOR) || SWITCH_DEV
        nn.fs.EntryType entryType = 0; //init to a dummy value (C# requirement)
        nn.fs.FileSystem.GetEntryType(ref entryType, saveDataPath);
        nn.Result result = nn.fs.File.Open(ref fileHandle, saveDataPath + fileName, nn.fs.OpenFileMode.Read);
        if (result.IsSuccess() == false)
        {
            return(false);   // Could not open file. This can be used to detect if this is the first time a user has launched your game.
                             // (However, be sure you are not getting this error due to your file being locked by another process, etc.)
        }
        loadedData = new byte[loadBufferSizeInBytes];
        nn.fs.File.Read(fileHandle, 0, loadedData, loadBufferSizeInBytes);
        nn.fs.File.Close(fileHandle);
#endif
        return(true);
    }
Exemple #3
0
    public bool load(ref string outputData, string filename)
    {
        nn.fs.EntryType entryType = 0; //init to a dummy value (C# requirement)
        nn.fs.FileSystem.GetEntryType(ref entryType, saveDataPath);
        nn.Result result = nn.fs.File.Open(ref fileHandle, saveDataPath + filename, nn.fs.OpenFileMode.Read);
        if (result.IsSuccess() == false)
        {
            return(false);   // Could not open file. This can be used to detect if this is the first time a user has launched your game.
                             // (However, be sure you are not getting this error due to your file being locked by another process, etc.)
        }
        byte[] loadedData = new byte[loadBufferSize];
        nn.fs.File.Read(fileHandle, 0, loadedData, loadBufferSize);
        nn.fs.File.Close(fileHandle);

        using (MemoryStream stream = new MemoryStream(loadedData))
        {
            BinaryReader reader = new BinaryReader(stream);
            outputData = reader.ReadString();
        }
        return(true);
    }