diff options
author | drh <drh@noemail.net> | 2015-12-07 18:18:33 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2015-12-07 18:18:33 +0000 |
commit | dc27851e21a94a0200bace098f61ec6deb4b427a (patch) | |
tree | 8fb5fe9a21c7f24008a2746fae9f61e6e5a194cb /src | |
parent | d797a9b5cb22e248015aabf0148ca544a7a7da3d (diff) | |
download | sqlite-dc27851e21a94a0200bace098f61ec6deb4b427a.tar.gz sqlite-dc27851e21a94a0200bace098f61ec6deb4b427a.zip |
Fix the openDirectory() routine in the unix VFS so that it works for databases
located in the root of the filesystem and for database files that have no
pathname at all.
FossilOrigin-Name: e7ae120d04cffafd9bc2b4ecd68571c17e05ed72
Diffstat (limited to 'src')
-rw-r--r-- | src/os_unix.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/os_unix.c b/src/os_unix.c index beaac0d15..791ba5d8d 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -3465,13 +3465,16 @@ static int openDirectory(const char *zFilename, int *pFd){ char zDirname[MAX_PATHNAME+1]; sqlite3_snprintf(MAX_PATHNAME, zDirname, "%s", zFilename); - for(ii=(int)strlen(zDirname); ii>1 && zDirname[ii]!='/'; ii--); - if( ii>1 ){ + for(ii=(int)strlen(zDirname); ii>0 && zDirname[ii]!='/'; ii--); + if( ii>0 ){ zDirname[ii] = '\0'; - fd = robust_open(zDirname, O_RDONLY|O_BINARY, 0); - if( fd>=0 ){ - OSTRACE(("OPENDIR %-3d %s\n", fd, zDirname)); - } + }else{ + if( zDirname[0]!='/' ) zDirname[0] = '.'; + zDirname[1] = 0; + } + fd = robust_open(zDirname, O_RDONLY|O_BINARY, 0); + if( fd>=0 ){ + OSTRACE(("OPENDIR %-3d %s\n", fd, zDirname)); } *pFd = fd; if( fd>=0 ) return SQLITE_OK; |