diff options
author | gramanas <anastasis.gramm2@gmail.com> | 2018-11-20 13:49:36 +0200 |
---|---|---|
committer | gramanas <anastasis.gramm2@gmail.com> | 2018-11-20 13:49:36 +0200 |
commit | da31bfd28301d63571eccb4abdd6b0a65b05c621 (patch) | |
tree | 33e0054d00927bd9dcfaabad41fdea53624c7b8e /src/export.c | |
parent | 78ee1c72c670a71bfd165448676fc65bff802916 (diff) | |
download | ck-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.c | 48 |
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"); +} |