コード例 #1
0
        /*
        ** Register a VFS with the system.  It is harmless to register the same
        ** VFS multiple times.  The new VFS becomes the default if makeDflt is
        ** true.
        */
        static public int sqlite3_vfs_register(sqlite3_vfs pVfs, int makeDflt)
        {
            sqlite3_mutex mutex;

#if !SQLITE_OMIT_AUTOINIT
            int rc = sqlite3_initialize();
            if (rc != 0)
            {
                return(rc);
            }
#endif
            mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
            sqlite3_mutex_enter(mutex);
            vfsUnlink(pVfs);
            if (makeDflt != 0 || vfsList == null)
            {
                pVfs.pNext = vfsList;
                vfsList    = pVfs;
            }
            else
            {
                pVfs.pNext    = vfsList.pNext;
                vfsList.pNext = pVfs;
            }
            Debug.Assert(vfsList != null);
            sqlite3_mutex_leave(mutex);
            return(SQLITE_OK);
        }
コード例 #2
0
/*
** Open a journal file.
*/
        int sqlite3JournalOpen(
            sqlite3_vfs pVfs,  /* The VFS to use for actual file I/O */
            string zName,      /* Name of the journal file */
            sqlite3_file pJfd, /* Preallocated, blank file handle */
            int flags,         /* Opening flags */
            int nBuf           /* Bytes buffered before opening the file */
            )
        {
            JournalFile p = (JournalFile )pJfd;

            memset(p, 0, sqlite3JournalSize(pVfs));
            if (nBuf > 0)
            {
                p.zBuf = sqlite3MallocZero(nBuf);
                if (null == p.zBuf)
                {
                    return(SQLITE_NOMEM);
                }
            }
            else
            {
                return(sqlite3OsOpen(pVfs, zName, pJfd, flags, 0));
            }
            p.pMethod  = JournalFileMethods;
            p.nBuf     = nBuf;
            p.flags    = flags;
            p.zJournal = zName;
            p.pVfs     = pVfs;
            return(SQLITE_OK);
        }
コード例 #3
0
        static public sqlite3_vfs sqlite3_vfs_find(string zVfs)
        {
            sqlite3_vfs pVfs = null;

#if SQLITE_THREADSAFE
            sqlite3_mutex mutex;
#endif
#if !SQLITE_OMIT_AUTOINIT
            int rc = sqlite3_initialize();
            if (rc != 0)
            {
                return(null);
            }
#endif
#if SQLITE_THREADSAFE
            mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
#endif
            sqlite3_mutex_enter(mutex);
            for (pVfs = vfsList; pVfs != null; pVfs = pVfs.pNext)
            {
                if (zVfs == null || zVfs == "")
                {
                    break;
                }
                if (zVfs == pVfs.zName)
                {
                    break; //strcmp(zVfs, pVfs.zName) == null) break;
                }
            }
            sqlite3_mutex_leave(mutex);
            return(pVfs);
        }
コード例 #4
0
        static int sqlite3OsOpenMalloc(
            ref sqlite3_vfs pVfs,
            string zFile,
            ref sqlite3_file ppFile,
            int flags,
            ref int pOutFlags
            )
        {
            int          rc = SQLITE_NOMEM;
            sqlite3_file pFile;

            pFile = new sqlite3_file(); //sqlite3Malloc(ref pVfs.szOsFile);
            if (pFile != null)
            {
                rc = sqlite3OsOpen(pVfs, zFile, pFile, flags, ref pOutFlags);
                if (rc != SQLITE_OK)
                {
                    pFile = null; // was  sqlite3DbFree(db,ref  pFile);
                }
                else
                {
                    ppFile = pFile;
                }
            }
            return(rc);
        }
コード例 #5
0
 /*
 ** Get the sector size of the device used to store
 ** file.
 */
 static int getSectorSize(
     sqlite3_vfs pVfs,
     string zRelative /* UTF-8 file name */
     )
 {
     return(SQLITE_DEFAULT_SECTOR_SIZE);
 }
コード例 #6
0
/*
** Populate the buffer pointed to by zBufOut with nByte bytes of
** random data.
*/
        static int vfstraceRandomness(sqlite3_vfs pVfs, int nByte, byte[] zBufOut)
        {
            vfstrace_info pInfo = (vfstrace_info)pVfs.pAppData;
            sqlite3_vfs   pRoot = pInfo.pRootVfs;

            vfstrace_printf(pInfo, "%s.xRandomness(%d)\n", pInfo.zVfsName, nByte);
            return(pRoot.xRandomness(pRoot, nByte, zBufOut));
        }
コード例 #7
0
        static string vfstraceNextSystemCall(sqlite3_vfs pVfs, string zName)
        {
            vfstrace_info pInfo = (vfstrace_info)pVfs.pAppData;
            sqlite3_vfs   pRoot = pInfo.pRootVfs;

            Debugger.Break();
            //return pRoot.xNextSystemCall(pRoot, zName);
            return("");
        }
コード例 #8
0
/*
** Close the dynamic library handle pHandle.
*/
        static void vfstraceDlClose(sqlite3_vfs pVfs, object pHandle)
        {
            vfstrace_info pInfo = (vfstrace_info)pVfs.pAppData;
            sqlite3_vfs   pRoot = pInfo.pRootVfs;

            vfstrace_printf(pInfo, "%s.xDlOpen()\n", pInfo.zVfsName);
            Debugger.Break();
            //  pRoot.xDlClose( pRoot, pHandle );
        }
コード例 #9
0
/*
** Populate the buffer zErrMsg (size nByte bytes) with a human readable
** utf-8 string describing the most recent error encountered associated
** with dynamic libraries.
*/
        static void vfstraceDlError(sqlite3_vfs pVfs, int nByte, string zErrMsg)
        {
            vfstrace_info pInfo = (vfstrace_info)pVfs.pAppData;
            sqlite3_vfs   pRoot = pInfo.pRootVfs;

            vfstrace_printf(pInfo, "%s.xDlError(%d)", pInfo.zVfsName, nByte);
            pRoot.xDlError(pRoot, nByte, zErrMsg);
            vfstrace_printf(pInfo, " . \"%s\"", zErrMsg);
        }
