]> granicus.if.org Git - postgresql/blob - src/include/storage/fd.h
Ye-old pgindent run. Same 4-space tabs.
[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.21 2000/04/12 17:16:51 momjian Exp $
11  *
12  *-------------------------------------------------------------------------
13  */
14
15 /*
16  * calls:
17  *
18  *      File {Close, Read, Write, Seek, Tell, MarkDirty, 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 extern void FileMarkDirty(File file);
62
63 /* Operations that allow use of regular stdio --- USE WITH CAUTION */
64 extern FILE *AllocateFile(char *name, char *mode);
65 extern void FreeFile(FILE *);
66
67 /* Miscellaneous support routines */
68 extern bool ReleaseDataFile(void);
69 extern void closeAllVfds(void);
70 extern void AtEOXact_Files(void);
71 extern int      pg_fsync(int fd);
72
73 #endif   /* FD_H */