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