aboutsummaryrefslogtreecommitdiffstats
path: root/src/blogc-make/exec-native.c
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2017-01-03 03:15:07 +0100
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2017-01-03 03:15:07 +0100
commita4bddf83cbbac86c3734b8c399e65c7341385a85 (patch)
tree4682d345d352c9e285925c8a073fcc72ad22fc02 /src/blogc-make/exec-native.c
parentaa8871ffe2e335b6f4a5107c15e978ba99a9fae5 (diff)
downloadblogc-a4bddf83cbbac86c3734b8c399e65c7341385a85.tar.gz
blogc-a4bddf83cbbac86c3734b8c399e65c7341385a85.tar.bz2
blogc-a4bddf83cbbac86c3734b8c399e65c7341385a85.zip
blogc-make: fixed clean rule
Diffstat (limited to 'src/blogc-make/exec-native.c')
-rw-r--r--src/blogc-make/exec-native.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/blogc-make/exec-native.c b/src/blogc-make/exec-native.c
index 32874b4..8b87d18 100644
--- a/src/blogc-make/exec-native.c
+++ b/src/blogc-make/exec-native.c
@@ -89,7 +89,7 @@ bm_exec_native_cp(bm_filectx_t *source, bm_filectx_t *dest, bool verbose)
int
-bm_exec_native_rm(bm_filectx_t *dest, bool verbose)
+bm_exec_native_rm(const char *output_dir, bm_filectx_t *dest, bool verbose)
{
if (verbose)
printf("Removing file '%s'\n", dest->path);
@@ -111,8 +111,7 @@ bm_exec_native_rm(bm_filectx_t *dest, bool verbose)
char *dir_short = dirname(short_path);
char *dir = dirname(path);
- while (0 != strcmp(dir_short, ".")) {
-
+ while ((0 != strcmp(dir_short, ".")) && (0 != strcmp(dir, output_dir))) {
DIR *d = opendir(dir);
if (d == NULL) {
fprintf(stderr, "error: failed to open directory (%s): %s\n",
@@ -154,6 +153,11 @@ bm_exec_native_rm(bm_filectx_t *dest, bool verbose)
dir = dirname(dir);
}
+ // try to remove output dir
+ // this is done on a best-effort basis, if we can't remove it, it probably
+ // have files, so we don't really want to remove it.
+ rmdir(output_dir);
+
free(short_path);
free(path);