/ Check-in [5276e31d]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Removed some more dead code and fixed some unresolved externals for WINCE. Ticket #3420. (CVS 5837)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 5276e31d42070e7b94bd6050c4fa484dfbfe98ca
User & Date: shane 2008-10-22 16:55:47
Context
2008-10-22
18:27
Updated configure/makefiles to handle SQLITE_ENABLE* compile options. Made sure makefile passes command line options (OPTS=-Dfoo) to the compiler. Add -DSQLITE_COVERAGE_TEST=1 if gcov being used. (CVS 5838) check-in: acb106e5 user: shane tags: trunk
16:55
Removed some more dead code and fixed some unresolved externals for WINCE. Ticket #3420. (CVS 5837) check-in: 5276e31d user: shane tags: trunk
16:26
Make sure variable declarations occur first in code blocks. (CVS 5836) check-in: b78f44c9 user: shane tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_win.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   ******************************************************************************
    12     12   **
    13     13   ** This file contains code that is specific to windows.
    14     14   **
    15         -** $Id: os_win.c,v 1.135 2008/10/12 02:27:39 shane Exp $
           15  +** $Id: os_win.c,v 1.136 2008/10/22 16:55:47 shane Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   #if SQLITE_OS_WIN               /* This file is used for windows only */
    19     19   
    20     20   
    21     21   /*
    22     22   ** A Note About Memory Allocation:
................................................................................
    69     69   # define INVALID_FILE_ATTRIBUTES ((DWORD)-1) 
    70     70   #endif
    71     71   
    72     72   /*
    73     73   ** Determine if we are dealing with WindowsCE - which has a much
    74     74   ** reduced API.
    75     75   */
    76         -#if defined(SQLITE_OS_WINCE)
           76  +#if SQLITE_OS_WINCE
    77     77   # define AreFileApisANSI() 1
    78     78   #endif
    79     79   
    80     80   /*
    81     81   ** WinCE lacks native support for file locking so we have to fake it
    82     82   ** with some code of our own.
    83     83   */
................................................................................
   786    786     if( isNT() ){
   787    787       OVERLAPPED ovlp;
   788    788       ovlp.Offset = SHARED_FIRST;
   789    789       ovlp.OffsetHigh = 0;
   790    790       ovlp.hEvent = 0;
   791    791       res = LockFileEx(pFile->h, LOCKFILE_FAIL_IMMEDIATELY,
   792    792                        0, SHARED_SIZE, 0, &ovlp);
          793  +/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. 
          794  +*/
          795  +#if SQLITE_OS_WINCE==0
   793    796     }else{
   794    797       int lk;
   795    798       sqlite3_randomness(sizeof(lk), &lk);
   796    799       pFile->sharedLockByte = (lk & 0x7fffffff)%(SHARED_SIZE - 1);
   797    800       res = LockFile(pFile->h, SHARED_FIRST+pFile->sharedLockByte, 0, 1, 0);
          801  +#endif
   798    802     }
   799    803     return res;
   800    804   }
   801    805   
   802    806   /*
   803    807   ** Undo a readlock
   804    808   */
   805    809   static int unlockReadLock(winFile *pFile){
   806    810     int res;
   807    811     if( isNT() ){
   808    812       res = UnlockFile(pFile->h, SHARED_FIRST, 0, SHARED_SIZE, 0);
          813  +/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. 
          814  +*/
          815  +#if SQLITE_OS_WINCE==0
   809    816     }else{
   810    817       res = UnlockFile(pFile->h, SHARED_FIRST + pFile->sharedLockByte, 0, 1, 0);
          818  +#endif
   811    819     }
   812    820     return res;
   813    821   }
   814    822   
   815    823   /*
   816    824   ** Lock the file with the lock specified by parameter locktype - one
   817    825   ** of the following:
................................................................................
  1076   1084   ** is obtained from malloc and must be freed by the calling
  1077   1085   ** function.
  1078   1086   */
  1079   1087   static void *convertUtf8Filename(const char *zFilename){
  1080   1088     void *zConverted = 0;
  1081   1089     if( isNT() ){
  1082   1090       zConverted = utf8ToUnicode(zFilename);
         1091  +/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. 
         1092  +*/
         1093  +#if SQLITE_OS_WINCE==0
  1083   1094     }else{
  1084   1095       zConverted = utf8ToMbcs(zFilename);
         1096  +#endif
  1085   1097     }
  1086   1098     /* caller will handle out of memory */
  1087   1099     return zConverted;
  1088   1100   }
  1089   1101   
  1090   1102   /*
  1091   1103   ** Create a temporary file name in zBuf.  zBuf must be big enough to
................................................................................
  1107   1119       zMulti = unicodeToUtf8(zWidePath);
  1108   1120       if( zMulti ){
  1109   1121         sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zMulti);
  1110   1122         free(zMulti);
  1111   1123       }else{
  1112   1124         return SQLITE_NOMEM;
  1113   1125       }
         1126  +/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. 
         1127  +** Since the ASCII version of these Windows API do not exist for WINCE,
         1128  +** it's important to not reference them for WINCE builds.
         1129  +*/
         1130  +#if SQLITE_OS_WINCE==0
  1114   1131     }else{
  1115   1132       char *zUtf8;
  1116   1133       char zMbcsPath[MAX_PATH];
  1117   1134       GetTempPathA(MAX_PATH-30, zMbcsPath);
  1118   1135       zUtf8 = mbcsToUtf8(zMbcsPath);
  1119   1136       if( zUtf8 ){
  1120   1137         sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zUtf8);
  1121   1138         free(zUtf8);
  1122   1139       }else{
  1123   1140         return SQLITE_NOMEM;
  1124   1141       }
         1142  +#endif
  1125   1143     }
  1126   1144     for(i=strlen(zTempPath); i>0 && zTempPath[i-1]=='\\'; i--){}
  1127   1145     zTempPath[i] = 0;
  1128   1146     sqlite3_snprintf(nBuf-30, zBuf,
  1129   1147                      "%s\\"SQLITE_TEMP_FILE_PREFIX, zTempPath);
  1130   1148     j = strlen(zBuf);
  1131   1149     sqlite3_randomness(20, &zBuf[j]);
