aboutsummaryrefslogtreecommitdiff
path: root/src/paths.c
blob: 20af56d8d13d4fd2ee9bc0a1e5b5fbfa8084be3e (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
#include "paths.h"

#include "stdio.h"
#include "stdlib.h"
#include "string.h"

char template[] = "/tmp/pow/XXXXXX";

int pow_create_dir_for_package(char **path) {
  char *new_path = malloc(strlen(template) + 1);

  if (!new_path) {
    return 1;
  }

  strcpy(new_path, template);

  if (!mkdtemp(new_path)) {
    free(new_path);
    return 1;
  }

  printf("%s\n", new_path);

  *path = new_path;

  return 0;
}