1 /*-------------------------------------------------------------------------
4 * Virtual file descriptor definitions.
7 * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * $Id: fd.h,v 1.35 2002/06/20 20:29:52 momjian 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, 0600);
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;
48 extern int max_files_per_process;
52 * prototypes for functions in fd.c
55 /* Operations on virtual Files --- equivalent to Unix kernel file ops */
56 extern File FileNameOpenFile(FileName fileName, int fileFlags, int fileMode);
57 extern File PathNameOpenFile(FileName fileName, int fileFlags, int fileMode);
58 extern File OpenTemporaryFile(void);
59 extern void FileClose(File file);
60 extern void FileUnlink(File file);
61 extern int FileRead(File file, char *buffer, int amount);
62 extern int FileWrite(File file, char *buffer, int amount);
63 extern long FileSeek(File file, long offset, int whence);
64 extern int FileTruncate(File file, long offset);
65 extern int FileSync(File file);
66 extern void FileMarkDirty(File file);
68 /* Operations that allow use of regular stdio --- USE WITH CAUTION */
69 extern FILE *AllocateFile(char *name, char *mode);
70 extern void FreeFile(FILE *);
72 /* If you've really really gotta have a plain kernel FD, use this */
73 extern int BasicOpenFile(FileName fileName, int fileFlags, int fileMode);
75 /* Miscellaneous support routines */
76 extern void closeAllVfds(void);
77 extern void AtEOXact_Files(void);
78 extern void RemovePgTempFiles(void);
79 extern int pg_fsync(int fd);
80 extern int pg_fdatasync(int fd);