SQLite

Check-in [bda4c47df8]
Login

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
Timelines: family | ancestors | descendants | both | mmapDisabled
Files: files | file ages | folders
SHA1: bda4c47df8e80b4cc9e8aac8fd74482869f96107
User & Date: mistachkin 2013-08-24 23:55:01.356
Context
2013-08-26
19:36
Merge updates from trunk. (check-in: 9d6860098f 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: bda4c47df8 user: mistachkin tags: mmapDisabled)
01:12
Fix a couple compilation issues on Unix. (check-in: 25b029d8f3 user: mistachkin tags: mmapDisabled)
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to src/os_win.c.
46
47
48
49
50
51
52


















53
54
55
56
57
58
59
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







** Are most of the Win32 Unicode APIs available (i.e. with certain exceptions
** based on the sub-platform)?
*/
#if SQLITE_OS_WINCE || SQLITE_OS_WINNT || SQLITE_OS_WINRT
#  define SQLITE_WIN32_HAS_WIDE
#endif

/*
** Maximum pathname length (in bytes) for Win32.  The MAX_PATH macro is in
** characters, so we allocate 3 bytes per character assuming worst-case of
** 3-bytes-per-character for UTF8.
*/
#ifndef SQLITE_WIN32_MAX_PATH
#  define SQLITE_WIN32_MAX_PATH   (MAX_PATH*3)
#endif

/*
** Maximum error message length (in bytes) for WinRT.  The MAX_PATH macro is
** in characters, so we allocate 3 bytes per character assuming worst-case of
** 3-bytes-per-character for UTF8.
*/
#ifndef SQLITE_WIN32_MAX_ERRMSG
#  define SQLITE_WIN32_MAX_ERRMSG (MAX_PATH*3)
#endif

/*
** Do we need to manually define the Win32 file mapping APIs for use with WAL
** mode (e.g. these APIs are available in the Windows CE SDK; however, they
** are not present in the header file)?
*/
#if SQLITE_WIN32_FILEMAPPING_API && !defined(SQLITE_OMIT_WAL)
/*
1459
1460
1461
1462
1463
1464
1465
1466

1467
1468
1469
1470
1471
1472
1473

1474
1475
1476
1477
1478
1479
1480
1477
1478
1479
1480
1481
1482
1483

1484
1485
1486
1487
1488
1489
1490

1491
1492
1493
1494
1495
1496
1497
1498







-
+






-
+







  ** buffer, excluding the terminating null char.
  */
  DWORD dwLen = 0;
  char *zOut = 0;

  if( isNT() ){
#if SQLITE_OS_WINRT
    WCHAR zTempWide[MAX_PATH+1]; /* NOTE: Somewhat arbitrary. */
    WCHAR zTempWide[SQLITE_WIN32_MAX_ERRMSG+1]; /* NOTE: Somewhat arbitrary. */
    dwLen = osFormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM |
                             FORMAT_MESSAGE_IGNORE_INSERTS,
                             NULL,
                             lastErrno,
                             0,
                             zTempWide,
                             MAX_PATH,
                             SQLITE_WIN32_MAX_ERRMSG,
                             0);
#else
    LPWSTR zTempWide = NULL;
    dwLen = osFormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
                             FORMAT_MESSAGE_FROM_SYSTEM |
                             FORMAT_MESSAGE_IGNORE_INSERTS,
                             NULL,
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3882
3883
3884
3885
3886
3887
3888









3889
3890
3891
3892
3893
3894
3895







-
-
-
-
-
-
-
-
-







    zConverted = sqlite3_win32_utf8_to_mbcs(zFilename);
  }
#endif
  /* caller will handle out of memory */
  return zConverted;
}

/*
** Maximum pathname length (in bytes) for windows.  The MAX_PATH macro is
** in characters, so we allocate 3 bytes per character assuming worst-case
** 3-bytes-per-character UTF8.
*/
#ifndef SQLITE_WIN32_MAX_PATH
#  define SQLITE_WIN32_MAX_PATH   (MAX_PATH*3)
#endif

/*
** Create a temporary file name in zBuf.  zBuf must be big enough to
** hold at pVfs->mxPathname characters.
*/
static int getTempname(int nBuf, char *zBuf){
  static char zChars[] =
    "abcdefghijklmnopqrstuvwxyz"
3899
3900
3901
3902
3903
3904
3905
3906
3907


3908
3909
3910
3911
3912
3913
3914
3908
3909
3910
3911
3912
3913
3914


3915
3916
3917
3918
3919
3920
3921
3922
3923







-
-
+
+







  if( sqlite3_temp_directory ){
    sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s",
                     sqlite3_temp_directory);
  }
#if !SQLITE_OS_WINRT
  else if( isNT() ){
    char *zMulti;
    WCHAR zWidePath[MAX_PATH];
    if( osGetTempPathW(MAX_PATH-30, zWidePath)==0 ){
    WCHAR zWidePath[SQLITE_WIN32_MAX_PATH];
    if( osGetTempPathW(SQLITE_WIN32_MAX_PATH-30, zWidePath)==0 ){
      OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
      return SQLITE_IOERR_GETTEMPPATH;
    }
    zMulti = unicodeToUtf8(zWidePath);
    if( zMulti ){
      sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zMulti);
      sqlite3_free(zMulti);