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.20 2000/04/09 04:43:18 tgl Exp $
12 *-------------------------------------------------------------------------
18 * File {Close, Read, Write, Seek, Tell, MarkDirty, 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);
61 extern void FileMarkDirty(File file);
63 /* Operations that allow use of regular stdio --- USE WITH CAUTION */
64 extern FILE *AllocateFile(char *name, char *mode);
65 extern void FreeFile(FILE *);
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);