public string Journal; // Name of the journal file internal RC CreateFile() { RC rc = RC.OK; if (Real == null) { VFile real = null; VSystem.OPEN dummy; rc = Vfs.Open(Journal, Real, Flags, out dummy); if (rc == RC.OK) { Real = real; if (Size > 0) { Debug.Assert(Size <= BufferLength); rc = Real.Write(Buffer, Size, 0); } if (rc != RC.OK) { // If an error occurred while writing to the file, close it before returning. This way, SQLite uses the in-memory journal data to // roll back changes made to the internal page-cache before this function was called. Real.Close(); Real = null; } } } return(rc); }
public override RC Write(byte[] buffer, int amount, long offset) { RC rc = RC.OK; if (Real != null && (offset + amount) > BufferLength) { rc = CreateFile(); } if (rc == RC.OK) { if (Real != null) { return(Real.Write(buffer, amount, offset)); } System.Buffer.BlockCopy(Buffer, (int)offset, buffer, 0, amount); if (Size < (offset + amount)) { Size = (int)(offset + amount); } } return(rc); }
internal RC CreateFile() { RC rc = RC.OK; if (Real == null) { VFile real = null; VSystem.OPEN dummy; rc = Vfs.Open(Journal, Real, Flags, out dummy); if (rc == RC.OK) { Real = real; if (Size > 0) { Debug.Assert(Size <= BufferLength); rc = Real.Write(Buffer, Size, 0); } if (rc != RC.OK) { // If an error occurred while writing to the file, close it before returning. This way, SQLite uses the in-memory journal data to // roll back changes made to the internal page-cache before this function was called. Real.Close(); Real = null; } } } return rc; }