]> granicus.if.org Git - postgresql/blob - src/include/storage/fd.h
Add:
[postgresql] / src / include / storage / fd.h
1 /*-------------------------------------------------------------------------
2  *
3  * fd.h
4  *        Virtual file descriptor definitions.
5  *
6  *
7  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * $Id: fd.h,v 1.19 2000/01/26 05:58:32 momjian Exp $
11  *
12  *-------------------------------------------------------------------------
13  */
14
15 /*
16  * calls:
17  *
18  *      File {Close, Read, Write, Seek, Tell, Sync}
19  *      {File Name Open, Allocate, Free} File
20  *
21  * These are NOT JUST RENAMINGS OF THE UNIX ROUTINES.
22  * Use them for all file activity...
23  *
24  *      File fd;
25  *      fd = FilePathOpenFile("foo", O_RDONLY);
26  *
27  *      AllocateFile();
28  *      FreeFile();
29  *
30  * Use AllocateFile, not fopen, if you need a stdio file (FILE*); then
31  * use FreeFile, not fclose, to close it.  AVOID using stdio for files
32  * that you intend to hold open for any length of time, since there is
33  * no way for them to share kernel file descriptors with other files.
34  */
35 #ifndef FD_H
36 #define FD_H
37
38 /*
39  * FileSeek uses the standard UNIX lseek(2) flags.
40  */
41
42 typedef char *FileName;
43
44 typedef int File;
45
46 /*
47  * prototypes for functions in fd.c
48  */
49
50 /* Operations on virtual Files --- equivalent to Unix kernel file ops */
51 extern File FileNameOpenFile(FileName fileName, int fileFlags, int fileMode);
52 extern File PathNameOpenFile(FileName fileName, int fileFlags, int fileMode);
53 extern File OpenTemporaryFile(void);
54 extern void FileClose(File file);
55 extern void FileUnlink(File file);
56 extern int      FileRead(File file, char *buffer, int amount);
57 extern int      FileWrite(File file, char *buffer, int amount);
58 extern long FileSeek(File file, long offset, int whence);
59 extern int      FileTruncate(File file, long offset);
60 extern int      FileSync(File file);
61
62 /* Operations that allow use of regular stdio --- USE WITH CAUTION */
63 extern FILE *AllocateFile(char *name, char *mode);
64 extern void FreeFile(FILE *);
65
66 /* Miscellaneous support routines */
67 extern bool     ReleaseDataFile(void);
68 extern void closeAllVfds(void);
69 extern void AtEOXact_Files(void);
70 extern int      pg_fsync(int fd);
71
72 #endif   /* FD_H */