Make the xAccess method of the unix VFS smaller and faster.

FossilOrigin-Name: 191aef986ffc4ef34d813e417e52a4ec820b0300
This commit is contained in:
drh
2015-11-25 18:03:33 +00:00
parent 5337dacbad
commit d260b5b2ce
3 changed files with 17 additions and 28 deletions
+6 -6
View File
@@ -1,5 +1,5 @@
C Remove\sunused\smethods\sfrom\sthe\sunix\sVFS.
D 2015-11-25T15:15:03.618
C Make\sthe\sxAccess\smethod\sof\sthe\sunix\sVFS\ssmaller\sand\sfaster.
D 2015-11-25T18:03:33.041
F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc e928e68168df69b353300ac87c10105206653a03
@@ -323,7 +323,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8
F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf
F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e
F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa
F src/os_unix.c a6ed7d9ae6e2308b61bd842d6aa296727d26b4fd
F src/os_unix.c 066d6f8e4ea9c9b82e93eef2daee3cf25759fa36
F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811
F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca
F src/pager.c 18341e2b759b447cbc82fb9215d08d9c5864e92e
@@ -1405,7 +1405,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P 2a20f793fdf6a2e88b679a7bd4e8ccf2935df049
R 9425887a4af2be1f5866057e942bff78
P 228bd15bbb7a1e6e3e0d03832e7f39ba169356a8
R e147c2a2e15689c8fb9a94a36196c06f
U drh
Z 8531bdf5b0fab73861e87c8c638f4398
Z 62ff0fd6ec1e0622890fd7a98828488f
+1 -1
View File
@@ -1 +1 @@
228bd15bbb7a1e6e3e0d03832e7f39ba169356a8
191aef986ffc4ef34d813e417e52a4ec820b0300
+10 -21
View File
@@ -5940,29 +5940,19 @@ static int unixAccess(
int flags, /* What do we want to learn about the zPath file? */
int *pResOut /* Write result boolean here */
){
int amode = 0;
UNUSED_PARAMETER(NotUsed);
SimulateIOError( return SQLITE_IOERR_ACCESS; );
switch( flags ){
case SQLITE_ACCESS_EXISTS:
amode = F_OK;
break;
case SQLITE_ACCESS_READWRITE:
amode = W_OK|R_OK;
break;
case SQLITE_ACCESS_READ:
amode = R_OK;
break;
assert( pResOut!=0 );
default:
assert(!"Invalid flags argument");
}
*pResOut = (osAccess(zPath, amode)==0);
if( flags==SQLITE_ACCESS_EXISTS && *pResOut ){
/* The spec says there are three possible values for flags. But only
** two of them are actually used */
assert( flags==SQLITE_ACCESS_EXISTS || flags==SQLITE_ACCESS_READWRITE );
if( flags==SQLITE_ACCESS_EXISTS ){
struct stat buf;
if( 0==osStat(zPath, &buf) && buf.st_size==0 ){
*pResOut = 0;
}
*pResOut = (0==osStat(zPath, &buf) && buf.st_size>0);
}else{
*pResOut = osAccess(zPath, W_OK|R_OK)==0;
}
return SQLITE_OK;
}
@@ -6005,8 +5995,7 @@ static int unixFullPathname(
if( errno!=EINVAL && errno!=ENOENT ){
return unixLogError(SQLITE_CANTOPEN_BKPT, "readlink", zPath);
}
zOut[nOut-1] = '\0';
sqlite3_snprintf(nOut-1, zOut, "%s", zPath);
sqlite3_snprintf(nOut, zOut, "%s", zPath);
nByte = sqlite3Strlen30(zOut);
}else{
zOut[nByte] = '\0';