version 1.29, 2004/11/19 20:00:57 |
version 1.30, 2005/05/16 15:22:46 |
|
|
#include "backupfile.h" |
#include "backupfile.h" |
#include "pathnames.h" |
#include "pathnames.h" |
|
|
|
|
/* Rename a file, copying it if necessary. */ |
/* Rename a file, copying it if necessary. */ |
|
|
int |
int |
|
|
makedirs(const char *filename, bool striplast) |
makedirs(const char *filename, bool striplast) |
{ |
{ |
char *tmpbuf; |
char *tmpbuf; |
|
mode_t mode, dir_mode; |
|
|
if ((tmpbuf = strdup(filename)) == NULL) |
if ((tmpbuf = strdup(filename)) == NULL) |
fatal("out of memory\n"); |
fatal("out of memory\n"); |
|
|
return; /* nothing to be done */ |
return; /* nothing to be done */ |
*s = '\0'; |
*s = '\0'; |
} |
} |
if (snprintf(buf, sizeof(buf), "%s -p %s", _PATH_MKDIR, tmpbuf) |
mode = 0777 & ~umask(0); |
>= sizeof(buf)) |
dir_mode = mode | S_IWUSR | S_IXUSR; |
fatal("buffer too small to hold %.20s...\n", tmpbuf); |
if (mkpath(tmpbuf, mode, dir_mode) != 0) |
|
pfatal("creation of %s failed", tmpbuf); |
if (system(buf)) |
free(tmpbuf); |
pfatal("%.40s failed", buf); |
|
} |
} |
|
|
/* |
/* |