r=vlad
Patch from abwillis - OS/2 SQLite changes
This commit is contained in:
mkaply%us.ibm.com 2005-10-20 18:55:10 +00:00
parent 5927d4d73a
commit 08638ebfd6
2 changed files with 43 additions and 40 deletions

View File

@ -29,12 +29,19 @@
# if defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BORLANDC__)
# define OS_WIN 1
# define OS_UNIX 0
# define OS_OS2 0
# elif defined(_EMX_) || defined(_OS2) || defined(OS2) || defined(OS_OS2)
# define OS_WIN 0
# define OS_UNIX 0
# define OS_OS2 1
# else
# define OS_WIN 0
# define OS_UNIX 1
# define OS_OS2 0
# endif
# else
# define OS_UNIX 0
# define OS_OS2 0
# endif
#else
# ifndef OS_WIN
@ -54,6 +61,9 @@
#if OS_WIN
# include "os_win.h"
#endif
#if OS_OS2
# include "os_os2.h"
#endif
/* os_other.c and os_other.h are not delivered with SQLite. These files
** are place-holders that can be filled in by third-party developers to

View File

@ -48,6 +48,13 @@
# define SQLITE_OS2_THREADS 1
#endif
/*
** Do not include any of the File I/O interface procedures if the
** SQLITE_OMIT_DISKIO macro is defined (indicating that there database
** will be in-memory only)
*/
#ifndef SQLITE_OMIT_DISKIO
/*
** Delete the named file
*/
@ -546,6 +553,32 @@ int sqlite3OsClose(OsFile *id){
return SQLITE_OK;
}
/*
** 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 *sqlite3OsFullPathname(const char *zRelative){
char *zFull = 0;
char zPath[260]; /* max OS/2 path length, incl drive */
if( !_abspath(zPath, zRelative, sizeof(zPath)) ){
sqlite3SetString(&zFull, zPath, 0);
}else{
char zBuf[260];
snprintf(zPath, sizeof(zPath), "%s/%s",
getcwd(zBuf, sizeof(zBuf)), zRelative);
sqlite3SetString(&zFull, zPath, 0);
}
return zFull;
}
#endif /* SQLITE_OMIT_DISKIO */
/***************************************************************************
** Everything above deals with file I/O. Everything that follows deals
** with other miscellanous aspects of the operating system interface
****************************************************************************/
/*
** Get information to seed the random number generator. The seed
** is written into the buffer zBuf[256]. The calling function must
@ -617,26 +650,6 @@ void sqlite3OsLeaveMutex(){
#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 *sqlite3OsFullPathname(const char *zRelative){
char *zFull = 0;
char zPath[260]; /* max OS/2 path length, incl drive */
if( !_abspath(zPath, zRelative, sizeof(zPath)) ){
sqlite3SetString(&zFull, zPath, 0);
}else{
char zBuf[260];
snprintf(zPath, sizeof(zPath), "%s/%s",
getcwd(zBuf, sizeof(zBuf)), zRelative);
sqlite3SetString(&zFull, zPath, 0);
}
return zFull;
}
/*
** The following variable, if set to a non-zero value, becomes the result
** returned from sqlite3OsCurrentTime(). This is used for testing.
@ -662,24 +675,4 @@ int sqlite3OsCurrentTime(double *prNow){
return 0;
}
#if 0 /* NOT USED */
/*
** Find the time that the file was last modified. Write the
** modification time and date as a Julian Day number into *prNow and
** return SQLITE_OK. Return SQLITE_ERROR if the modification
** time cannot be found.
*/
int sqlite3OsFileModTime(OsFile *id, double *prNow){
int rc;
struct stat statbuf;
if( fstat(id->h, &statbuf)==0 ){
*prNow = statbuf.st_mtime/86400.0 + 2440587.5;
rc = SQLITE_OK;
}else{
rc = SQLITE_ERROR;
}
return rc;
}
#endif /* NOT USED */
#endif /* OS_OS2 */