codekingpro/portable-devtools
115k
1/*-------------------------------------------------------------------------2 *3 * Assorted utility functions to work on files.4 *5 *6 * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group7 * Portions Copyright (c) 1994, Regents of the University of California8 *9 * src/include/common/file_utils.h10 *11 *-------------------------------------------------------------------------12 */13#ifndef FILE_UTILS_H14#define FILE_UTILS_H15 16#include <dirent.h>17 18typedef enum PGFileType19{20 PGFILETYPE_ERROR,21 PGFILETYPE_UNKNOWN,22 PGFILETYPE_REG,23 PGFILETYPE_DIR,24 PGFILETYPE_LNK25} PGFileType;26 27struct iovec; /* avoid including port/pg_iovec.h here */28 29#ifdef FRONTEND30extern int fsync_fname(const char *fname, bool isdir);31extern void fsync_pgdata(const char *pg_data, int serverVersion);32extern void fsync_dir_recurse(const char *dir);33extern int durable_rename(const char *oldfile, const char *newfile);34extern int fsync_parent_path(const char *fname);35#endif36 37extern PGFileType get_dirent_type(const char *path,38 const struct dirent *de,39 bool look_through_symlinks,40 int elevel);41 42extern ssize_t pg_pwritev_with_retry(int fd,43 const struct iovec *iov,44 int iovcnt,45 off_t offset);46 47extern ssize_t pg_pwrite_zeros(int fd, size_t size, off_t offset);48 49#endif /* FILE_UTILS_H */50 