/ Check-in [bda4c47d]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Several modifications to the use of the MAX_PATH macro on Windows to improve consistency.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | mmapDisabled
Files: files | file ages | folders
SHA1: bda4c47df8e80b4cc9e8aac8fd74482869f96107
User & Date: mistachkin 2013-08-24 23:55:01
Context
2013-08-26
19:36
Merge updates from trunk. check-in: 9d686009 user: mistachkin tags: mmapDisabled
2013-08-24
23:55
Several modifications to the use of the MAX_PATH macro on Windows to improve consistency. check-in: bda4c47d user: mistachkin tags: mmapDisabled
01:12
Fix a couple compilation issues on Unix. check-in: 25b029d8 user: mistachkin tags: mmapDisabled
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_win.c.

    46     46   ** Are most of the Win32 Unicode APIs available (i.e. with certain exceptions
    47     47   ** based on the sub-platform)?
    48     48   */
    49     49   #if SQLITE_OS_WINCE || SQLITE_OS_WINNT || SQLITE_OS_WINRT
    50     50   #  define SQLITE_WIN32_HAS_WIDE
    51     51   #endif
    52     52   
           53  +/*
           54  +** Maximum pathname length (in bytes) for Win32.  The MAX_PATH macro is in
           55  +** characters, so we allocate 3 bytes per character assuming worst-case of
           56  +** 3-bytes-per-character for UTF8.
           57  +*/
           58  +#ifndef SQLITE_WIN32_MAX_PATH
           59  +#  define SQLITE_WIN32_MAX_PATH   (MAX_PATH*3)
           60  +#endif
           61  +
           62  +/*
           63  +** Maximum error message length (in bytes) for WinRT.  The MAX_PATH macro is
           64  +** in characters, so we allocate 3 bytes per character assuming worst-case of
           65  +** 3-bytes-per-character for UTF8.
           66  +*/
           67  +#ifndef SQLITE_WIN32_MAX_ERRMSG
           68  +#  define SQLITE_WIN32_MAX_ERRMSG (MAX_PATH*3)
           69  +#endif
           70  +
    53     71   /*
    54     72   ** Do we need to manually define the Win32 file mapping APIs for use with WAL
    55     73   ** mode (e.g. these APIs are available in the Windows CE SDK; however, they
    56     74   ** are not present in the header file)?
    57     75   */
    58     76   #if SQLITE_WIN32_FILEMAPPING_API && !defined(SQLITE_OMIT_WAL)
    59     77   /*
................................................................................
  1459   1477     ** buffer, excluding the terminating null char.
  1460   1478     */
  1461   1479     DWORD dwLen = 0;
  1462   1480     char *zOut = 0;
  1463   1481   
  1464   1482     if( isNT() ){
  1465   1483   #if SQLITE_OS_WINRT
  1466         -    WCHAR zTempWide[MAX_PATH+1]; /* NOTE: Somewhat arbitrary. */
         1484  +    WCHAR zTempWide[SQLITE_WIN32_MAX_ERRMSG+1]; /* NOTE: Somewhat arbitrary. */
  1467   1485       dwLen = osFormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM |
  1468   1486                                FORMAT_MESSAGE_IGNORE_INSERTS,
  1469   1487                                NULL,
  1470   1488                                lastErrno,
  1471   1489                                0,
  1472   1490                                zTempWide,
  1473         -                             MAX_PATH,
         1491  +                             SQLITE_WIN32_MAX_ERRMSG,
  1474   1492                                0);
  1475   1493   #else
  1476   1494       LPWSTR zTempWide = NULL;
  1477   1495       dwLen = osFormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
  1478   1496                                FORMAT_MESSAGE_FROM_SYSTEM |
  1479   1497                                FORMAT_MESSAGE_IGNORE_INSERTS,
  1480   1498                                NULL,
................................................................................
  3864   3882       zConverted = sqlite3_win32_utf8_to_mbcs(zFilename);
  3865   3883     }
  3866   3884   #endif
  3867   3885     /* caller will handle out of memory */
  3868   3886     return zConverted;
  3869   3887   }
  3870   3888   
  3871         -/*
  3872         -** Maximum pathname length (in bytes) for windows.  The MAX_PATH macro is
  3873         -** in characters, so we allocate 3 bytes per character assuming worst-case
  3874         -** 3-bytes-per-character UTF8.
  3875         -*/
  3876         -#ifndef SQLITE_WIN32_MAX_PATH
  3877         -#  define SQLITE_WIN32_MAX_PATH   (MAX_PATH*3)
  3878         -#endif
  3879         -
  3880   3889   /*
  3881   3890   ** Create a temporary file name in zBuf.  zBuf must be big enough to
  3882   3891   ** hold at pVfs->mxPathname characters.
  3883   3892   */
  3884   3893   static int getTempname(int nBuf, char *zBuf){
  3885   3894     static char zChars[] =
  3886   3895       "abcdefghijklmnopqrstuvwxyz"
................................................................................
  3899   3908     if( sqlite3_temp_directory ){
  3900   3909       sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s",
  3901   3910                        sqlite3_temp_directory);
  3902   3911     }
  3903   3912   #if !SQLITE_OS_WINRT
  3904   3913     else if( isNT() ){
  3905   3914       char *zMulti;
  3906         -    WCHAR zWidePath[MAX_PATH];
  3907         -    if( osGetTempPathW(MAX_PATH-30, zWidePath)==0 ){
         3915  +    WCHAR zWidePath[SQLITE_WIN32_MAX_PATH];
         3916  +    if( osGetTempPathW(SQLITE_WIN32_MAX_PATH-30, zWidePath)==0 ){
  3908   3917         OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
  3909   3918         return SQLITE_IOERR_GETTEMPPATH;
  3910   3919       }
  3911   3920       zMulti = unicodeToUtf8(zWidePath);
  3912   3921       if( zMulti ){
  3913   3922         sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zMulti);
  3914   3923         sqlite3_free(zMulti);