diff options
-rw-r--r-- | misc.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -73,3 +73,21 @@ char *make_str(const char *str) { memcpy(s, str, length+1); return s; } + +char *dir_path_num(const char *root, int num) { + /* Get the length of the path. */ + int len = snprintf(NULL, 0, "%s/%i", root, num); + /* Create the directory path. */ + char *dir = calloc(len+1, sizeof(char)) + sprintf(pr_dir, "%s/%i", root, num); + return dir; +} + +char *dir_path_name(const char *root, char *name) { + /* Get the length of the path. */ + int len = snprintf(NULL, 0, "%s/%s", root, name); + /* Create the directory path. */ + char *dir = calloc(len+1, sizeof(char)); + sprintf(dir, "%s/%s", root, name); + return dir; +} |