/ Check-in [f677065a]
Login

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

Overview
Comment:Document and expose sqlite3_win32_set_directory() function for use on Win32.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | branch-3.23
Files: files | file ages | folders
SHA3-256:f677065aab61037914fc980456caaa60132a19b387d6d717ec1a6b6fa7c61a10
User & Date: mistachkin 2018-04-28 01:48:40
Context
2018-05-02
03:03
Add sqlite3_win32_set_directory8() and sqlite3_win32_set_directory16() functions. check-in: 6cf0f4e2 user: mistachkin tags: branch-3.23
2018-04-28
01:48
Document and expose sqlite3_win32_set_directory() function for use on Win32. check-in: f677065a user: mistachkin tags: branch-3.23
01:46
Document and expose sqlite3_win32_set_directory() function for use on Win32. check-in: 7626b593 user: mistachkin tags: trunk
01:37
Bump the version number to 3.23.2. check-in: 242dc910 user: drh tags: branch-3.23
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_win.c.

   311    311   /*
   312    312    * The size of the buffer used by sqlite3_win32_write_debug().
   313    313    */
   314    314   #ifndef SQLITE_WIN32_DBG_BUF_SIZE
   315    315   #  define SQLITE_WIN32_DBG_BUF_SIZE   ((int)(4096-sizeof(DWORD)))
   316    316   #endif
   317    317   
   318         -/*
   319         - * The value used with sqlite3_win32_set_directory() to specify that
   320         - * the data directory should be changed.
   321         - */
   322         -#ifndef SQLITE_WIN32_DATA_DIRECTORY_TYPE
   323         -#  define SQLITE_WIN32_DATA_DIRECTORY_TYPE (1)
   324         -#endif
   325         -
   326         -/*
   327         - * The value used with sqlite3_win32_set_directory() to specify that
   328         - * the temporary directory should be changed.
   329         - */
   330         -#ifndef SQLITE_WIN32_TEMP_DIRECTORY_TYPE
   331         -#  define SQLITE_WIN32_TEMP_DIRECTORY_TYPE (2)
   332         -#endif
   333         -
   334    318   /*
   335    319    * If compiled with SQLITE_WIN32_MALLOC on Windows, we will use the
   336    320    * various Win32 API heap functions instead of our own.
   337    321    */
   338    322   #ifdef SQLITE_WIN32_MALLOC
   339    323   
   340    324   /*
................................................................................
  1929   1913   /*
  1930   1914   ** This function sets the data directory or the temporary directory based on
  1931   1915   ** the provided arguments.  The type argument must be 1 in order to set the
  1932   1916   ** data directory or 2 in order to set the temporary directory.  The zValue
  1933   1917   ** argument is the name of the directory to use.  The return value will be
  1934   1918   ** SQLITE_OK if successful.
  1935   1919   */
  1936         -int sqlite3_win32_set_directory(DWORD type, LPCWSTR zValue){
         1920  +int sqlite3_win32_set_directory(
         1921  +  unsigned long type, /* Identifier for directory being set or reset */
         1922  +  void *zValue        /* New value for directory being set or reset */
         1923  +){
  1937   1924     char **ppDirectory = 0;
  1938   1925   #ifndef SQLITE_OMIT_AUTOINIT
  1939   1926     int rc = sqlite3_initialize();
  1940   1927     if( rc ) return rc;
  1941   1928   #endif
  1942   1929     if( type==SQLITE_WIN32_DATA_DIRECTORY_TYPE ){
  1943   1930       ppDirectory = &sqlite3_data_directory;
................................................................................
  1945   1932       ppDirectory = &sqlite3_temp_directory;
  1946   1933     }
  1947   1934     assert( !ppDirectory || type==SQLITE_WIN32_DATA_DIRECTORY_TYPE
  1948   1935             || type==SQLITE_WIN32_TEMP_DIRECTORY_TYPE
  1949   1936     );
  1950   1937     assert( !ppDirectory || sqlite3MemdebugHasType(*ppDirectory, MEMTYPE_HEAP) );
  1951   1938     if( ppDirectory ){
         1939  +    LPCWSTR zStrValue = zValue;
  1952   1940       char *zValueUtf8 = 0;
  1953         -    if( zValue && zValue[0] ){
  1954         -      zValueUtf8 = winUnicodeToUtf8(zValue);
         1941  +    if( zStrValue && zStrValue[0] ){
         1942  +      zValueUtf8 = winUnicodeToUtf8(zStrValue);
  1955   1943         if ( zValueUtf8==0 ){
  1956   1944           return SQLITE_NOMEM_BKPT;
  1957   1945         }
  1958   1946       }
  1959   1947       sqlite3_free(*ppDirectory);
  1960   1948       *ppDirectory = zValueUtf8;
  1961   1949       return SQLITE_OK;

Changes to src/sqlite.h.in.

  5488   5488   ** using [sqlite3_free].
  5489   5489   ** Hence, if this variable is modified directly, either it should be
  5490   5490   ** made NULL or made to point to memory obtained from [sqlite3_malloc]
  5491   5491   ** or else the use of the [data_store_directory pragma] should be avoided.
  5492   5492   */
  5493   5493   SQLITE_EXTERN char *sqlite3_data_directory;
  5494   5494   
         5495  +/*
         5496  +** CAPI3REF: Win32 Specific Interface
         5497  +**
         5498  +** These interfaces are available only on Windows.  The
         5499  +** [sqlite3_win32_set_directory] interface is used to set the value associated
         5500  +** with the [sqlite3_temp_directory] or [sqlite3_data_directory] variable, to
         5501  +** zValue, depending on the value of the type parameter.  The zValue parameter
         5502  +** should be NULL to cause the previous value to be freed via [sqlite3_free];
         5503  +** a non-NULL value will be copied into memory obtained from [sqlite3_malloc]
         5504  +** prior to being used.  The [sqlite3_win32_set_directory] interface returns
         5505  +** [SQLITE_OK] to indicate success, [SQLITE_ERROR] if the type is unsupported,
         5506  +** or [SQLITE_NOMEM] if memory could not be allocated.  The value of the
         5507  +** [sqlite3_data_directory] variable is intended to act as a replacement for
         5508  +** the current directory on the sub-platforms of Win32 where that concept is
         5509  +** not present, e.g. WinRT and UWP.
         5510  +*/
         5511  +int sqlite3_win32_set_directory(
         5512  +  unsigned long type, /* Identifier for directory being set or reset */
         5513  +  void *zValue        /* New value for directory being set or reset */
         5514  +);
         5515  +
         5516  +/*
         5517  +** CAPI3REF: Win32 Directory Types
         5518  +**
         5519  +** These macros are only available on Windows.  They define the allowed values
         5520  +** for the type argument to the [sqlite3_win32_set_directory] interface.
         5521  +*/
         5522  +#define SQLITE_WIN32_DATA_DIRECTORY_TYPE  1
         5523  +#define SQLITE_WIN32_TEMP_DIRECTORY_TYPE  2
         5524  +
  5495   5525   /*
  5496   5526   ** CAPI3REF: Test For Auto-Commit Mode
  5497   5527   ** KEYWORDS: {autocommit mode}
  5498   5528   ** METHOD: sqlite3
  5499   5529   **
  5500   5530   ** ^The sqlite3_get_autocommit() interface returns non-zero or
  5501   5531   ** zero if the given database connection is or is not in autocommit mode,