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); }
internal static RC JournalVFileCreate(VFile file) { if (file.Type != 2) { return(RC.OK); } return(((JournalVFile)file).CreateFile()); }
// extensions #if ENABLE_ATOMIC_WRITE internal static RC JournalVFileOpen(VSystem vfs, string name, ref VFile file, VSystem.OPEN flags, int bufferLength) { var p = new JournalVFile(); if (bufferLength > 0) { p.Buffer = C._allocZero(bufferLength); } else { VSystem.OPEN dummy; return(vfs.Open(name, p, flags, out dummy)); } p.Type = 2; p.BufferLength = bufferLength; p.Flags = flags; p.Journal = name; p.Vfs = vfs; file = p; return(RC.OK); }
internal static void MemoryVFileOpen(ref VFile file) { file = new MemoryVFile(); file.Type = 1; }
internal bool HasJournalVFile(VFile file) { return(true); }
internal static bool HasJournalVFile(VFile file) { return(file.Type != 2 || ((JournalVFile)file).Real != null); }
static void FileWriterInit(Context ctx, VFile file, FileWriter p, long start) { p._memset(); int pageSize = ctx.DBs[0].Bt.GetPageSize(); p.Buffer.data = (byte[])C._tagalloc(ctx, pageSize); if (p.Buffer.data == null) p.FWErr = RC.NOMEM; else { p.BufEnd = p.BufStart = (start % pageSize); p.WriteOffset = start - p.BufStart; p.Buffer.length = pageSize; p.File = file; } }
internal bool HasJournalVFile(VFile file) { return true; }
static RC VdbeSorterOpenTempFile(Context ctx, ref VFile file) { VSystem.OPEN outFlags; return ctx.Vfs.OpenAndAlloc(null, file, (VSystem.OPEN)(VSystem.OPEN_TEMP_JOURNAL | VSystem.OPEN_READWRITE | VSystem.OPEN_CREATE | VSystem.OPEN_EXCLUSIVE | VSystem.OPEN_DELETEONCLOSE), ref outFlags); }
// extensions internal static RC JournalVFileOpen(VSystem vfs, string name, ref VFile file, VSystem.OPEN flags, int bufferLength) { var p = new JournalVFile(); if (bufferLength > 0) p.Buffer = SysEx.Alloc(bufferLength, true); else { VSystem.OPEN dummy; return vfs.Open(name, p, flags, out dummy); } p.Type = 2; p.BufferLength = bufferLength; p.Flags = flags; p.Journal = name; p.Vfs = vfs; file = p; return RC.OK; }
internal static RC JournalVFileCreate(VFile file) { if (file.Type != 2) return RC.OK; return ((JournalVFile)file).CreateFile(); }
//#if ENABLE_ATOMIC_WRITE // static int JournalOpen(VSystem vfs, string a, VFile b, int c, int d) { return 0; } // static int JournalSize(VSystem vfs) { return 0; } // static int JournalCreate(VFile v) { return 0; } // static bool JournalExists(VFile v) { return true; } //#else // static int JournalSize(VSystem vfs) { return vfs.SizeOsFile; } // static bool JournalExists(VFile v) { return true; } //#endif #endregion Other #if ENABLE_ATOMIC_WRITE internal static bool HasJournalVFile(VFile file) { return (file.Type != 2 || ((JournalVFile)file).Real != null); }
internal static bool HasMemoryVFile(VFile file) { return(file.Type == 1); }
public abstract RC Open(string path, VFile file, OPEN flags, out OPEN outFlags);
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; }
internal static RC Open(VSystem x, VFile y, string z) { return RC.OK; }
static RC BackupTruncateFile(VFile file, int size) { long current; RC rc = file.get_FileSize(out current); if (rc == RC.OK && current > size) rc = file.Truncate(size); return rc; }
internal static bool HasMemoryVFile(VFile file) { return (file.Type == 1); }