From: mistachkin Date: Tue, 21 Aug 2012 23:33:45 +0000 (+0000) Subject: Added sqlite3_win32_set_directory API to assist in portability to WinRT. X-Git-Tag: version-3.7.14~19^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=61540688514ae7c9a45786e47b850d9cbec2d8e9;p=thirdparty%2Fsqlite.git Added sqlite3_win32_set_directory API to assist in portability to WinRT. FossilOrigin-Name: 600de08d40ceead24f425d20429d60f5732f8ba7 --- diff --git a/manifest b/manifest index 25c6e732c0..bc66c497d0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sthe\sspellfix\svirtual\stable\sso\sthat\sall\sOOM\serrors\sare\sreported\sout\nto\sthe\sapplication. -D 2012-08-21T17:44:05.685 +C Added\ssqlite3_win32_set_directory\sAPI\sto\sassist\sin\sportability\sto\sWinRT. +D 2012-08-21T23:33:45.221 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in abd5c10d21d1395f140d9e50ea999df8fa4d6376 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -163,7 +163,7 @@ F src/os.c e1acdc09ff3ac2412945cca9766e2dcf4675f31c F src/os.h 027491c77d2404c0a678bb3fb06286f331eb9b57 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_unix.c b5149a3343a6acd6c9df4e3acf5085a6501c1f68 -F src/os_win.c b8fc659987a678c7924796585f5ae293ba5c896d +F src/os_win.c c177b87e25e189a17f1f797d7c9c586874a44b90 F src/pager.c e381c118b77dc22021a1a59d3fec24815e91df78 F src/pager.h 8b8c9bc065a3c66769df8724dfdf492ee1aab3c5 F src/parse.y f29df90bd3adc64b33114ab1de9fb7768fcf2099 @@ -1011,7 +1011,10 @@ F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9 -P e799222f3b8246e65657a758437914ece7069ba9 -R 5e828b4451d9abd5424b5fdb18a303b8 -U drh -Z 86d779defb1a86a95d6cf62943de67e6 +P 573770f5a66fa4d708931b30350149eb739da607 +R bf4b4382f33c3f3a7bd23f2197ce7bd3 +T *branch * win32SetDir +T *sym-win32SetDir * +T -sym-trunk * +U mistachkin +Z fdab0a6682c0f1b3e699cc9646e4e11e diff --git a/manifest.uuid b/manifest.uuid index 4aa121d156..3391fa77f0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -573770f5a66fa4d708931b30350149eb739da607 \ No newline at end of file +600de08d40ceead24f425d20429d60f5732f8ba7 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index bb5fae133a..6684c9122e 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -105,6 +105,22 @@ struct winFile { # define SQLITE_WIN32_DBG_BUF_SIZE ((int)(4096-sizeof(DWORD))) #endif +/* + * The value used with sqlite3_win32_set_directory() to specify that + * the data directory should be changed. + */ +#ifndef SQLITE_WIN32_DATA_DIRECTORY_TYPE +# define SQLITE_WIN32_DATA_DIRECTORY_TYPE (1) +#endif + +/* + * The value used with sqlite3_win32_set_directory() to specify that + * the temporary directory should be changed. + */ +#ifndef SQLITE_WIN32_TEMP_DIRECTORY_TYPE +# define SQLITE_WIN32_TEMP_DIRECTORY_TYPE (2) +#endif + /* * If compiled with SQLITE_WIN32_MALLOC on Windows, we will use the * various Win32 API heap functions instead of our own. @@ -1318,6 +1334,41 @@ char *sqlite3_win32_utf8_to_mbcs(const char *zFilename){ return zFilenameMbcs; } +/* +** This function sets the data directory or the temporary directory based on +** the provided arguments. The type argument must be 1 in order to set the +** data directory or 2 in order to set the temporary directory. The zValue +** argument is the name of the directory to use. The return value will be +** SQLITE_OK if successful. +*/ +int sqlite3_win32_set_directory(DWORD type, LPCWSTR zValue){ + char **ppDirectory = 0; +#ifndef SQLITE_OMIT_AUTOINIT + int rc = sqlite3_initialize(); + if( rc ) return rc; +#endif + if( type==SQLITE_WIN32_DATA_DIRECTORY_TYPE ){ + ppDirectory = &sqlite3_data_directory; + }else if( type==SQLITE_WIN32_TEMP_DIRECTORY_TYPE ){ + ppDirectory = &sqlite3_temp_directory; + } + assert( !ppDirectory || type==SQLITE_WIN32_DATA_DIRECTORY_TYPE + || type==SQLITE_WIN32_TEMP_DIRECTORY_TYPE + ); + if( ppDirectory ){ + char *zValueUtf8 = 0; + if( zValue && zValue[0] ){ + zValueUtf8 = unicodeToUtf8(zValue); + if ( zValueUtf8==0 ){ + return SQLITE_NOMEM; + } + } + sqlite3_free(*ppDirectory); + *ppDirectory = zValueUtf8; + return SQLITE_OK; + } + return SQLITE_ERROR; +} /* ** The return value of getLastErrorMsg