1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-12 13:01:09 +03:00

Merge Windows directory checking changes from trunk.

FossilOrigin-Name: 7a7466f400e94d8c9e745efb2973300474a74d2a
This commit is contained in:
mistachkin
2012-05-07 20:28:19 +00:00
4 changed files with 106 additions and 28 deletions

View File

@@ -1,5 +1,5 @@
C Sync\sthe\slatest\strunk\schanges\sinto\sthe\swinRT\sbranch.
D 2012-05-04T23:11:21.989
C Merge\sWindows\sdirectory\schecking\schanges\sfrom\strunk.
D 2012-05-07T20:28:19.785
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -160,7 +160,7 @@ F src/os.h 38aabd5e3ecd4162332076f55bb09cec02165cca
F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440
F src/os_unix.c 424d46e0edab969293c2223f09923b2178171f47
F src/os_win.c c3487c9c506c1253bb4c65abc3caf988b9addb6c
F src/os_win.c ce348d158b43883c5b1495f68be3f654b7d0c503
F src/pager.c bb5635dde0b152797836d1c72275284724bb563c
F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5
F src/parse.y eb054bb40a5bf90d3422a01ed0e5df229461727a
@@ -175,7 +175,7 @@ F src/resolve.c 748e75299faff345f34f0e5bd02a2bac8aa69fcd
F src/rowset.c f6a49f3e9579428024662f6e2931832511f831a1
F src/select.c d7b9018b7dd2e821183d69477ab55c39b8272335
F src/shell.c 04399b2f9942bd02ed5ffee3b84bcdb39c52a1e6
F src/sqlite.h.in 21eb2ff783710a8cf2b435890dc1ffc750058169
F src/sqlite.h.in 457e6fb1eef84fbd97864c086499b1de64a05aa5
F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477
F src/sqliteInt.h c5e917c4f1453f3972b1fd0c81105dfe4f09cc32
F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
@@ -689,11 +689,11 @@ F test/shared6.test 866bb4982c45ce216c61ded5e8fde4e7e2f3ffa9
F test/shared7.test 960760bc8d03e1419e70dea69cf41db62853616e
F test/shared_err.test 91e26ec4f3fbe07951967955585137e2f18993de
F test/sharedlock.test ffa0a3c4ac192145b310f1254f8afca4d553eabf
F test/shell1.test 7dcd612b0018ddad783647d984fffa76791ffd3d w tool/shell1.test
F test/shell2.test 037d6ad16e873354195d30bb2dc4b5321788154a w tool/shell2.test
F test/shell3.test 9196c42772d575685e722c92b4b39053c6ebba59 w tool/shell3.test
F test/shell4.test aa4eef8118b412d1a01477a53426ece169ea86a9 w tool/shell4.test
F test/shell5.test fa2188bbb13fe2d183fd04a5f7b512650c35ef5d w tool/shell5.test
F test/shell1.test 7dcd612b0018ddad783647d984fffa76791ffd3d
F test/shell2.test 037d6ad16e873354195d30bb2dc4b5321788154a
F test/shell3.test 9196c42772d575685e722c92b4b39053c6ebba59
F test/shell4.test aa4eef8118b412d1a01477a53426ece169ea86a9
F test/shell5.test fa2188bbb13fe2d183fd04a5f7b512650c35ef5d
F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3
F test/shrink.test 8c70f62b6e8eb4d54533de6d65bd06b1b9a17868
F test/sidedelete.test f0ad71abe6233e3b153100f3b8d679b19a488329
@@ -995,7 +995,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
F tool/warnings-clang.sh a8a0a3babda96dfb1ff51adda3cbbf3dfb7266c2
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
P 25478dcff59690a5f59c3b96600374184057eae9 bfa61e781cb442be641486e7e55a1518e888d830
R ce5ef0f680ccee96865eacdf6d030fb3
U drh
Z e6cad85cf7d7f8dd84e66fcbcd8c3674
P be4ab188cffbe97ae4f1f0520591bb7f0df185de a4555a53eab3f5d2f142c78a6b71189544e80ae6
R d4541eb715733c4ea776ae24939baa95
U mistachkin
Z 7ca602c491f736ecdcb3f782ba71db3e

View File

@@ -1 +1 @@
be4ab188cffbe97ae4f1f0520591bb7f0df185de
7a7466f400e94d8c9e745efb2973300474a74d2a

View File

