aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2012-05-07 13:15:20 +0000
committerdrh <drh@noemail.net>2012-05-07 13:15:20 +0000
commit1e039a240fa330cc14a33c5db56709b146db4b71 (patch)
treeeea9fa46355a3ff18658a5c9c5d939d197e52631 /src
parent7a9fc59efad39cc1780aa0ba6fb77414190c2ec3 (diff)
downloadsqlite-1e039a240fa330cc14a33c5db56709b146db4b71.tar.gz
sqlite-1e039a240fa330cc14a33c5db56709b146db4b71.zip
Do not do the AV retry loop on open if the file that is attempting to be
opened is really a directory. FossilOrigin-Name: 03875633f465e82fbe99829f96db25f6d32bd333
Diffstat (limited to 'src')
-rw-r--r--src/os_win.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/src/os_win.c b/src/os_win.c
index 358b70c12..0f3256193 100644
--- a/src/os_win.c
+++ b/src/os_win.c
@@ -3031,6 +3031,29 @@ static int getTempname(int nBuf, char *zBuf){
return SQLITE_OK;
}
+/* Forward reference */
+static int winAccess(sqlite3_vfs*,const char*,int,int*);
+
+/*
+** Return TRUE if the named file is really a directory. Return false if
+** it is something other than a directory, or if there is any kind of memory
+** allocation failure.
+*/
+static int winIsDir(sqlite3_vfs *pVfs, const char *zName){
+ int isDir = 0;
+ int rc;
+ char *zDirName;
+
+ zDirName = sqlite3_mprintf("%s/nul", zName);
+ if( zDirName ){
+ rc = winAccess(pVfs, zDirName, SQLITE_ACCESS_EXISTS, &isDir);
+ sqlite3_free(zDirName);
+ }else{
+ rc = SQLITE_NOMEM;
+ }
+ return rc==SQLITE_OK && isDir;
+}
+
/*
** Open a file.
*/
@@ -3185,12 +3208,11 @@ static int winOpen(
dwShareMode, NULL,
dwCreationDisposition,
dwFlagsAndAttributes,
- NULL))==INVALID_HANDLE_VALUE &&
- retryIoerr(&cnt, &lastErrno) ){}
-/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed.
-** Since the ANSI version of these Windows API do not exist for WINCE,
-** it's important to not reference them for WINCE builds.
-*/
+ NULL))==INVALID_HANDLE_VALUE
+ && !winIsDir(pVfs, zName)
+ && retryIoerr(&cnt, &lastErrno) ){
+ /* Noop */
+ }
#if SQLITE_OS_WINCE==0
}else{
while( (h = osCreateFileA((LPCSTR)zConverted,