コード例 #10
0
/*
** Return th3 emost recent error code and message
*/
        static int vfstraceGetLastError(sqlite3_vfs pVfs, int iErr, string zErr)
        {
            vfstrace_info pInfo = (vfstrace_info)pVfs.pAppData;
            sqlite3_vfs   pRoot = pInfo.pRootVfs;

            Debugger.Break();
            //return pRoot.xGetLastError(pRoot, iErr, zErr);
            return(0);
        }
コード例 #11
0
ファイル: os_c.cs プロジェクト: ehsan2022002/VirastarE
        /*
        ** Unregister a VFS so that it is no longer accessible.
        */
        static int sqlite3_vfs_unregister(sqlite3_vfs pVfs)
        {
#if SQLITE_THREADSAFE
            sqlite3_mutex mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
#endif
            sqlite3_mutex_enter(mutex);
            vfsUnlink(pVfs);
            sqlite3_mutex_leave(mutex);
            return(SQLITE_OK);
        }
コード例 #12
0
/*
** Return a pointer to the symbol zSymbol in the dynamic library pHandle.
*/
        static void vfstraceDlSym(sqlite3_vfs pVfs, object p, string zSym)
        {
            vfstrace_info pInfo = (vfstrace_info)pVfs.pAppData;
            sqlite3_vfs   pRoot = pInfo.pRootVfs;

            vfstrace_printf(pInfo, "%s.xDlSym(\"%s\")\n", pInfo.zVfsName, zSym);
            Debugger.Break();
            //return pRoot.xDlSym(pRoot, p, zSym);
            return;
        }
コード例 #13
0
/*
** Open the dynamic library located at zPath and return a handle.
*/
        static void vfstraceDlOpen(sqlite3_vfs pVfs, string zPath)
        {
            vfstrace_info pInfo = (vfstrace_info)pVfs.pAppData;
            sqlite3_vfs   pRoot = pInfo.pRootVfs;

            vfstrace_printf(pInfo, "%s.xDlOpen(\"%s\")\n", pInfo.zVfsName, zPath);
            Debugger.Break();//TODO
            //return pRoot.xDlOpen(pRoot, zPath);
            return;
        }
コード例 #14
0
ファイル: os_c.cs プロジェクト: ehsan2022002/VirastarE
 static int sqlite3OsFullPathname(
     sqlite3_vfs pVfs,
     string zPath,
     int nPathOut,
     StringBuilder zPathOut
     )
 {
     zPathOut.Length = 0;//zPathOut[0] = 0;
     return(pVfs.xFullPathname(pVfs, zPath, nPathOut, zPathOut));
 }
コード例 #15
0
/*
** Override system calls.
*/
        static int vfstraceSetSystemCall(
            sqlite3_vfs pVfs,
            string zName,
            sqlite3_int64 pFunc //sqlite3_syscall_ptr pFunc
            )
        {
            vfstrace_info pInfo = (vfstrace_info)pVfs.pAppData;
            sqlite3_vfs   pRoot = pInfo.pRootVfs;

            return(pRoot.xSetSystemCall(pRoot, zName, pFunc));
        }
コード例 #16
0
/*
** Delete the file located at zPath. If the dirSync argument is true,
** ensure the file-system modifications are synced to disk before
** returning.
*/
        static int vfstraceDelete(sqlite3_vfs pVfs, string zPath, int dirSync)
        {
            vfstrace_info pInfo = (vfstrace_info)pVfs.pAppData;
            sqlite3_vfs   pRoot = pInfo.pRootVfs;
            int           rc;

            vfstrace_printf(pInfo, "%s.xDelete(\"%s\",%d)",
                            pInfo.zVfsName, zPath, dirSync);
            rc = pRoot.xDelete(pRoot, zPath, dirSync);
            vfstrace_print_errcode(pInfo, " . %s\n", rc);
            return(rc);
        }
コード例 #17
0
/*
** Open an vfstrace file handle.
*/
        static int vfstraceOpen(
            sqlite3_vfs pVfs,
            string zName,
            sqlite3_file pFile,
            int flags,
            int pOutFlags
            )
        {
            int rc = 0;

            Debugger.Break(); //TODO
//  vfstrace_file p = (vfstrace_file )pFile;
//  vfstrace_info pInfo = (vfstrace_info)pVfs.pAppData;
//  sqlite3_vfs pRoot = pInfo.pRootVfs;
//  p.pInfo = pInfo;
//  p.zFName = zName ? fileTail(zName) : "<temp>";
//  p.pReal = (sqlite3_file )&p[1];
//  rc = pRoot.xOpen(pRoot, zName, p.pReal, flags, pOutFlags);
//  vfstrace_printf(pInfo, "%s.xOpen(%s,flags=0x%x)",
//                  pInfo.zVfsName, p.zFName, flags);
//  if( p.pReal.pMethods ){
//    sqlite3_io_methods pNew = new sqlite3_io_methods();//sqlite3_malloc( sizeof(*pNew) );
//    sqlite3_io_methods pSub = p.pReal.pMethods;
//    //memset(pNew, 0, sizeof(*pNew));
//    pNew.iVersion = pSub.iVersion;
//    pNew.xClose = vfstraceClose;
//    pNew.xRead = vfstraceRead;
//    pNew.xWrite = vfstraceWrite;
//    pNew.xTruncate = vfstraceTruncate;
//    pNew.xSync = vfstraceSync;
//    pNew.xFileSize = vfstraceFileSize;
//    pNew.xLock = vfstraceLock;
//    pNew.xUnlock = vfstraceUnlock;
//    pNew.xCheckReservedLock = vfstraceCheckReservedLock;
//    pNew.xFileControl = vfstraceFileControl;
//    pNew.xSectorSize = vfstraceSectorSize;
//    pNew.xDeviceCharacteristics = vfstraceDeviceCharacteristics;
//    if( pNew.iVersion>=2 ){
//      pNew.xShmMap = pSub.xShmMap ? vfstraceShmMap : 0;
//      pNew.xShmLock = pSub.xShmLock ? vfstraceShmLock : 0;
//      pNew.xShmBarrier = pSub.xShmBarrier ? vfstraceShmBarrier : 0;
//      pNew.xShmUnmap = pSub.xShmUnmap ? vfstraceShmUnmap : 0;
//    }
//    pFile.pMethods = pNew;
//  }
//  vfstrace_print_errcode(pInfo, " . %s", rc);
//  if( pOutFlags ){
//    vfstrace_printf(pInfo, ", refFlags=0x%x\n", pOutFlags);
//  }else{
//    vfstrace_printf(pInfo, "\n");
//  }
            return(rc);
        }
