summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2021-06-23 16:30:22 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2021-06-23 16:30:22 -0400
commita06cbb1969a727914f2c7c8884dc05c08689720c (patch)
treec812e06ad32ed6da46d3dd70440c9b887b34549f /misc.c
parent4ca70321e5639ac451ac3b1099242e8e148ab790 (diff)
Added 'dir_path_num()', and `dir_path_name()`.
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c18
1 files changed, 18 insertions, 0 deletions
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;
+}