aboutsummaryrefslogtreecommitdiffstats
path: root/src/export.c
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2018-11-20 13:49:36 +0200
committergramanas <anastasis.gramm2@gmail.com>2018-11-20 13:49:36 +0200
commitda31bfd28301d63571eccb4abdd6b0a65b05c621 (patch)
tree33e0054d00927bd9dcfaabad41fdea53624c7b8e /src/export.c
parent78ee1c72c670a71bfd165448676fc65bff802916 (diff)
downloadck-da31bfd28301d63571eccb4abdd6b0a65b05c621.tar.gz
ck-da31bfd28301d63571eccb4abdd6b0a65b05c621.tar.bz2
ck-da31bfd28301d63571eccb4abdd6b0a65b05c621.zip
Add export action, fix util_is_link bug
Diffstat (limited to 'src/export.c')
-rw-r--r--src/export.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/export.c b/src/export.c
new file mode 100644
index 0000000..b9f6aa3
--- /dev/null
+++ b/src/export.c
@@ -0,0 +1,48 @@
+/* export.c - the export action ---------------------------------------*- C -*-
+ *
+ * This file is part of ck, the config keeper
+ *
+ * -----------------------------------------------------------------------------
+ *
+ * Copyright (C) 2018 Anastasis Grammenos
+ * GPLv3 (see LICENCE for the full notice)
+ *
+ * -------------------------------------------------------------------------- */
+#include <libgen.h>
+
+#include "dblayer.h"
+#include "ckerrlog.h"
+
+ERRLOG(export);
+
+int run_EXPORT(UserOpt *opt, Conf *conf) {
+ if (system("which tar > /dev/null 2>&1") != 0) {
+ ERR("No tar avaliable. Please make sure you have tar installed.");
+ return -1;
+ }
+
+ char cmd[STR_L] = "tar -zcvf ck.tar.gz";
+ if(conf->scrt_dir) {
+ strcat(cmd, " -C ");
+ strcat(cmd, conf->scrt_dir);
+ strcat(cmd, " ../");
+ strcat(cmd, basename(conf->scrt_dir));
+ }
+ strcat(cmd, " -C ");
+ strcat(cmd, conf->vc_dir);
+ strcat(cmd, " ../");
+ strcat(cmd, basename(conf->vc_dir));
+ strcat(cmd, " -C ");
+ strcat(cmd, opt->confDir);
+ strcat(cmd, " ckrc -C ");
+ strcat(cmd, opt->confDir);
+ strcat(cmd, " ckdb");
+
+ hLOG("Running: %s", cmd);
+ strcat(cmd, " > /dev/null 2>&1");
+ return system(cmd);
+}
+
+void print_EXPORT_help() {
+ HELP("ck export");
+}