コード例 #18
0
        static sqlite3_int64 vfstraceGetSystemCall(//sqlite3_syscall_ptr vfstraceGetSystemCall(
            sqlite3_vfs pVfs,
            string zName
            )
        {
            vfstrace_info pInfo = (vfstrace_info)pVfs.pAppData;
            sqlite3_vfs   pRoot = pInfo.pRootVfs;

            Debugger.Break();
            //return pRoot.xGetSystemCall(pRoot, zName);
            return(0);
        }
コード例 #19
0
        /*
        ** Turn a relative pathname into a full pathname.  Write the full
        ** pathname into zOut[].  zOut[] will be at least pVfs.mxPathname
        ** bytes in size.
        */
        static int winFullPathname(
            sqlite3_vfs pVfs,     /* Pointer to vfs object */
            string zRelative,     /* Possibly relative input path */
            int nFull,            /* Size of output buffer in bytes */
            StringBuilder zFull   /* Output buffer */
            )
        {
            zFull.Append(zRelative);
            return(SQLITE_OK);

            int    nByte;
            string zOut = null;

            UNUSED_PARAMETER(nFull);
            //convertUtf8Filename(zRelative));
            if (isNT())
            {
                try
                {
                    zOut = Path.GetFullPath(zRelative); // was unicodeToUtf8(zTemp);
                }
                catch (IOException e)
                { zOut = zRelative; }
            }
            else
            {
                Debugger.Break(); // -- Not Running under NT
            }
            if (zOut != null)
            {
                // sqlite3_snprintf(pVfs.mxPathname, zFull, "%s", zOut);
                if (zFull.Length > pVfs.mxPathname)
                {
                    zFull.Length = pVfs.mxPathname;
                }
                zFull.Append(zOut);

                // will happen on exit; was   free(zOut);
                return(SQLITE_OK);
            }
            else
            {
                return(SQLITE_NOMEM);
            }
        }
コード例 #20
0
/*
** Test for access permissions. Return true if the requested permission
** is available, or false otherwise.
*/
        static int vfstraceAccess(
            sqlite3_vfs pVfs,
            string zPath,
            int flags,
            int pResOut
            )
        {
            vfstrace_info pInfo = (vfstrace_info)pVfs.pAppData;
            sqlite3_vfs   pRoot = pInfo.pRootVfs;
            int           rc;

            vfstrace_printf(pInfo, "%s.xDelete(\"%s\",%d)",
                            pInfo.zVfsName, zPath, flags);
            rc = pRoot.xAccess(pRoot, zPath, flags, out pResOut);
            vfstrace_print_errcode(pInfo, " . %s", rc);
            vfstrace_printf(pInfo, ", ref=%d\n", pResOut);
            return(rc);
        }
コード例 #21
0
/*
** Populate buffer zOut with the full canonical pathname corresponding
** to the pathname in zPath. zOut is guaranteed to point to a buffer
** of at least (DEVSYM_MAX_PATHNAME+1) bytes.
*/
        static int vfstraceFullPathname(
            sqlite3_vfs pVfs,
            string zPath,
            int nOut,
            StringBuilder zOut
            )
        {
            vfstrace_info pInfo = (vfstrace_info)pVfs.pAppData;
            sqlite3_vfs   pRoot = pInfo.pRootVfs;
            int           rc;

            vfstrace_printf(pInfo, "%s.xFullPathname(\"%s\")",
                            pInfo.zVfsName, zPath);
            rc = pRoot.xFullPathname(pRoot, zPath, nOut, zOut);
            vfstrace_print_errcode(pInfo, " . %s", rc);
            vfstrace_printf(pInfo, ", ref=\"%.*s\"\n", nOut, zOut);
            return(rc);
        }
コード例 #22
0
ファイル: os_c.cs プロジェクト: ehsan2022002/VirastarE
        /*
        ** The next group of routines are convenience wrappers around the
        ** VFS methods.
        */
        static int sqlite3OsOpen(
            sqlite3_vfs pVfs,
            string zPath,
            sqlite3_file pFile,
            int flags,
            ref int pFlagsOut
            )
        {
            int rc;

            DO_OS_MALLOC_TEST(null);

            /* 0x87f3f is a mask of SQLITE_OPEN_ flags that are valid to be passed
            ** down into the VFS layer.  Some SQLITE_OPEN_ flags (for example,
            ** SQLITE_OPEN_FULLMUTEX or SQLITE_OPEN_SHAREDCACHE) are blocked before
            ** reaching the VFS. */
            rc = pVfs.xOpen(pVfs, zPath, pFile, flags & 0x87f3f, out pFlagsOut);
            Debug.Assert(rc == SQLITE_OK || pFile.pMethods == null);
            return(rc);
        }
コード例 #23
0
ファイル: os_c.cs プロジェクト: ehsan2022002/VirastarE
        static int sqlite3OsCurrentTimeInt64(sqlite3_vfs pVfs, ref sqlite3_int64 pTimeOut)
        {
            int rc;

            /* IMPLEMENTATION-OF: R-49045-42493 SQLite will use the xCurrentTimeInt64()
            ** method to get the current date and time if that method is available
            ** (if iVersion is 2 or greater and the function pointer is not NULL) and
            ** will fall back to xCurrentTime() if xCurrentTimeInt64() is
            ** unavailable.
            */
            if (pVfs.iVersion >= 2 && pVfs.xCurrentTimeInt64 != null)
            {
                rc = pVfs.xCurrentTimeInt64(pVfs, ref pTimeOut);
            }
            else
            {
                double r = 0;
                rc       = pVfs.xCurrentTime(pVfs, ref r);
                pTimeOut = (sqlite3_int64)(r * 86400000.0);
            }
            return(rc);
        }
