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