blob: 93fa5352c89a9de12384258603222aef3ae0f4c6 [file] [log] [blame]
drhe3c41372001-09-17 20:25:58 +00001/*
2** 2001 September 16
3**
4** The author disclaims copyright to this source code. In place of
5** a legal notice, here is a blessing:
6**
7** May you do good and not evil.
8** May you find forgiveness for yourself and forgive others.
9** May you share freely, never taking more than you give.
10**
11******************************************************************************
12**
13** This header file (together with is companion C source-code file
14** "os.c") attempt to abstract the underlying operating system so that
15** the SQLite library will work on both POSIX and windows systems.
16*/
17#ifndef _SQLITE_OS_H_
18#define _SQLITE_OS_H_
19
drh829e8022002-11-06 14:08:11 +000020/*
drh820f3812003-01-08 13:02:52 +000021** Figure out if we are dealing with Unix, Windows or MacOS.
22**
23** N.B. MacOS means Mac Classic (or Carbon). Treat Darwin (OS X) as Unix.
24** The MacOS build is designed to use CodeWarrior (tested with v8)
drh829e8022002-11-06 14:08:11 +000025*/
drh27a32202002-03-20 00:00:29 +000026#ifndef OS_UNIX
27# ifndef OS_WIN
drh820f3812003-01-08 13:02:52 +000028# ifndef OS_MAC
29# if defined(__MACOS__)
30# define OS_MAC 1
31# define OS_WIN 0
32# define OS_UNIX 0
33# elif defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BORLANDC__)
34# define OS_MAC 0
35# define OS_WIN 1
36# define OS_UNIX 0
37# else
38# define OS_MAC 0
39# define OS_WIN 0
40# define OS_UNIX 1
41# endif
drh27a32202002-03-20 00:00:29 +000042# else
43# define OS_WIN 0
drh820f3812003-01-08 13:02:52 +000044# define OS_UNIX 0
drh27a32202002-03-20 00:00:29 +000045# endif
46# else
drh820f3812003-01-08 13:02:52 +000047# define OS_MAC 0
drh27a32202002-03-20 00:00:29 +000048# define OS_UNIX 0
49# endif
drh820f3812003-01-08 13:02:52 +000050#else
51# define OS_MAC 0
drhe5e37602003-08-16 13:10:51 +000052# ifndef OS_WIN
53# define OS_WIN 0
54# endif
drh1ab43002002-01-14 09:28:19 +000055#endif
56
drhe3c41372001-09-17 20:25:58 +000057/*
drhbbd42a62004-05-22 17:41:58 +000058** Invoke the appropriate operating-system specific header file.
drhe3c41372001-09-17 20:25:58 +000059*/
60#if OS_UNIX
drhbbd42a62004-05-22 17:41:58 +000061# include "os_unix.h"
drhe3c41372001-09-17 20:25:58 +000062#endif
drhe3c41372001-09-17 20:25:58 +000063#if OS_WIN
drhbbd42a62004-05-22 17:41:58 +000064# include "os_win.h"
drhe3c41372001-09-17 20:25:58 +000065#endif
drh820f3812003-01-08 13:02:52 +000066#if OS_MAC
drhbbd42a62004-05-22 17:41:58 +000067# include "os_mac.h"
drh820f3812003-01-08 13:02:52 +000068#endif
69
danielk19776622cce2004-05-20 11:00:52 +000070/*
drhbbd42a62004-05-22 17:41:58 +000071** Temporary files are named starting with this prefix followed by 16 random
72** alphanumeric characters, and no file extension. They are stored in the
73** OS's standard temporary file directory, and are deleted prior to exit.
74** If sqlite is being embedded in another program, you may wish to change the
75** prefix to reflect your program's name, so that if your program exits
76** prematurely, old temporary files can be easily identified. This can be done
77** using -DTEMP_FILE_PREFIX=myprefix_ on the compiler command line.
danielk19776622cce2004-05-20 11:00:52 +000078*/
drhbbd42a62004-05-22 17:41:58 +000079#ifndef TEMP_FILE_PREFIX
80# define TEMP_FILE_PREFIX "sqlite_"
81#endif
82
danielk19776622cce2004-05-20 11:00:52 +000083
danielk19774adee202004-05-08 08:23:19 +000084int sqlite3OsDelete(const char*);
85int sqlite3OsFileExists(const char*);
drh001bbcb2003-03-19 03:14:00 +000086int sqliteOsFileRename(const char*, const char*);
danielk19774adee202004-05-08 08:23:19 +000087int sqlite3OsOpenReadWrite(const char*, OsFile*, int*);
88int sqlite3OsOpenExclusive(const char*, OsFile*, int);
89int sqlite3OsOpenReadOnly(const char*, OsFile*);
90int sqlite3OsOpenDirectory(const char*, OsFile*);
91int sqlite3OsTempFileName(char*);
92int sqlite3OsClose(OsFile*);
93int sqlite3OsRead(OsFile*, void*, int amt);
94int sqlite3OsWrite(OsFile*, const void*, int amt);
95int sqlite3OsSeek(OsFile*, off_t offset);
96int sqlite3OsSync(OsFile*);
97int sqlite3OsTruncate(OsFile*, off_t size);
98int sqlite3OsFileSize(OsFile*, off_t *pSize);
99int sqlite3OsReadLock(OsFile*);
100int sqlite3OsWriteLock(OsFile*);
101int sqlite3OsUnlock(OsFile*);
102int sqlite3OsRandomSeed(char*);
103int sqlite3OsSleep(int ms);
104int sqlite3OsCurrentTime(double*);
105void sqlite3OsEnterMutex(void);
106void sqlite3OsLeaveMutex(void);
107char *sqlite3OsFullPathname(const char*);
drhe3c41372001-09-17 20:25:58 +0000108
drhe3c41372001-09-17 20:25:58 +0000109#endif /* _SQLITE_OS_H_ */