37 copydir(
const char *fromdir,
const char *todir,
bool recurse)
47 errmsg(
"could not create directory \"%s\": %m", todir)));
51 while ((xlde =
ReadDir(xldir, fromdir)) != NULL)
58 if (strcmp(xlde->
d_name,
".") == 0 ||
59 strcmp(xlde->
d_name,
"..") == 0)
62 snprintf(fromfile,
sizeof(fromfile),
"%s/%s", fromdir, xlde->
d_name);
71 copydir(fromfile, tofile,
true);
87 while ((xlde =
ReadDir(xldir, todir)) != NULL)
89 if (strcmp(xlde->
d_name,
".") == 0 ||
90 strcmp(xlde->
d_name,
"..") == 0)
127 #define COPY_BUF_SIZE (8 * BLCKSZ)
135 #if defined(__darwin__)
136 #define FLUSH_DISTANCE (32 * 1024 * 1024)
138 #define FLUSH_DISTANCE (1024 * 1024)
151 errmsg(
"could not open file \"%s\": %m", fromfile)));
157 errmsg(
"could not create file \"%s\": %m", tofile)));
163 for (offset = 0;; offset += nbytes)
176 flush_offset = offset;
185 errmsg(
"could not read file \"%s\": %m", fromfile)));
190 if ((
int)
write(
dstfd, buffer, nbytes) != nbytes)
197 errmsg(
"could not write to file \"%s\": %m", tofile)));
202 if (offset > flush_offset)
208 errmsg(
"could not close file \"%s\": %m", tofile)));
213 errmsg(
"could not close file \"%s\": %m", fromfile)));
void copy_file(const char *fromfile, const char *tofile)
void copydir(const char *fromdir, const char *todir, bool recurse)
int errcode_for_file_access(void)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
struct dirent * ReadDir(DIR *dir, const char *dirname)
void pg_flush_data(int fd, off_t offset, off_t nbytes)
int MakePGDirectory(const char *directoryName)
int CloseTransientFile(int fd)
void fsync_fname(const char *fname, bool isdir)
int OpenTransientFile(const char *fileName, int fileFlags)
DIR * AllocateDir(const char *dirname)
PGFileType get_dirent_type(const char *path, const struct dirent *de, bool look_through_symlinks, int elevel)
void pfree(void *pointer)
#define CHECK_FOR_INTERRUPTS()
static void pgstat_report_wait_start(uint32 wait_event_info)
static void pgstat_report_wait_end(void)