mirror of
https://github.com/pygos/pkg-utils.git
synced 2024-11-22 12:59:46 +01:00
Fix mkdir_p for absolute directories
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
This commit is contained in:
parent
c23a2c8c33
commit
391e69eceb
1 changed files with 3 additions and 3 deletions
|
@ -12,17 +12,17 @@ int mkdir_p(const char *path)
|
||||||
size_t i, len;
|
size_t i, len;
|
||||||
char *buffer;
|
char *buffer;
|
||||||
|
|
||||||
while (*path == '/')
|
while (path[0] == '/' && path[1] == '/')
|
||||||
++path;
|
++path;
|
||||||
|
|
||||||
if (*path == '\0')
|
if (*path == '\0' || (path[0] == '/' && path[1] == '\0'))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
len = strlen(path) + 1;
|
len = strlen(path) + 1;
|
||||||
buffer = alloca(len);
|
buffer = alloca(len);
|
||||||
|
|
||||||
for (i = 0; i < len; ++i) {
|
for (i = 0; i < len; ++i) {
|
||||||
if (path[i] == '/' || path[i] == '\0') {
|
if (i > 0 && (path[i] == '/' || path[i] == '\0')) {
|
||||||
buffer[i] = '\0';
|
buffer[i] = '\0';
|
||||||
|
|
||||||
if (mkdir(buffer, 0755) != 0) {
|
if (mkdir(buffer, 0755) != 0) {
|
||||||
|
|
Loading…
Reference in a new issue