コード例 #24
0
        static int winRandomness(sqlite3_vfs pVfs, int nBuf, ref byte[] zBuf)
        {
            int n = 0;

            UNUSED_PARAMETER(pVfs);

            byte[] sBuf = BitConverter.GetBytes(System.DateTime.Now.Ticks);
            zBuf[0] = sBuf[0];
            zBuf[1] = sBuf[1];
            zBuf[2] = sBuf[2];
            zBuf[3] = sBuf[3];
            ;        // memcpy(&zBuf[n], x, sizeof(x))
            n += 16; // sizeof(x);
            if (sizeof(DWORD) <= nBuf - n)
            {
//DWORD pid = GetCurrentProcessId();
                u32 processId;
                processId = 28376023;

                put32bits(zBuf, n, processId); //(memcpy(&zBuf[n], pid, sizeof(pid));
                n += 4;                        // sizeof(pid);
            }
            if (sizeof(DWORD) <= nBuf - n)
            {
//DWORD cnt = GetTickCount();
                System.DateTime dt = new System.DateTime();
                put32bits(zBuf, n, (u32)dt.Ticks); // memcpy(&zBuf[n], cnt, sizeof(cnt));
                n += 4;                            // cnt.Length;
            }
            if (sizeof(long) <= nBuf - n)
            {
                long i;
                i = System.DateTime.UtcNow.Millisecond;    // QueryPerformanceCounter(out i);
                put32bits(zBuf, n, (u32)(i & 0xFFFFFFFF)); //memcpy(&zBuf[n], i, sizeof(i));
                put32bits(zBuf, n, (u32)(i >> 32));
                n += sizeof(long);
            }
            return(n);
        }
コード例 #25
0
        /*
        ** The following variable, if set to a non-zero value, becomes the result
        ** returned from sqlite3OsCurrentTime().  This is used for testing.
        **
        ** /*
        ** Find the current time (in Universal Coordinated Time).  Write the
        ** current time and date as a Julian Day number into prNow and
        ** return 0.  Return 1 if the time and date cannot be found.
        */
        static int winCurrentTime(sqlite3_vfs pVfs, ref double prNow)
        {
            sqlite3_int64 timeW; /* Whole days */
            sqlite3_int64 timeF; /* Fractional Days */

            /* Number of 100-nanosecond intervals in a single day */
            const sqlite3_int64 ntuPerDay =
                10000000 * (sqlite3_int64)86400;

            /* Number of 100-nanosecond intervals in half of a day */
            const sqlite3_int64 ntuPerHalfDay =
                10000000 * (sqlite3_int64)43200;

            timeW = System.DateTime.UtcNow.ToFileTime();
            timeF = timeW % ntuPerDay;           /* fractional days (100-nanoseconds) */
            timeW = timeW / ntuPerDay;           /* whole days */
            timeW = timeW + 2305813;             /* add whole days (from 2305813.5) */
            timeF = timeF + ntuPerHalfDay;       /* add half a day (from 2305813.5) */
            timeW = timeW + (timeF / ntuPerDay); /* add whole day if half day made one */
            timeF = timeF % ntuPerDay;           /* compute new fractional days */
            prNow = (double)timeW + ((double)timeF / (double)ntuPerDay);
            return(0);
        }
コード例 #26
0
ファイル: os_c.cs プロジェクト: ehsan2022002/VirastarE
 /*
 ** Unlink a VFS from the linked list
 */
 static void vfsUnlink(sqlite3_vfs pVfs)
 {
     Debug.Assert(sqlite3_mutex_held(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER)));
     if (pVfs == null)
     {
         /* No-op */
     }
     else if (vfsList == pVfs)
     {
         vfsList = pVfs.pNext;
     }
     else if (vfsList != null)
     {
         sqlite3_vfs p = vfsList;
         while (p.pNext != null && p.pNext != pVfs)
         {
             p = p.pNext;
         }
         if (p.pNext == pVfs)
         {
             p.pNext = pVfs.pNext;
         }
     }
 }
コード例 #27
0
ファイル: os_c.cs プロジェクト: pragmat1c/coolstorage
 static int sqlite3OsRandomness( sqlite3_vfs pVfs, int nByte, ref byte[] zBufOut )
 {
   return pVfs.xRandomness( pVfs, nByte, ref zBufOut );
 }
