From da31bfd28301d63571eccb4abdd6b0a65b05c621 Mon Sep 17 00:00:00 2001 From: gramanas Date: Tue, 20 Nov 2018 13:49:36 +0200 Subject: Add export action, fix util_is_link bug --- src/export.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/export.c (limited to 'src/export.c') 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 + +#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"); +} -- cgit v1.2.3