]> granicus.if.org Git - postgresql/blob - src/include/storage/fd.h
Okay, following Bryan's (and others) suggestions...cleaning up the
[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.3 1996/11/01 09:31:10 scrappy Exp $
10  *
11  *-------------------------------------------------------------------------
12  */
13 /*
14  * calls:
15  * 
16  *  File {Close, Read, Write, Seek, Tell, Sync}
17  *  {File Name Open, Allocate, Free} File
18  *
19  * These are NOT JUST RENAMINGS OF THE UNIX ROUTINES.
20  * use them for all file activity...
21  *
22  *  fd = FilePathOpenFile("foo", O_RDONLY);
23  *  File fd;
24  *
25  * use AllocateFile if you need a file descriptor in some other context.
26  * it will make sure that there is a file descriptor free
27  *
28  * use FreeFile to let the virtual file descriptor package know that 
29  * there is now a free fd (when you are done with it)
30  *
31  *  AllocateFile();
32  *  FreeFile();
33  */
34 #ifndef FD_H
35 #define FD_H
36
37 /*
38  * FileOpen uses the standard UNIX open(2) flags.
39  */
40 #include <fcntl.h>      /* for O_ on most */
41 #ifndef O_RDONLY
42 #include <sys/file.h>   /* for O_ on the rest */
43 #endif /* O_RDONLY */
44
45 /*
46  * FileSeek uses the standard UNIX lseek(2) flags.
47  */
48 #ifndef WIN32
49 #include <unistd.h>     /* for SEEK_ on most */
50 #else
51 #ifndef SEEK_SET
52 #include <stdio.h>      /* for SEEK_ on the rest */
53 #endif /* SEEK_SET */
54 #endif /* WIN32 */
55
56 typedef char   *FileName;
57
58 typedef int     File;
59
60 /* originally in libpq-fs.h */
61 struct pgstat { /* just the fields we need from stat structure */
62     int st_ino;
63     int st_mode;
64     unsigned int st_size;
65     unsigned int st_sizehigh;   /* high order bits */
66 /* 2^64 == 1.8 x 10^20 bytes */
67     int st_uid;
68     int st_atime_s;     /* just the seconds */
69     int st_mtime_s;     /* since SysV and the new BSD both have */
70     int st_ctime_s;     /* usec fields.. */
71 };
72
73 /*
74  * prototypes for functions in fd.c
75  */
76 extern void FileInvalidate(File file);
77 extern File FileNameOpenFile(FileName fileName, int fileFlags, int fileMode);
78 extern File PathNameOpenFile(FileName fileName, int fileFlags, int fileMode);
79 extern void FileClose(File file);
80 extern void FileUnlink(File file);
81 extern int FileRead(File file, char *buffer, int amount);
82 extern int FileWrite(File file, char *buffer, int amount);
83 extern long FileSeek(File file, long offset, int whence);
84 extern long FileTell(File file);
85 extern int FileTruncate(File file, int offset);
86 extern int FileSync(File file);
87 extern int FileNameUnlink(char *filename);
88 extern void AllocateFile(void);
89 extern void FreeFile(void);
90 extern void closeAllVfds(void);
91 extern void closeOneVfd(void);
92
93 #endif  /* FD_H */