コード例 #28
0
        /*
        ** Open a file.
        */
        static int winOpen(
            sqlite3_vfs pVfs,   /* Not used */
            string zName,       /* Name of the file (UTF-8) */
            sqlite3_file pFile, /* Write the SQLite file handle here */
            int flags,          /* Open mode flags */
            ref int pOutFlags   /* Status return flags */
            )
        {
            if (pFile.fs != null)
            {
                return(SQLITE_OK);
            }
            //HANDLE h;
            //pFile.fs = null;
            //fs = null;
            FileAccess    dwDesiredAccess;
            FileShare     dwShareMode;
            FileMode      dwCreationDisposition;
            string        zConverted;                                  /* Filename in OS encoding */
            string        zUtf8Name = zName;                           /* Filename in UTF-8 encoding */
            StringBuilder zTmpname  = new StringBuilder(MAX_PATH + 1); /* Buffer used to create temp filename */

            Debug.Assert(pFile != null);
            UNUSED_PARAMETER(pVfs);

            /* If the second argument to this function is NULL, generate a
            ** temporary file name to use
            */
            if (String.IsNullOrEmpty(zUtf8Name))
            {
                int rc = getTempname(MAX_PATH + 1, zTmpname);
                if (rc != SQLITE_OK)
                {
                    return(rc);
                }
                zUtf8Name = zTmpname.ToString();
            }

            // /* Convert the filename to the system encoding. */
            zConverted = zUtf8Name;// convertUtf8Filename( zUtf8Name );
            if (String.IsNullOrEmpty(zConverted))
            {
                return(SQLITE_NOMEM);
            }

            if ((flags & SQLITE_OPEN_READWRITE) != 0)
            {
                dwDesiredAccess = FileAccess.Read | FileAccess.Write; // GENERIC_READ | GENERIC_WRITE;
            }
            else
            {
                dwDesiredAccess = FileAccess.Read; // GENERIC_READ;
            }

            /* SQLITE_OPEN_EXCLUSIVE is used to make sure that a new file is
            ** created. SQLite doesn't use it to indicate "exclusive access"
            ** as it is usually understood.
            */
            Debug.Assert(0 == (flags & SQLITE_OPEN_EXCLUSIVE) || (flags & SQLITE_OPEN_CREATE) != 0);
            if ((flags & SQLITE_OPEN_EXCLUSIVE) != 0)
            {
                /* Creates a new file, only if it does not already exist. */
                /* If the file exists, it fails. */
                dwCreationDisposition = FileMode.CreateNew;// CREATE_NEW;
            }
            else if ((flags & SQLITE_OPEN_CREATE) != 0)
            {
                /* Open existing file, or create if it doesn't exist */
                dwCreationDisposition = FileMode.OpenOrCreate;// OPEN_ALWAYS;
            }
            else
            {
                /* Opens a file, only if it exists. */
                dwCreationDisposition = FileMode.Open;      //OPEN_EXISTING;
            }
            dwShareMode = FileShare.Read | FileShare.Write; // FILE_SHARE_READ | FILE_SHARE_WRITE;
            if ((flags & SQLITE_OPEN_DELETEONCLOSE) != 0)
            {
            }
            else
            {
            }

            /* Reports from the internet are that performance is always
            ** better if FILE_FLAG_RANDOM_ACCESS is used.  Ticket #2699. */
            if (isNT())
            {
                int retries = 3;
                //while ( ( pFile.fs == null ) && ( retries > 0 ) )
                while ((pFile.fs == null) && (retries > 0))
                {
                    try
                    {
                        retries--;
                        //pFile.fs = new IsolatedStorageFileStream(zConverted, dwCreationDisposition, dwDesiredAccess, dwShareMode, pFile.store);
                        //pFile.fs = new IsolatedStorageFileStream(zConverted, dwCreationDisposition, dwDesiredAccess, dwShareMode, store);
                        pFile.fs = new IsolatedStorageFileStream(zConverted, FileMode.OpenOrCreate, dwDesiredAccess, dwShareMode, store);
                    }
                    catch (Exception e)
                    {
                        Thread.Sleep(100);
                    }
                }

                /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed.
                ** Since the ASCII version of these Windows API do not exist for WINCE,
                ** it's important to not reference them for WINCE builds.
                */
            }
            //if ( pFile.fs == null
            if (pFile.fs == null
                ||
                //!pFile.fs.CanRead
                !pFile.fs.CanRead
                )
            {
                if ((flags & SQLITE_OPEN_READWRITE) != 0)
                {
                    return(winOpen(pVfs, zName, pFile,
                                   ((flags | SQLITE_OPEN_READONLY) & ~SQLITE_OPEN_READWRITE), ref pOutFlags));
                }
                else
                {
                    return(SQLITE_CANTOPEN_BKPT());
                }
            }
            if ((flags & SQLITE_OPEN_READWRITE) != 0)
            {
                pOutFlags = SQLITE_OPEN_READWRITE;
            }
            else
            {
                pOutFlags = SQLITE_OPEN_READONLY;
            }
            //}
            pFile.Clear(); // memset(pFile, 0, sizeof(*pFile));
            pFile.pMethods   = winIoMethod;
            pFile.lastErrno  = NO_ERROR;
            pFile.sectorSize = (ulong)getSectorSize(pVfs, zUtf8Name);
            return(SQLITE_OK);
        }
コード例 #29
0
ファイル: wal_h.cs プロジェクト: RainsSoft/CsharpSQLite
		//# define sqlite3WalLimit(x,y)
		static void sqlite3WalLimit(sqlite3_vfs x, long y)
		{
		}
コード例 #30
0
ファイル: os_c.cs プロジェクト: pragmat1c/coolstorage
    /*
    ** Register a VFS with the system.  It is harmless to register the same
    ** VFS multiple times.  The new VFS becomes the default if makeDflt is
    ** true.
    */
    static int sqlite3_vfs_register( sqlite3_vfs pVfs, int makeDflt )
    {
      sqlite3_mutex mutex;
#if !SQLITE_OMIT_AUTOINIT
      int rc = sqlite3_initialize();
      if ( rc != 0 )
        return rc;
#endif
      mutex = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_MASTER );
      sqlite3_mutex_enter( mutex );
      vfsUnlink( pVfs );
      if ( makeDflt != 0 || vfsList == null )
      {
        pVfs.pNext = vfsList;
        vfsList = pVfs;
      }
      else
      {
        pVfs.pNext = vfsList.pNext;
        vfsList.pNext = pVfs;
      }
      Debug.Assert( vfsList != null );
      sqlite3_mutex_leave( mutex );
      return SQLITE_OK;
    }
コード例 #31
0
ファイル: wal_h.cs プロジェクト: RainsSoft/CsharpSQLite
/* Open and close a connection to a write-ahead log. */
int sqlite3WalOpen(sqlite3_vfs*, sqlite3_file*, string , int, i64, Wal*);
コード例 #32
0
ファイル: os_c.cs プロジェクト: pragmat1c/coolstorage
 static int sqlite3OsDelete( sqlite3_vfs pVfs, string zPath, int dirSync )
 {
   return pVfs.xDelete( pVfs, zPath, dirSync );
 }
コード例 #33
0
ファイル: os_c.cs プロジェクト: pragmat1c/coolstorage
 static int sqlite3OsOpenMalloc(
 ref sqlite3_vfs pVfs,
 string zFile,
 ref sqlite3_file ppFile,
 int flags,
 ref int pOutFlags
 )
 {
   int rc = SQLITE_NOMEM;
   sqlite3_file pFile;
   pFile = new sqlite3_file(); //sqlite3Malloc(ref pVfs.szOsFile);
   if ( pFile != null )
   {
     rc = sqlite3OsOpen( pVfs, zFile, pFile, flags, ref pOutFlags );
     if ( rc != SQLITE_OK )
     {
       pFile = null; // was  sqlite3DbFree(db,ref  pFile);
     }
     else
     {
       ppFile = pFile;
     }
   }
   return rc;
 }
