aboutsummaryrefslogtreecommitdiffstats
path: root/src/blogc-make/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/blogc-make/utils.c')
-rw-r--r--src/blogc-make/utils.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/blogc-make/utils.c b/src/blogc-make/utils.c
index 91b7b53..8f69e44 100644
--- a/src/blogc-make/utils.c
+++ b/src/blogc-make/utils.c
@@ -28,7 +28,7 @@ bm_generate_filename(const char *dir, const char *prefix, const char *fname,
bool have_ext = ext != NULL && ext[0] != '\0';
bool have_ext_noslash = have_ext && ext[0] != '/';
bool is_index = have_fname && have_ext && (
- (0 == strcmp(fname, "index")) && ext[0] == '/');
+ (0 == strcmp(fname, "index")) && ext[0] == '/') && !have_prefix;
bc_string_t *rv = bc_string_new();
@@ -70,6 +70,38 @@ bm_generate_filename(const char *dir, const char *prefix, const char *fname,
char*
+bm_generate_filename2(const char *dir, const char *prefix, const char *fname,
+ const char *prefix2, const char *fname2, const char *ext)
+{
+ bool have_prefix = prefix != NULL && prefix[0] != '\0';
+ bool have_fname = fname != NULL && fname[0] != '\0';
+ bool have_prefix2 = prefix2 != NULL && prefix2[0] != '\0';
+
+ bc_string_t *p = bc_string_new();
+
+ if (have_prefix)
+ bc_string_append(p, prefix);
+
+ if (have_prefix && (have_fname || have_prefix2))
+ bc_string_append_c(p, '/');
+
+ if (have_fname)
+ bc_string_append(p, fname);
+
+ if (have_fname && have_prefix2)
+ bc_string_append_c(p, '/');
+
+ if (have_prefix2)
+ bc_string_append(p, prefix2);
+
+ char *rv = bm_generate_filename(dir, p->str, fname2, ext);
+ bc_string_free(p, true);
+
+ return rv;
+}
+
+
+char*
bm_abspath(const char *path, bc_error_t **err)
{
if (err == NULL || *err != NULL)