21 lines
435 B
C
21 lines
435 B
C
#ifndef _MAKE_PATH_H
|
|
#define _MAKE_PATH_H
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
|
|
char *mu_make_path(const char *prog_name, const char *src, const char *dst) {
|
|
size_t len = strlen(src) + strlen(dst) + 2;
|
|
char *full_path = malloc(len + 1);
|
|
if (full_path == NULL) {
|
|
fprintf(stderr, "%s: malloc() fail\n", prog_name);
|
|
return NULL;
|
|
}
|
|
|
|
snprintf(full_path, len, "%s/%s", src, dst);
|
|
return full_path;
|
|
}
|
|
|
|
#endif
|