1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-10-25 20:58:26 +03:00

Add in-process file locking to test_async.c. The unix implementation of

sqlite3OsFullPathname() now attempts to remove /./ and /../ elements from
the path. (CVS 3090)

FossilOrigin-Name: 42379c623073eb541d053c2dff9f49087fb290f8
This commit is contained in:
drh
2006-02-13 17:03:47 +00:00
parent 99681dbbdb
commit 89ea93121d
4 changed files with 92 additions and 27 deletions

View File

@@ -1539,6 +1539,7 @@ static int unixClose(OsFile **pId){
*/
char *sqlite3UnixFullPathname(const char *zRelative){
char *zFull = 0;
int i, j;
if( zRelative[0]=='/' ){
sqlite3SetString(&zFull, zRelative, (char*)0);
}else{
@@ -1551,6 +1552,28 @@ char *sqlite3UnixFullPathname(const char *zRelative){
(char*)0);
sqliteFree(zBuf);
}
/*
** Remove "/./" path elements and convert "/A/./" path elements
** to just "/".
*/
if( zFull ){
for(i=j=0; zFull[i]; i++){
if( zFull[i]=='/' ){
if( zFull[i+1]=='/' ) continue;
if( zFull[i+1]=='.' && zFull[i+2]=='/' ){
i += 1;
continue;
}
if( zFull[i+1]=='.' && zFull[i+2]=='.' && zFull[i+3]=='/' ){
while( j>0 && zFull[j-1]!='/' ){ j--; }
i += 3;
continue;
}
}
zFull[j++] = zFull[i];
}
zFull[j] = 0;
}
return zFull;
}