diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2021-06-23 16:30:22 -0400 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2021-06-23 16:30:22 -0400 |
commit | a06cbb1969a727914f2c7c8884dc05c08689720c (patch) | |
tree | c812e06ad32ed6da46d3dd70440c9b887b34549f /misc.c | |
parent | 4ca70321e5639ac451ac3b1099242e8e148ab790 (diff) |
Added 'dir_path_num()', and `dir_path_name()`.
Diffstat (limited to 'misc.c')
-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; +} |