37 const char *(*link_map) (
const char *);
91 streamer->
file = file;
95 streamer->
file = fopen(pathname,
"wb");
96 if (streamer->
file == NULL)
97 pg_fatal(
"could not create file \"%s\": %m", pathname);
101 return &streamer->
base;
125 pg_fatal(
"could not write to file \"%s\": %m",
142 pg_fatal(
"could not close file \"%s\": %m",
145 mystreamer->
file = NULL;
188 const char *(*link_map) (
const char *),
189 void (*report_output_file) (
const char *))
200 return &streamer->
base;
227 fnamelen = strlen(mystreamer->
filename);
228 if (mystreamer->
filename[fnamelen - 1] ==
'/')
229 mystreamer->
filename[fnamelen - 1] =
'\0';
239 linktarget = mystreamer->
link_map(linktarget);
253 if (mystreamer->
file == NULL)
262 pg_fatal(
"could not write to file \"%s\": %m",
268 if (mystreamer->
file == NULL)
270 fclose(mystreamer->
file);
271 mystreamer->
file = NULL;
279 pg_fatal(
"unexpected state while extracting archive");
300 if (strcmp(
filename,
"pg_wal") == 0 ||
302 strcmp(
filename,
"archive_status") == 0 ||
303 strcmp(
filename,
"summaries") == 0 ||
309 const char *pg_tblspc = strstr(pathname,
"/pg_tblspc/");
311 return pg_tblspc != NULL && pg_tblspc + 11 ==
filename;
325 pg_fatal(
"could not create directory \"%s\": %m",
330 pg_fatal(
"could not set permissions on directory \"%s\": %m",
349 pg_fatal(
"could not create symbolic link from \"%s\" to \"%s\": %m",
369 pg_fatal(
"could not set permissions on file \"%s\": %m",
387 Assert(mystreamer->file == NULL);
astreamer_archive_context
@ ASTREAMER_MEMBER_HEADER
@ ASTREAMER_MEMBER_CONTENTS
@ ASTREAMER_MEMBER_TRAILER
@ ASTREAMER_ARCHIVE_TRAILER
static void astreamer_plain_writer_content(astreamer *streamer, astreamer_member *member, const char *data, int len, astreamer_archive_context context)
static void astreamer_extractor_finalize(astreamer *streamer)
static void extract_directory(const char *filename, mode_t mode)
static FILE * create_file_for_extract(const char *filename, mode_t mode)
static const astreamer_ops astreamer_extractor_ops
astreamer * astreamer_plain_writer_new(char *pathname, FILE *file)
struct astreamer_extractor astreamer_extractor
astreamer * astreamer_extractor_new(const char *basepath, const char *(*link_map)(const char *), void(*report_output_file)(const char *))
struct astreamer_plain_writer astreamer_plain_writer
static void astreamer_plain_writer_finalize(astreamer *streamer)
static void astreamer_extractor_free(astreamer *streamer)
static void astreamer_extractor_content(astreamer *streamer, astreamer_member *member, const char *data, int len, astreamer_archive_context context)
static const astreamer_ops astreamer_plain_writer_ops
static bool should_allow_existing_directory(const char *pathname)
static void extract_link(const char *filename, const char *linktarget)
static void astreamer_plain_writer_free(astreamer *streamer)
#define PG_USED_FOR_ASSERTS_ONLY
#define Assert(condition)
char * pstrdup(const char *in)
void pfree(void *pointer)
void * palloc0(Size size)
static PgChecksumMode mode
char * last_dir_separator(const char *filename)
char linktarget[MAXPGPATH]
void(* content)(astreamer *streamer, astreamer_member *member, const char *data, int len, astreamer_archive_context context)
const astreamer_ops * bbs_ops
#define symlink(oldpath, newpath)