diff options
author | Anastasis Grammenos <anastasis.gramm2@gmail.com> | 2018-10-27 00:49:06 +0300 |
---|---|---|
committer | Anastasis Grammenos <anastasis.gramm2@gmail.com> | 2018-10-27 00:49:06 +0300 |
commit | 401820e28b74e09bffdeaa25fcf6de518487a433 (patch) | |
tree | e0a6b4d0fafb4718a3eacee983e4694996f1f570 /src/actionhelper.c | |
parent | 2e1a9e0832b53c0f03a71ba76fdd76612517d03c (diff) | |
download | ck-401820e28b74e09bffdeaa25fcf6de518487a433.tar.gz ck-401820e28b74e09bffdeaa25fcf6de518487a433.tar.bz2 ck-401820e28b74e09bffdeaa25fcf6de518487a433.zip |
restore
Diffstat (limited to 'src/actionhelper.c')
-rw-r--r-- | src/actionhelper.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/actionhelper.c b/src/actionhelper.c index ad259a2..0269470 100644 --- a/src/actionhelper.c +++ b/src/actionhelper.c @@ -260,6 +260,36 @@ ListOpt list_make_options(cklist *args) { return listOpt; } +int restore_make_links(cklist *from, cklist *to) { + list_rewind(from); + list_rewind(to); + if (list_size(from) > 0 + && list_size(to) > 0 + && list_size(from) == list_size(to)) { + while (1) { + HELP("%s %d %d", list_get(to), util_file_exists(list_get(to), NULL), !util_is_file_link(list_get(to))); + if (util_file_exists(list_get(to), NULL) + || !util_is_file_link(list_get(to))) { + sERR("File %s already exists. Terminating.", list_get(to)); + return -1; + } + if (util_symlink_file(list_get(from), list_get(to))) { + sERR("Failed: %s -> %s", list_get(from), list_get(to)); + return -1; + } + LOG("Linking: %s -> %s", list_get(from), list_get(to)); + HELP("Linking: %s -> %s", list_get(from), list_get(to)); + if (!list_next(from)) { + break; + } + if (!list_next(to)) { + break; + } + } + } + return 0; +} + /*****************/ /* PRINT RESULTS */ /*****************/ @@ -317,6 +347,14 @@ void print_HELP_result(int err) { } } +void print_RESTORE_result(int err) { + if (!err) { + HELP("restore OK"); + return; + } + sERR("restore NOT OK"); +} + void print_INIT_help() { ckhelp("Initialize the database and create the file that holds"); ckhelp("the paths where configurations will be stored."); @@ -406,6 +444,11 @@ void print_HELP_help() { report_help(); } +void print_RESTORE_help() { + ckhelp("Restore help"); + report_help(); +} + void print_conf_help(void) { ckhelp("Set a different ck configuration directory.\n"); ckhelp("This has to be passed before any action or action argument"); |