| 1234567891011121314151617181920212223242526272829 |
- #include <sys/stat.h>
- #include <stdlib.h>
- #include <string.h>
- #include <stdio.h>
- #include <errno.h>
- #include <time.h>
- #include "sandbox.h"
- int init_env(t_param *params)
- {
- char * path = params->tmppath = (char *) malloc(sizeof(*path) * (strlen(params->tmpdir) + 24));
- sprintf(path, "%s/sandbox_%ld:%d", params->tmpdir, time(NULL), getpid());
- if (mkdir(path, 0) == -1)
- {
- fprintf(stderr, "Cannot create directory %s: %s\n", path, strerror(errno));
- return -1;
- }
- return 0;
- }
- void release_env(t_param *params)
- {
- rmdir(params->tmppath);
- /* TODO remove files */
- free(params->tmppath);
- free(params);
- }
|