1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Save the full pathname of the database file so that journalling still works

even if the user changes working directories after opening the databae.
Ticket #200. (CVS 798)

FossilOrigin-Name: 1c58b4fc032c5975dcce9b8ae844c0e516254a17
This commit is contained in:
drh
2002-12-07 21:45:14 +00:00
parent 1a844c380b
commit 3e7a609667
6 changed files with 76 additions and 16 deletions

View File

@@ -20,6 +20,7 @@
#if OS_UNIX
# include <time.h>
# include <errno.h>
# include <unistd.h>
# ifndef O_LARGEFILE
# define O_LARGEFILE 0
# endif
@@ -970,3 +971,32 @@ void sqliteOsLeaveMutex(){
LeaveCriticalSection(&cs);
#endif
}
/*
** Turn a relative pathname into a full pathname. Return a pointer
** to the full pathname stored in space obtained from sqliteMalloc().
** The calling function is responsible for freeing this space once it
** is no longer needed.
*/
char *sqliteOsFullPathname(const char *zRelative){
#if OS_UNIX
char *zFull = 0;
if( zRelative[0]=='/' ){
sqliteSetString(&zFull, zRelative, 0);
}else{
char zBuf[5000];
sqliteSetString(&zFull, getcwd(zBuf, sizeof(zBuf)), "/", zRelative, 0);
}
return zFull;
#endif
#if OS_WIN
char *zNotUsed;
char *zFull;
int nByte;
nByte = GetFullPathName(zRelative, 0, 0, &zNotUsed);
zFull = sqliteMalloc( nByte );
if( zFull==0 ) return 0;
GetFullPathName(zRelative, nByte, zFull, &zNotUsed);
return zFull;
#endif
}