Beispiel #1
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_interop(stmt._sqlite_stmt, index);
            ptr  = UnsafeNativeMethods.sqlite3_column_blob_interop(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.ToInt32() + nDataOffset), bDest, nStart, nCopied);
            }
            else
            {
                nCopied = 0;
            }

            return(nCopied);
        }