@@ -3404,6 +3404,35 @@ static int getTempname(int nBuf, char *zBuf){
return SQLITE_OK;
}
/*
** 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(const void *zConverted){
DWORD attr;
int rc = 0;
DWORD lastErrno;
if( isNT() ){
int cnt = 0;
WIN32_FILE_ATTRIBUTE_DATA sAttrData;
memset(&sAttrData, 0, sizeof(sAttrData));
while( !(rc = osGetFileAttributesExW((LPCWSTR)zConverted,
GetFileExInfoStandard,
&sAttrData)) && retryIoerr(&cnt, &lastErrno) ){}
if( !rc ){
return 0; /* Invalid name? */
}
attr = sAttrData.dwFileAttributes;
#if SQLITE_OS_WINCE==0
}else{
attr = osGetFileAttributesA((char*)zConverted);
#endif
}
return (attr!=INVALID_FILE_ATTRIBUTES) && (attr&FILE_ATTRIBUTE_DIRECTORY);
}
/*
** Open a file.
*/
@@ -3510,6 +3539,11 @@ static int winOpen(
return SQLITE_IOERR_NOMEM;
}
if( winIsDir(zConverted) ){
sqlite3_free(zConverted);
return SQLITE_CANTOPEN_ISDIR;
}
if( isReadWrite ){
dwDesiredAccess = GENERIC_READ | GENERIC_WRITE;
}else{
@@ -3567,7 +3601,9 @@ static int winOpen(
dwShareMode,
dwCreationDisposition,
&extendedParameters))==INVALID_HANDLE_VALUE &&
retryIoerr(&cnt, &lastErrno) ){}
retryIoerr(&cnt, &lastErrno) ){
/* Noop */
}
#else
while( (h = osCreateFileW((LPCWSTR)zConverted,
dwDesiredAccess,
@@ -3575,7 +3611,9 @@ static int winOpen(
dwCreationDisposition,
dwFlagsAndAttributes,
NULL))==INVALID_HANDLE_VALUE &&
retryIoerr(&cnt, &lastErrno) ){}
retryIoerr(&cnt, &lastErrno) ){
/* Noop */
}
#endif
}
#ifdef SQLITE_WIN32_HAS_ANSI
@@ -3586,7 +3624,9 @@ static int winOpen(
dwCreationDisposition,
dwFlagsAndAttributes,
NULL))==INVALID_HANDLE_VALUE &&
retryIoerr(&cnt, &lastErrno) ){}
retryIoerr(&cnt, &lastErrno) ){
/* Noop */
}
}
#endif
logIoerr(cnt);
@@ -3665,6 +3705,7 @@ static int winDelete(
){
int cnt = 0;
int rc;
DWORD attr;
DWORD lastErrno;
void *zConverted;
UNUSED_PARAMETER(pVfs);
@@ -3675,24 +3716,60 @@ static int winDelete(
if( zConverted==0 ){
return SQLITE_IOERR_NOMEM;
}
rc = 1;
if( isNT() ){
do {
#if SQLITE_OS_WINRT
WIN32_FILE_ATTRIBUTE_DATA sAttrData;
memset(&sAttrData, 0, sizeof(sAttrData));
while( osGetFileAttributesExW(zConverted, GetFileExInfoStandard,
&sAttrData) &&
if ( osGetFileAttributesExW(zConverted, GetFileExInfoStandard,
&sAttrData) ){
attr = sAttrData.dwFileAttributes;
}else{
rc = SQLITE_OK; /* Already gone? */
break;
}
#else
while( osGetFileAttributesW(zConverted)!=INVALID_FILE_ATTRIBUTES &&
attr = osGetFileAttributesW(zConverted);
#endif
(rc = osDeleteFileW(zConverted))==0 && retryIoerr(&cnt, &lastErrno) ){}
rc = rc ? SQLITE_OK : SQLITE_ERROR;
if ( attr==INVALID_FILE_ATTRIBUTES ){
rc = SQLITE_OK; /* Already gone? */
break;
}
if ( attr&FILE_ATTRIBUTE_DIRECTORY ){
rc = SQLITE_ERROR; /* Files only. */
break;
}
if ( osDeleteFileW(zConverted) ){
rc = SQLITE_OK; /* Deleted OK. */
break;
}
if ( !retryIoerr(&cnt, &lastErrno) ){
rc = SQLITE_ERROR; /* No more retries. */
break;
}
} while(1);
}
#ifdef SQLITE_WIN32_HAS_ANSI
else{
while( osGetFileAttributesA(zConverted)!=INVALID_FILE_ATTRIBUTES &&
(rc = osDeleteFileA(zConverted))==0 && retryIoerr(&cnt, &lastErrno) ){}
rc = rc ? SQLITE_OK : SQLITE_ERROR;
do {
attr = osGetFileAttributesA(zConverted);
if ( attr==INVALID_FILE_ATTRIBUTES ){
rc = SQLITE_OK; /* Already gone? */
break;
}
if ( attr&FILE_ATTRIBUTE_DIRECTORY ){
rc = SQLITE_ERROR; /* Files only. */
break;
}
if ( osDeleteFileA(zConverted) ){
rc = SQLITE_OK; /* Deleted OK. */
break;
}
if ( !retryIoerr(&cnt, &lastErrno) ){
rc = SQLITE_ERROR; /* No more retries. */
break;
}
} while(1);
}
#endif
if( rc ){

View File

@@ -453,6 +453,7 @@ int sqlite3_exec(
#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
#define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
#define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
#define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
#define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))