コード例 #34
0
/*
** Populate the buffer pointed to by zBufOut with nByte bytes of 
** random data.
*/
static int vfstraceRandomness(sqlite3_vfs pVfs, int nByte, byte[] zBufOut){
  vfstrace_info pInfo = (vfstrace_info)pVfs.pAppData;
  sqlite3_vfs pRoot = pInfo.pRootVfs;
  vfstrace_printf(pInfo, "%s.xRandomness(%d)\n", pInfo.zVfsName, nByte);
  return pRoot.xRandomness( pRoot, nByte, zBufOut );
}
コード例 #35
0
ファイル: os_c.cs プロジェクト: pragmat1c/coolstorage
 /*
 ** The next group of routines are convenience wrappers around the
 ** VFS methods.
 */
 static int sqlite3OsOpen(
 sqlite3_vfs pVfs,
 string zPath,
 sqlite3_file pFile,
 int flags,
 ref int pFlagsOut
 )
 {
   int rc;
   DO_OS_MALLOC_TEST( null );
   /* 0x87f3f is a mask of SQLITE_OPEN_ flags that are valid to be passed
   ** down into the VFS layer.  Some SQLITE_OPEN_ flags (for example,
   ** SQLITE_OPEN_FULLMUTEX or SQLITE_OPEN_SHAREDCACHE) are blocked before
   ** reaching the VFS. */
   rc = pVfs.xOpen( pVfs, zPath, pFile, flags & 0x87f3f, ref pFlagsOut );
   Debug.Assert( rc == SQLITE_OK || pFile.pMethods == null );
   return rc;
 }
コード例 #36
0
ファイル: sqlite3_h.cs プロジェクト: hanahanaside/JPN
 public void CopyTo(sqlite3_vfs ct)
 {
   ct.iVersion = this.iVersion;
   ct.szOsFile = this.szOsFile;
   ct.mxPathname = this.mxPathname;
   ct.pNext = this.pNext;
   ct.zName = this.zName;
   ct.pAppData = this.pAppData;
   ct.xOpen = this.xOpen;
   ct.xDelete = this.xDelete;
   ct.xAccess = this.xAccess;
   ct.xFullPathname = this.xFullPathname;
   ct.xDlOpen = this.xDlOpen;
   ct.xDlError = this.xDlError;
   ct.xDlSym = this.xDlSym;
   ct.xDlClose = this.xDlClose;
   ct.xRandomness = this.xRandomness;
   ct.xSleep = this.xSleep;
   ct.xCurrentTime = this.xCurrentTime;
   ct.xGetLastError = this.xGetLastError;
   ct.xCurrentTimeInt64 = this.xCurrentTimeInt64;
 }
コード例 #37
0
ファイル: journal_c.cs プロジェクト: RainsSoft/CsharpSQLite
/*
** Return the number of bytes required to store a JournalFile that uses vfs
** pVfs to create the underlying on-disk files.
*/
int sqlite3JournalSize(sqlite3_vfs pVfs){
return (pVfs->szOsFile+sizeof(JournalFile));
}
コード例 #38
0
        /*
        ** Check the existence and status of a file.
        */
        static int winAccess(
            sqlite3_vfs pVfs, /* Not used on win32 */
            string zFilename, /* Name of file to check */
            int flags,        /* Type of test to make on this file */
            ref int pResOut   /* OUT: Result */
            )
        {
            pResOut = 1;
            return(SQLITE_OK);

            //FileAttributes attr = 0; // DWORD attr;
            //int rc = 0;
            //UNUSED_PARAMETER( pVfs );
            //    if (flags == SQLITE_ACCESS_EXISTS)
            //    {
            //        pResOut =store.FileExists(zFilename) ? 1 : 0;
            //        return SQLITE_OK;
            //    }

            //    try
            //    {
            //        if (store.DirectoryExists(zFilename))
            //        {
            //            StringBuilder zTmpname = new StringBuilder(255);        /* Buffer used to create temp filename */
            //            getTempname(256, zTmpname);

            //            string zTempFilename;
            //            zTempFilename = zTmpname.ToString();//( SQLITE_TEMP_FILE_PREFIX.Length + 1 );
            //            try
            //            {
            //                IsolatedStorageFileStream fs = store.CreateFile(zTempFilename);
            //                fs.Close();
            //                fs = null;
            //                store.DeleteFile(zTempFilename);
            //                attr = FileAttributes.Normal;
            //            }
            //            catch (IOException e) { attr = FileAttributes.ReadOnly; }
            //        }
            //    }
            //    catch (IOException e)
            //    {
            //    }

            ////  free(zConverted);
            //switch ( flags )
            //{
            //  case SQLITE_ACCESS_READ:
            //  case SQLITE_ACCESS_EXISTS:
            //    rc = attr != 0 ? 1 : 0;// != INVALID_FILE_ATTRIBUTES;
            //    break;
            //  case SQLITE_ACCESS_READWRITE:
            //    rc = attr == 0 ? 0 : (int)( attr & FileAttributes.ReadOnly ) != 0 ? 0 : 1; //FILE_ATTRIBUTE_READONLY ) == 0;
            //    break;
            //  default:
            //    Debug.Assert( "" == "Invalid flags argument" );
            //    rc = 0;
            //    break;
            //}
            //pResOut = rc;
            //return SQLITE_OK;
        }
コード例 #39
0
ファイル: os_c.cs プロジェクト: pragmat1c/coolstorage
 static int sqlite3OsSleep( sqlite3_vfs pVfs, int nMicro )
 {
   return pVfs.xSleep( pVfs, nMicro );
 }
コード例 #40
0
ファイル: os_c.cs プロジェクト: pragmat1c/coolstorage
 static int sqlite3OsAccess( sqlite3_vfs pVfs, string zPath, int flags, ref int pResOut )
 {
   DO_OS_MALLOC_TEST( null );
   return pVfs.xAccess( pVfs, zPath, flags, ref pResOut );
 }
コード例 #41
0
ファイル: os_c.cs プロジェクト: pragmat1c/coolstorage
 static int sqlite3OsCurrentTimeInt64( sqlite3_vfs pVfs, ref sqlite3_int64 pTimeOut )
 {
   int rc;
   /* IMPLEMENTATION-OF: R-49045-42493 SQLite will use the xCurrentTimeInt64()
   ** method to get the current date and time if that method is available
   ** (if iVersion is 2 or greater and the function pointer is not NULL) and
   ** will fall back to xCurrentTime() if xCurrentTimeInt64() is
   ** unavailable.
   */
   if ( pVfs.iVersion >= 2 && pVfs.xCurrentTimeInt64 != null )
   {
     rc = pVfs.xCurrentTimeInt64( pVfs, ref pTimeOut );
   }
   else
   {
     double r = 0;
     rc = pVfs.xCurrentTime( pVfs, ref r );
     pTimeOut = (sqlite3_int64)( r * 86400000.0 );
   }
   return rc;
 }
