1 /*-------------------------------------------------------------------------
4 * Virtual file descriptor definitions.
7 * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * $Id: fd.h,v 1.19 2000/01/26 05:58:32 momjian Exp $
12 *-------------------------------------------------------------------------
18 * File {Close, Read, Write, Seek, Tell, Sync}
19 * {File Name Open, Allocate, Free} File
21 * These are NOT JUST RENAMINGS OF THE UNIX ROUTINES.
22 * Use them for all file activity...
25 * fd = FilePathOpenFile("foo", O_RDONLY);
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.
39 * FileSeek uses the standard UNIX lseek(2) flags.
42 typedef char *FileName;
47 * prototypes for functions in fd.c
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);
62 /* Operations that allow use of regular stdio --- USE WITH CAUTION */
63 extern FILE *AllocateFile(char *name, char *mode);
64 extern void FreeFile(FILE *);
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);