From 18364caa34c71263fb575bc07012620274e66803 Mon Sep 17 00:00:00 2001 From: Anastasia Date: Tue, 27 Feb 2018 13:02:43 +0300 Subject: [PATCH] rewrite dir_create_dir() in a cross platform way --- src/dir.c | 8 +++++--- src/pg_probackup.h | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/dir.c b/src/dir.c index eed62c5c..834b2708 100644 --- a/src/dir.c +++ b/src/dir.c @@ -10,7 +10,6 @@ #include "pg_probackup.h" -#include #include #include #include @@ -99,10 +98,12 @@ int dir_create_dir(const char *dir, mode_t mode) { char copy[MAXPGPATH]; - char parent[MAXPGPATH]; + char *parent; strncpy(copy, dir, MAXPGPATH); - strncpy(parent, dirname(copy), MAXPGPATH); + + parent = pstrdup(dir); + get_parent_directory(parent); /* Create parent first */ if (access(parent, F_OK) == -1) @@ -116,6 +117,7 @@ dir_create_dir(const char *dir, mode_t mode) elog(ERROR, "cannot create directory \"%s\": %s", dir, strerror(errno)); } + pfree(parent); return 0; } diff --git a/src/pg_probackup.h b/src/pg_probackup.h index 1c1eef1b..392ef579 100644 --- a/src/pg_probackup.h +++ b/src/pg_probackup.h @@ -28,6 +28,7 @@ #include "storage/checksum.h" #include "utils/pg_crc.h" #include "common/relpath.h" +#include "port.h" #include "utils/parray.h" #include "utils/pgut.h"