summaryrefslogtreecommitdiff
path: root/src/dged/path.h
diff options
context:
space:
mode:
authorAlbert Cervin <albert@acervin.com>2024-01-29 23:34:07 +0100
committerAlbert Cervin <albert@acervin.com>2024-01-30 15:04:44 +0100
commitdda591fa33ac10c433289aa3ee862c3ded41eed3 (patch)
tree9a25edbc810fd5d8fbc20f367c71ebcd81bb6026 /src/dged/path.h
parent880199011075afd4f2d9bd16c7ce42a04741b5b7 (diff)
downloaddged-dda591fa33ac10c433289aa3ee862c3ded41eed3.tar.gz
dged-dda591fa33ac10c433289aa3ee862c3ded41eed3.tar.xz
dged-dda591fa33ac10c433289aa3ee862c3ded41eed3.zip
Syntax highlight is a go
Diffstat (limited to 'src/dged/path.h')
-rw-r--r--src/dged/path.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/dged/path.h b/src/dged/path.h
index da62457..8ea9977 100644
--- a/src/dged/path.h
+++ b/src/dged/path.h
@@ -38,3 +38,28 @@ static char *to_abspath(const char *path) {
return exp;
}
}
+
+static const char *join_path_with_delim(const char *p1, const char *p2,
+ const char delim) {
+ size_t len1 = strlen(p1);
+ size_t len2 = strlen(p2);
+
+ char *path = malloc(len1 + len2 + 2);
+ uint32_t idx = 0;
+ memcpy(&path[idx], p1, len1);
+ idx += len1;
+ path[idx++] = '/';
+ memcpy(&path[idx], p2, len2);
+ idx += len2;
+ path[idx++] = '\0';
+
+ return path;
+}
+
+static const char *join_path(const char *p1, const char *p2) {
+#ifdef __unix__
+ return join_path_with_delim(p1, p2, '/');
+#elif defined(_WIN32) || defined(WIN32)
+ return join_path_with_delim(p1, p2, '\\');
+#endif
+}