public static unsafe bool WriteToDisk(FixedString128 gameSaveFilePath, MemoryBinaryWriter writer) { Baselib_ErrorState errorState = new Baselib_ErrorState(); Baselib_FileIO_SyncFile gameSaveFileHandle = Baselib_FileIO_SyncOpen(gameSaveFilePath.GetUnsafePtr(), Baselib_FileIO_OpenFlags.CreateAlways | Baselib_FileIO_OpenFlags.Write, &errorState); if (errorState.code != Baselib_ErrorCode.Success) { return(false); } Baselib_FileIO_SyncWrite(gameSaveFileHandle, 0, (IntPtr)writer.Data, (uint)writer.Length, &errorState); if (errorState.code != Baselib_ErrorCode.Success) { return(false); } Baselib_FileIO_SyncFlush(gameSaveFileHandle, &errorState); if (errorState.code != Baselib_ErrorCode.Success) { return(false); } // If we get this far, we'll consider the write a success because it should have been completed. Baselib_FileIO_SyncClose(gameSaveFileHandle, &errorState); return(true); }
public unsafe void PushValueField(FixedString128 key, FixedString4096 value) { AddCommaIfRequired(); ValidateInObject(); FixedString128 str = $"\"{key}\": \"{value}\""; m_Buffer.Append(str.GetUnsafePtr(), str.Length); }
public unsafe void PushValueField(FixedString128 key, bool value) { AddCommaIfRequired(); ValidateInObject(); var boolString = (value ? (FixedString128)"true" : (FixedString128)"false"); FixedString128 str = $"\"{key}\": {boolString}"; m_Buffer.Append(str.GetUnsafePtr(), str.Length); }
public unsafe void PushArrayField(FixedString128 key) { AddCommaIfRequired(); ValidateInObject(); m_Stack.Push(k_EmptyArray); FixedString128 str = $"\"{key}\": ["; m_Buffer.Append(str.GetUnsafePtr(), str.Length); }
public unsafe int PushValueToArray(bool value) { AddCommaIfRequired(); ValidateInArray(); int index = m_Stack.Peek(); FixedString128 str = value ? (FixedString128)"true" : (FixedString128)"false"; m_Buffer.Append(str.GetUnsafePtr(), str.Length); m_Stack.IncrementTop(); return(index); }
public static unsafe bool ReadFromDisk(FixedString128 gameSaveFilePath) { Baselib_ErrorState errorState = new Baselib_ErrorState(); Baselib_FileIO_SyncFile fileHandle = Baselib_FileIO_SyncOpen(gameSaveFilePath.GetUnsafePtr(), Baselib_FileIO_OpenFlags.Read, &errorState); if (errorState.code != Baselib_ErrorCode.Success) { return(false); } GameSaveFile gameSaveFile; gameSaveFile.filePath = gameSaveFilePath; gameSaveFile.fileHandle = fileHandle; gameSaveReadFiles.Add(gameSaveFile); return(true); }
public unsafe void Draw(FixedString128 text, Matrix4x4 transform, Color color) => Draw(text.GetUnsafePtr(), text.Length, transform, color);