confer/src/gen.c

65 lines
1.2 KiB
C

#include "gen.h"
#include "args.h"
#include "config.h"
#include "error.h"
#include "intl.h"
#include "log.h"
#include "util.h"
#include <unistd.h>
bool gen_cmd() {
bool ret = false;
config_t cfg;
if (args.count != 2) {
error(_("Please specify a directory for the repository"));
return ret;
}
if (!exists(args.list[1]) || !is_dir(args.list[1])) {
error(_("Failed to access the directory"));
return ret;
}
if (chdir(args.list[1]) < 0) {
error(_("Failed to change directory to the specified directory"));
return ret;
}
success(_("Loaded repository configuration"));
if (!config_load(&cfg, "mc.cfg")) {
error(_("Failed to load the configuration file (mc.cfg):"));
details(errch);
return ret;
}
success(_("Loaded repository configuration"));
config_print(&cfg);
target_t *cur = cfg.t_first;
int counter = 0;
info(_("Copying all the targets"));
bar_init();
while (cur && counter++) {
if(!target_copy(cur, true)){
error(_("Failed to copy the target:"));
details(errch);
bar_free();
goto END;
}
success(_("%s: copy success"));
bar(counter, cfg.t_len);
cur = cur->next;
}
bar_free();
ret = true;
END:
config_free(&cfg);
return ret;
}