................................................................................
  1245   1263          dwDesiredAccess,
  1246   1264          dwShareMode,
  1247   1265          NULL,
  1248   1266          dwCreationDisposition,
  1249   1267          dwFlagsAndAttributes,
  1250   1268          NULL
  1251   1269       );
         1270  +/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. 
         1271  +** Since the ASCII version of these Windows API do not exist for WINCE,
         1272  +** it's important to not reference them for WINCE builds.
         1273  +*/
         1274  +#if SQLITE_OS_WINCE==0
  1252   1275     }else{
  1253   1276       h = CreateFileA((char*)zConverted,
  1254   1277          dwDesiredAccess,
  1255   1278          dwShareMode,
  1256   1279          NULL,
  1257   1280          dwCreationDisposition,
  1258   1281          dwFlagsAndAttributes,
  1259   1282          NULL
  1260   1283       );
         1284  +#endif
  1261   1285     }
  1262   1286     if( h==INVALID_HANDLE_VALUE ){
  1263   1287       free(zConverted);
  1264   1288       if( flags & SQLITE_OPEN_READWRITE ){
  1265   1289         return winOpen(0, zName, id, 
  1266   1290                ((flags|SQLITE_OPEN_READONLY)&~SQLITE_OPEN_READWRITE), pOutFlags);
  1267   1291       }else{
................................................................................
  1327   1351     if( isNT() ){
  1328   1352       do{
  1329   1353         DeleteFileW(zConverted);
  1330   1354       }while(   (   ((rc = GetFileAttributesW(zConverted)) != INVALID_FILE_ATTRIBUTES)
  1331   1355                  || ((error = GetLastError()) == ERROR_ACCESS_DENIED))
  1332   1356              && (++cnt < MX_DELETION_ATTEMPTS)
  1333   1357              && (Sleep(100), 1) );
         1358  +/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. 
         1359  +** Since the ASCII version of these Windows API do not exist for WINCE,
         1360  +** it's important to not reference them for WINCE builds.
         1361  +*/
         1362  +#if SQLITE_OS_WINCE==0
  1334   1363     }else{
  1335   1364       do{
  1336   1365         DeleteFileA(zConverted);
  1337   1366       }while(   (   ((rc = GetFileAttributesA(zConverted)) != INVALID_FILE_ATTRIBUTES)
  1338   1367                  || ((error = GetLastError()) == ERROR_ACCESS_DENIED))
  1339   1368              && (++cnt < MX_DELETION_ATTEMPTS)
  1340   1369              && (Sleep(100), 1) );
         1370  +#endif
  1341   1371     }
  1342   1372     free(zConverted);
  1343   1373     OSTRACE2("DELETE \"%s\"\n", zFilename);
  1344   1374     return (   (rc == INVALID_FILE_ATTRIBUTES) 
  1345   1375             && (error == ERROR_FILE_NOT_FOUND)) ? SQLITE_OK : SQLITE_IOERR_DELETE;
  1346   1376   }
  1347   1377   
................................................................................
  1358   1388     int rc;
  1359   1389     void *zConverted = convertUtf8Filename(zFilename);
  1360   1390     if( zConverted==0 ){
  1361   1391       return SQLITE_NOMEM;
  1362   1392     }
  1363   1393     if( isNT() ){
  1364   1394       attr = GetFileAttributesW((WCHAR*)zConverted);
         1395  +/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. 
         1396  +** Since the ASCII version of these Windows API do not exist for WINCE,
         1397  +** it's important to not reference them for WINCE builds.
         1398  +*/
         1399  +#if SQLITE_OS_WINCE==0
  1365   1400     }else{
  1366   1401       attr = GetFileAttributesA((char*)zConverted);
         1402  +#endif
  1367   1403     }
  1368   1404     free(zConverted);
  1369   1405     switch( flags ){
  1370   1406       case SQLITE_ACCESS_READ:
  1371   1407       case SQLITE_ACCESS_EXISTS:
  1372   1408         rc = attr!=INVALID_FILE_ATTRIBUTES;
  1373   1409         break;
................................................................................
  1418   1454         free(zConverted);
  1419   1455         return SQLITE_NOMEM;
  1420   1456       }
  1421   1457       GetFullPathNameW((WCHAR*)zConverted, nByte, zTemp, 0);
  1422   1458       free(zConverted);
  1423   1459       zOut = unicodeToUtf8(zTemp);
  1424   1460       free(zTemp);
         1461  +/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. 
         1462  +** Since the ASCII version of these Windows API do not exist for WINCE,
         1463  +** it's important to not reference them for WINCE builds.
         1464  +*/
         1465  +#if SQLITE_OS_WINCE==0
  1425   1466     }else{
  1426   1467       char *zTemp;
  1427   1468       nByte = GetFullPathNameA((char*)zConverted, 0, 0, 0) + 3;
  1428   1469       zTemp = malloc( nByte*sizeof(zTemp[0]) );
  1429   1470       if( zTemp==0 ){
  1430   1471         free(zConverted);
  1431   1472         return SQLITE_NOMEM;
  1432   1473       }
  1433   1474       GetFullPathNameA((char*)zConverted, nByte, zTemp, 0);
  1434   1475       free(zConverted);
  1435   1476       zOut = mbcsToUtf8(zTemp);
  1436   1477       free(zTemp);
         1478  +#endif
  1437   1479     }
  1438   1480     if( zOut ){
  1439   1481       sqlite3_snprintf(pVfs->mxPathname, zFull, "%s", zOut);
  1440   1482       free(zOut);
  1441   1483       return SQLITE_OK;
  1442   1484     }else{
  1443   1485       return SQLITE_NOMEM;
................................................................................
  1458   1500     HANDLE h;
  1459   1501     void *zConverted = convertUtf8Filename(zFilename);
  1460   1502     if( zConverted==0 ){
  1461   1503       return 0;
  1462   1504     }
  1463   1505     if( isNT() ){
  1464   1506       h = LoadLibraryW((WCHAR*)zConverted);
         1507  +/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. 
         1508  +** Since the ASCII version of these Windows API do not exist for WINCE,
         1509  +** it's important to not reference them for WINCE builds.
         1510  +*/
         1511  +#if SQLITE_OS_WINCE==0
  1465   1512     }else{
  1466   1513       h = LoadLibraryA((char*)zConverted);
         1514  +#endif
  1467   1515     }
  1468   1516     free(zConverted);
  1469   1517     return (void*)h;
  1470   1518   }
  1471   1519   static void winDlError(sqlite3_vfs *pVfs, int nBuf, char *zBufOut){
  1472   1520     getLastErrorMsg(nBuf, zBufOut);
  1473   1521   }