aboutsummaryrefslogtreecommitdiffstats
path: root/src/blogc-make/exec-native.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/blogc-make/exec-native.c')
-rw-r--r--src/blogc-make/exec-native.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/blogc-make/exec-native.c b/src/blogc-make/exec-native.c
index 179216a..2417173 100644
--- a/src/blogc-make/exec-native.c
+++ b/src/blogc-make/exec-native.c
@@ -24,15 +24,9 @@
int
-bm_exec_native_cp(bm_filectx_t *source, bm_filectx_t *dest, bool verbose)
+bm_exec_native_mkdir_p(const char *filename)
{
- if (verbose)
- printf("Copying '%s' to '%s'\n", source->path, dest->path);
- else
- printf(" COPY %s\n", dest->short_path);
- fflush(stdout);
-
- char *fname = bc_strdup(dest->path);
+ char *fname = bc_strdup(filename);
for (char *tmp = fname; *tmp != '\0'; tmp++) {
if (*tmp != '/' && *tmp != '\\')
continue;
@@ -51,6 +45,23 @@ bm_exec_native_cp(bm_filectx_t *source, bm_filectx_t *dest, bool verbose)
}
free(fname);
+ return 0;
+}
+
+
+int
+bm_exec_native_cp(bm_filectx_t *source, bm_filectx_t *dest, bool verbose)
+{
+ if (verbose)
+ printf("Copying '%s' to '%s'\n", source->path, dest->path);
+ else
+ printf(" COPY %s\n", dest->short_path);
+ fflush(stdout);
+
+ int rv = bm_exec_native_mkdir_p(dest->path);
+ if (rv != 0)
+ return rv;
+
int fd_from = open(source->path, O_RDONLY);
if (fd_from < 0) {
fprintf(stderr, "blogc-make: error: failed to open source file to copy "