2
0

buffile.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*-------------------------------------------------------------------------
  2. *
  3. * buffile.h
  4. * Management of large buffered temporary files.
  5. *
  6. * The BufFile routines provide a partial replacement for stdio atop
  7. * virtual file descriptors managed by fd.c. Currently they only support
  8. * buffered access to a virtual file, without any of stdio's formatting
  9. * features. That's enough for immediate needs, but the set of facilities
  10. * could be expanded if necessary.
  11. *
  12. * BufFile also supports working with temporary files that exceed the OS
  13. * file size limit and/or the largest offset representable in an int.
  14. * It might be better to split that out as a separately accessible module,
  15. * but currently we have no need for oversize temp files without buffered
  16. * access.
  17. *
  18. * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
  19. * Portions Copyright (c) 1994, Regents of the University of California
  20. *
  21. * src/include/storage/buffile.h
  22. *
  23. *-------------------------------------------------------------------------
  24. */
  25. #ifndef BUFFILE_H
  26. #define BUFFILE_H
  27. #include "storage/fileset.h"
  28. /* BufFile is an opaque type whose details are not known outside buffile.c. */
  29. typedef struct BufFile BufFile;
  30. /*
  31. * prototypes for functions in buffile.c
  32. */
  33. extern BufFile *BufFileCreateTemp(bool interXact);
  34. extern void BufFileClose(BufFile *file);
  35. extern size_t BufFileRead(BufFile *file, void *ptr, size_t size);
  36. extern void BufFileWrite(BufFile *file, void *ptr, size_t size);
  37. extern int BufFileSeek(BufFile *file, int fileno, off_t offset, int whence);
  38. extern void BufFileTell(BufFile *file, int *fileno, off_t *offset);
  39. extern int BufFileSeekBlock(BufFile *file, long blknum);
  40. extern int64 BufFileSize(BufFile *file);
  41. extern long BufFileAppend(BufFile *target, BufFile *source);
  42. extern BufFile *BufFileCreateFileSet(FileSet *fileset, const char *name);
  43. extern void BufFileExportFileSet(BufFile *file);
  44. extern BufFile *BufFileOpenFileSet(FileSet *fileset, const char *name,
  45. int mode, bool missing_ok);
  46. extern void BufFileDeleteFileSet(FileSet *fileset, const char *name,
  47. bool missing_ok);
  48. extern void BufFileTruncateFileSet(BufFile *file, int fileno, off_t offset);
  49. #endif /* BUFFILE_H */