Пример #1
0
        internal override long GetBytes(SQLiteStatement stmt, int index, int nDataOffset, byte[] bDest, int nStart, int nLength)
        {
            int    length = nLength;
            int    num    = UnsafeNativeMethods.sqlite3_column_bytes((IntPtr)stmt._sqlite_stmt, index);
            IntPtr ptr    = UnsafeNativeMethods.sqlite3_column_blob((IntPtr)stmt._sqlite_stmt, index);

            if (bDest == null)
            {
                return((long)num);
            }
            if ((length + nStart) > bDest.Length)
            {
                length = bDest.Length - nStart;
            }
            if ((length + nDataOffset) > num)
            {
                length = num - nDataOffset;
            }
            if (length > 0)
            {
                Marshal.Copy((IntPtr)(ptr.ToInt64() + nDataOffset), bDest, nStart, length);
            }
            else
            {
                length = 0;
            }
            return((long)length);
        }
Пример #2
0
        internal override long GetBytes(SQLiteStatement stmt, int index, int nDataOffset, byte[] bDest, int nStart, int nLength)
        {
            IntPtr ptr;
            int    nlen;
            int    nCopied = nLength;

            nlen = UnsafeNativeMethods.sqlite3_column_bytes(stmt._sqlite_stmt, index);
            ptr  = UnsafeNativeMethods.sqlite3_column_blob(stmt._sqlite_stmt, index);

            if (bDest == null)
            {
                return(nlen);
            }

            if (nCopied + nStart > bDest.Length)
            {
                nCopied = bDest.Length - nStart;
            }
            if (nCopied + nDataOffset > nlen)
            {
                nCopied = nlen - nDataOffset;
            }

            if (nCopied > 0)
            {
                Marshal.Copy((IntPtr)(ptr.ToInt64() + nDataOffset), bDest, nStart, nCopied);
            }
            else
            {
                nCopied = 0;
            }

            return(nCopied);
        }