mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-01-09 14:45:47 +02:00
rewrite dir_create_dir() in a cross platform way
This commit is contained in:
parent
2a9baaa960
commit
18364caa34
@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
#include "pg_probackup.h"
|
#include "pg_probackup.h"
|
||||||
|
|
||||||
#include <libgen.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -99,10 +98,12 @@ int
|
|||||||
dir_create_dir(const char *dir, mode_t mode)
|
dir_create_dir(const char *dir, mode_t mode)
|
||||||
{
|
{
|
||||||
char copy[MAXPGPATH];
|
char copy[MAXPGPATH];
|
||||||
char parent[MAXPGPATH];
|
char *parent;
|
||||||
|
|
||||||
strncpy(copy, dir, MAXPGPATH);
|
strncpy(copy, dir, MAXPGPATH);
|
||||||
strncpy(parent, dirname(copy), MAXPGPATH);
|
|
||||||
|
parent = pstrdup(dir);
|
||||||
|
get_parent_directory(parent);
|
||||||
|
|
||||||
/* Create parent first */
|
/* Create parent first */
|
||||||
if (access(parent, F_OK) == -1)
|
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));
|
elog(ERROR, "cannot create directory \"%s\": %s", dir, strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pfree(parent);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "storage/checksum.h"
|
#include "storage/checksum.h"
|
||||||
#include "utils/pg_crc.h"
|
#include "utils/pg_crc.h"
|
||||||
#include "common/relpath.h"
|
#include "common/relpath.h"
|
||||||
|
#include "port.h"
|
||||||
|
|
||||||
#include "utils/parray.h"
|
#include "utils/parray.h"
|
||||||
#include "utils/pgut.h"
|
#include "utils/pgut.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user