Example #1
0
        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);
        }
Example #2
0
 internal static RC JournalVFileCreate(VFile file)
 {
     if (file.Type != 2)
     {
         return(RC.OK);
     }
     return(((JournalVFile)file).CreateFile());
 }
Example #3
0
        // 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);
        }
Example #4
0
 internal static void MemoryVFileOpen(ref VFile file)
 {
     file      = new MemoryVFile();
     file.Type = 1;
 }
Example #5
0
 internal bool HasJournalVFile(VFile file)
 {
     return(true);
 }
Example #6
0
 internal static bool HasJournalVFile(VFile file)
 {
     return(file.Type != 2 || ((JournalVFile)file).Real != null);
 }
Example #7
0
 internal static void MemoryVFileOpen(ref VFile file)
 {
     file = new MemoryVFile();
     file.Type = 1;
 }
Example #8
0
 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;
     }
 }
Example #9
0
 internal bool HasJournalVFile(VFile file)
 {
     return true;
 }
Example #10
0
 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);
 }
Example #11
0
 // 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;
 }
Example #12
0
 internal static RC JournalVFileCreate(VFile file)
 {
     if (file.Type != 2)
         return RC.OK;
     return ((JournalVFile)file).CreateFile();
 }
Example #13
0
        //#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);
        }
Example #14
0
 internal static bool HasMemoryVFile(VFile file)
 {
     return(file.Type == 1);
 }
Example #15
0
 public abstract RC Open(string path, VFile file, OPEN flags, out OPEN outFlags);
Example #16
0
 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;
 }
Example #17
0
 internal static RC Open(VSystem x, VFile y, string z)
 {
     return RC.OK;
 }
Example #18
0
 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;
 }
Example #19
0
 internal static bool HasMemoryVFile(VFile file)
 {
     return (file.Type == 1);
 }