blob: d4239ff8c4b825483293624f8ab928481c64f54e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#include "paths.h"
#include "errno.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "sys/stat.h"
#include "unistd.h"
char template[] = "/tmp/pow/XXXXXX";
int pow_create_dir_for_package(char **path) {
if (mkdir("/tmp/pow", 0700)) {
if (errno != EEXIST) {
printf("failed to create temp dir\n");
return 1;
}
}
char *new_path = malloc(strlen(template) + 1);
if (!new_path) {
return 1;
}
strcpy(new_path, template);
if (!mkdtemp(new_path)) {
printf("failed to make dir\n");
free(new_path);
return 1;
}
printf("%s\n", new_path);
*path = new_path;
return 0;
}
|