コード例 #42
0
ファイル: os_c.cs プロジェクト: pragmat1c/coolstorage
 static int sqlite3OsFullPathname(
 sqlite3_vfs pVfs,
 string zPath,
 int nPathOut,
 StringBuilder zPathOut
 )
 {
   zPathOut.Length = 0;//zPathOut[0] = 0;
   return pVfs.xFullPathname( pVfs, zPath, nPathOut, zPathOut );
 }
コード例 #43
0
ファイル: os_c.cs プロジェクト: pragmat1c/coolstorage
 /*
 ** Unlink a VFS from the linked list
 */
 static void vfsUnlink( sqlite3_vfs pVfs )
 {
   Debug.Assert( sqlite3_mutex_held( sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_MASTER ) ) );
   if ( pVfs == null )
   {
     /* No-op */
   }
   else if ( vfsList == pVfs )
   {
     vfsList = pVfs.pNext;
   }
   else if ( vfsList != null )
   {
     sqlite3_vfs p = vfsList;
     while ( p.pNext != null && p.pNext != pVfs )
     {
       p = p.pNext;
     }
     if ( p.pNext == pVfs )
     {
       p.pNext = pVfs.pNext;
     }
   }
 }
コード例 #44
0
ファイル: os_c.cs プロジェクト: pragmat1c/coolstorage
 static HANDLE sqlite3OsDlOpen( sqlite3_vfs pVfs, string zPath )
 {
   return pVfs.xDlOpen( pVfs, zPath );
 }
コード例 #45
0
ファイル: os_c.cs プロジェクト: pragmat1c/coolstorage
    /*
    ** Unregister a VFS so that it is no longer accessible.
    */
    static int sqlite3_vfs_unregister( sqlite3_vfs pVfs )
    {
#if SQLITE_THREADSAFE
      sqlite3_mutex mutex = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_MASTER );
#endif
      sqlite3_mutex_enter( mutex );
      vfsUnlink( pVfs );
      sqlite3_mutex_leave( mutex );
      return SQLITE_OK;
    }
コード例 #46
0
ファイル: os_c.cs プロジェクト: pragmat1c/coolstorage
 static void sqlite3OsDlError( sqlite3_vfs pVfs, int nByte, string zBufOut )
 {
   pVfs.xDlError( pVfs, nByte, zBufOut );
 }
コード例 #47
0
ファイル: wal_h.cs プロジェクト: RainsSoft/CsharpSQLite
		/*
		** 2010 February 1
		**
		** The author disclaims copyright to this source code.  In place of
		** a legal notice, here is a blessing:
		**
		**    May you do good and not evil.
		**    May you find forgiveness for yourself and forgive others.
		**    May you share freely, never taking more than you give.
		**
		*************************************************************************
		** This header file defines the interface to the write-ahead logging 
		** system. Refer to the comments below and the header comment attached to 
		** the implementation of each function in log.c for further details.
		*************************************************************************
		**  Included in SQLite3 port to C#-SQLite;  2008 Noah B Hart
		**  C#-SQLite is an independent reimplementation of the SQLite software library
		**
		**  SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2
		**
		*************************************************************************
		*/

		//#if !_WAL_H_
		//#define _WAL_H_

		//#include "sqliteInt.h"

#if SQLITE_OMIT_WAL

		//# define sqlite3WalOpen(x,y,z)                 0
		static int sqlite3WalOpen(sqlite3_vfs x, sqlite3_file y, string z)
		{
			return 0;
		}
コード例 #48
0
ファイル: os_c.cs プロジェクト: pragmat1c/coolstorage
 static object sqlite3OsDlSym( sqlite3_vfs pVfs, HANDLE pHdle, ref string zSym )
 {
   return pVfs.xDlSym( pVfs, pHdle, zSym );
 }
コード例 #49
0
/*
** Close the dynamic library handle pHandle.
*/
static void vfstraceDlClose(sqlite3_vfs pVfs, object  pHandle){
  vfstrace_info pInfo = (vfstrace_info)pVfs.pAppData;
  sqlite3_vfs pRoot = pInfo.pRootVfs;
  vfstrace_printf(pInfo, "%s.xDlOpen()\n", pInfo.zVfsName);
  Debugger.Break();
  //  pRoot.xDlClose( pRoot, pHandle );
}
コード例 #50
0
ファイル: os_c.cs プロジェクト: pragmat1c/coolstorage
 static void sqlite3OsDlClose( sqlite3_vfs pVfs, HANDLE pHandle )
 {
   pVfs.xDlClose( pVfs, pHandle );
 }
