From a06cbb1969a727914f2c7c8884dc05c08689720c Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Wed, 23 Jun 2021 16:30:22 -0400 Subject: Added 'dir_path_num()', and `dir_path_name()`. --- misc.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/misc.c b/misc.c index 6782ff4..b6309a2 100644 --- a/misc.c +++ b/misc.c @@ -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; +} -- cgit v1.2.3-13-gbd6f