Ejemplo 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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
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;
 }