コード例 #51
0
static int vfstraceCurrentTimeInt64(sqlite3_vfs pVfs, sqlite_int64 pTimeOut){
  vfstrace_info pInfo = (vfstrace_info)pVfs.pAppData;
  sqlite3_vfs pRoot = pInfo.pRootVfs;
  return pRoot.xCurrentTimeInt64(pRoot, ref pTimeOut);
}
コード例 #52
0
/*
** Sleep for nMicro microseconds. Return the number of microseconds 
** actually slept.
*/
static int vfstraceSleep(sqlite3_vfs pVfs, int nMicro){
  vfstrace_info pInfo = (vfstrace_info)pVfs.pAppData;
  sqlite3_vfs pRoot = pInfo.pRootVfs;
  return pRoot.xSleep(pRoot, nMicro);
}
コード例 #53
0
        static int winDelete(
            sqlite3_vfs pVfs, /* Not used on win32 */
            string zFilename, /* Name of file to delete */
            int syncDir       /* Not used on win32 */
            )
        {
            int cnt = 0;
            int rc;
            int error;

            UNUSED_PARAMETER(pVfs);
            UNUSED_PARAMETER(syncDir);
            string zConverted = convertUtf8Filename(zFilename);

            if (zConverted == null || zConverted == "")
            {
                return(SQLITE_NOMEM);
            }
            if (isNT())
            {
                do
                {
                    if (!ExistsFile(zFilename))
                    {
                        rc = SQLITE_IOERR;
                        break;
                    }
                    try
                    {
                        DeleteFile(zConverted);
                        rc = SQLITE_OK;
                    }
                    catch (IOException e)
                    {
                        rc = SQLITE_IOERR;
                        Thread.Sleep(100);
                    }
                } while (rc != SQLITE_OK && ++cnt < MX_DELETION_ATTEMPTS);

                /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed.
                ** Since the ASCII version of these Windows API do not exist for WINCE,
                ** it's important to not reference them for WINCE builds.
                */
            }
            else
            {
                do
                {
                    if (!ExistsFile(zFilename))
                    {
                        rc = SQLITE_IOERR;
                        break;
                    }
                    try
                    {
                        DeleteFile(zConverted);
                        rc = SQLITE_OK;
                    }
                    catch (IOException e)
                    {
                        rc = SQLITE_IOERR;
                        Thread.Sleep(100);
                    }
                } while (rc != SQLITE_OK && cnt++ < MX_DELETION_ATTEMPTS);
            }
            //free(zConverted);
#if SQLITE_DEBUG
            OSTRACE2("DELETE \"%s\"\n", zFilename);
#endif
            //return ( ( rc == INVALID_FILE_ATTRIBUTES )
            //&& ( error == ERROR_FILE_NOT_FOUND ) ) ? SQLITE_OK : SQLITE_IOERR_DELETE;
            return(rc);
        }
コード例 #54
0
/*
** Return th3 emost recent error code and message
*/
static int vfstraceGetLastError(sqlite3_vfs pVfs, int iErr, string zErr){
  vfstrace_info pInfo = (vfstrace_info)pVfs.pAppData;
  sqlite3_vfs pRoot = pInfo.pRootVfs;
  Debugger.Break();
  //return pRoot.xGetLastError(pRoot, iErr, zErr);
  return 0;
}
コード例 #55
0
ファイル: journal_c.cs プロジェクト: RainsSoft/CsharpSQLite
/*
** Open a journal file.
*/
int sqlite3JournalOpen(
sqlite3_vfs pVfs,         /* The VFS to use for actual file I/O */
string zName,         /* Name of the journal file */
sqlite3_file pJfd,        /* Preallocated, blank file handle */
int flags,                 /* Opening flags */
int nBuf                   /* Bytes buffered before opening the file */
){
JournalFile p = (JournalFile )pJfd;
memset(p, 0, sqlite3JournalSize(pVfs));
if( nBuf>0 ){
p.zBuf = sqlite3MallocZero(nBuf);
if( null==p.zBuf ){
return SQLITE_NOMEM;
}
}else{
return sqlite3OsOpen(pVfs, zName, pJfd, flags, 0);
}
p.pMethod = JournalFileMethods;
p.nBuf = nBuf;
p.flags = flags;
p.zJournal = zName;
p.pVfs = pVfs;
return SQLITE_OK;
}
コード例 #56
0
/*
** Override system calls.
*/
static int vfstraceSetSystemCall(
  sqlite3_vfs pVfs,
  string zName,
  sqlite3_int64 pFunc //sqlite3_syscall_ptr pFunc
){
  vfstrace_info pInfo = (vfstrace_info)pVfs.pAppData;
  sqlite3_vfs pRoot = pInfo.pRootVfs;
  return pRoot.xSetSystemCall(pRoot, zName, pFunc);
}
コード例 #57
0
ファイル: sqlite3_h.cs プロジェクト: hanahanaside/JPN
 public sqlite3_vfs( int iVersion,
 int szOsFile,
 int mxPathname,
 sqlite3_vfs pNext,
 string zName,
 object pAppData,
 dxOpen xOpen,
 dxDelete xDelete,
 dxAccess xAccess,
 dxFullPathname xFullPathname,
 dxDlOpen xDlOpen,
 dxDlError xDlError,
 dxDlSym xDlSym,
 dxDlClose xDlClose,
 dxRandomness xRandomness,
 dxSleep xSleep,
 dxCurrentTime xCurrentTime,
 dxGetLastError xGetLastError,
 dxCurrentTimeInt64 xCurrentTimeInt64,
 dxSetSystemCall xSetSystemCall,
 dxGetSystemCall xGetSystemCall,
 dxNextSystemCall xNextSystemCall)
 {
   this.iVersion = iVersion;
   this.szOsFile = szOsFile;
   this.mxPathname = mxPathname;
   this.pNext = pNext;
   this.zName = zName;
   this.pAppData = pAppData;
   this.xOpen = xOpen;
   this.xDelete = xDelete;
   this.xAccess = xAccess;
   this.xFullPathname = xFullPathname;
   this.xDlOpen = xDlOpen;
   this.xDlError = xDlError;
   this.xDlSym = xDlSym;
   this.xDlClose = xDlClose;
   this.xRandomness = xRandomness;
   this.xSleep = xSleep;
   this.xCurrentTime = xCurrentTime;
   this.xGetLastError = xGetLastError;
   this.xCurrentTimeInt64 = xCurrentTimeInt64;
 }
コード例 #58
0
static sqlite3_int64 vfstraceGetSystemCall(//sqlite3_syscall_ptr vfstraceGetSystemCall(
  sqlite3_vfs pVfs,
  string zName
){
  vfstrace_info pInfo = (vfstrace_info)pVfs.pAppData;
  sqlite3_vfs pRoot = pInfo.pRootVfs;
  Debugger.Break();
  //return pRoot.xGetSystemCall(pRoot, zName);
  return 0;
}
コード例 #59
0
/*
** Return the number of bytes required to store a JournalFile that uses vfs
** pVfs to create the underlying on-disk files.
*/
        int sqlite3JournalSize(sqlite3_vfs pVfs)
        {
            return(pVfs->szOsFile + sizeof(JournalFile));
        }
コード例 #60
0
static string vfstraceNextSystemCall(sqlite3_vfs pVfs, string zName){
  vfstrace_info pInfo = (vfstrace_info)pVfs.pAppData;
  sqlite3_vfs pRoot = pInfo.pRootVfs;
  Debugger.Break();
  //return pRoot.xNextSystemCall(pRoot, zName);
  return "";
}