fix: skip '.' and '..' entries while copying, append home dir to destination paths
This commit is contained in:
parent
3bc3c7b8db
commit
d7e347175f
@ -7,7 +7,7 @@ msgid ""
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2024-05-02 22:56+0300\n"
|
"POT-Creation-Date: 2024-05-02 23:10+0300\n"
|
||||||
"PO-Revision-Date: 2024-05-01 13:34+0300\n"
|
"PO-Revision-Date: 2024-05-01 13:34+0300\n"
|
||||||
"Last-Translator: <ngn@ngn.tf>\n"
|
"Last-Translator: <ngn@ngn.tf>\n"
|
||||||
"Language-Team: Turkish <gnome-turk@gnome.org>\n"
|
"Language-Team: Turkish <gnome-turk@gnome.org>\n"
|
||||||
@ -17,48 +17,48 @@ msgstr ""
|
|||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||||
|
|
||||||
#: src/config.c:23
|
#: src/config.c:24
|
||||||
msgid "Configuration does not have a name field"
|
msgid "Configuration does not have a name field"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/config.c:28
|
#: src/config.c:29
|
||||||
msgid "Configuration does not have an author field"
|
msgid "Configuration does not have an author field"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/config.c:33
|
#: src/config.c:34
|
||||||
msgid "Configuration does not have any targets"
|
msgid "Configuration does not have any targets"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/config.c:91
|
#: src/config.c:92
|
||||||
msgid "Configuration contains multiple targets with the same name"
|
msgid "Configuration contains multiple targets with the same name"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/config.c:113
|
#: src/config.c:116
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "Key %s is unknown"
|
msgid "Key %s is unknown"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/config.c:143
|
#: src/config.c:146
|
||||||
msgid "Configuration file not found"
|
msgid "Configuration file not found"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/config.c:158
|
#: src/config.c:161
|
||||||
msgid "Failed to parse configuration file"
|
msgid "Failed to parse configuration file"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/config.c:174
|
#: src/config.c:177
|
||||||
msgid "Configuration details:\n"
|
msgid "Configuration details:\n"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/config.c:175
|
#: src/config.c:178
|
||||||
msgid "Name"
|
msgid "Name"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/config.c:176
|
#: src/config.c:179
|
||||||
msgid "Author"
|
msgid "Author"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/config.c:178
|
#: src/config.c:181
|
||||||
msgid "Keywords"
|
msgid "Keywords"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@ -86,15 +86,10 @@ msgstr ""
|
|||||||
msgid "Copying all the targets"
|
msgid "Copying all the targets"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/gen.c:47
|
#: src/gen.c:48
|
||||||
msgid "Failed to copy the target:"
|
msgid "Failed to copy the target:"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/gen.c:53
|
|
||||||
#, c-format
|
|
||||||
msgid "%s: copy success"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: src/log.c:145
|
#: src/log.c:145
|
||||||
msgid "y"
|
msgid "y"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@ -221,7 +216,7 @@ msgstr ""
|
|||||||
msgid "Failed to open the directory: %s"
|
msgid "Failed to open the directory: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/target.c:76
|
#: src/target.c:79
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "Source directory \"%s\" does not exist"
|
msgid "Source directory \"%s\" does not exist"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "paths.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "intl.h"
|
#include "intl.h"
|
||||||
@ -99,7 +100,9 @@ int config_handler(void *data, const char *section, const char *key, const char
|
|||||||
config->t_last->desc = strdup(value);
|
config->t_last->desc = strdup(value);
|
||||||
return 1;
|
return 1;
|
||||||
} else if (MATCHKEY("dst")) {
|
} else if (MATCHKEY("dst")) {
|
||||||
config->t_last->dst = strdup(value);
|
int len = strlen(value)+strlen(mc_root)+2;
|
||||||
|
config->t_last->dst = malloc(len);
|
||||||
|
join(config->t_last->dst, mc_root, value);
|
||||||
return 1;
|
return 1;
|
||||||
} else if (MATCHKEY("src")) {
|
} else if (MATCHKEY("src")) {
|
||||||
config->t_last->src = strdup(value);
|
config->t_last->src = strdup(value);
|
||||||
|
@ -44,13 +44,12 @@ bool gen_cmd() {
|
|||||||
|
|
||||||
while (cur && ++counter > 0) {
|
while (cur && ++counter > 0) {
|
||||||
if(!target_copy(cur, true)){
|
if(!target_copy(cur, true)){
|
||||||
|
bar_free();
|
||||||
error(_("Failed to copy the target:"));
|
error(_("Failed to copy the target:"));
|
||||||
details(errch);
|
details(errch);
|
||||||
bar_free();
|
|
||||||
goto END;
|
goto END;
|
||||||
}
|
}
|
||||||
|
|
||||||
success(_("%s: copy success"));
|
|
||||||
bar(counter, cfg.t_len);
|
bar(counter, cfg.t_len);
|
||||||
cur = cur->next;
|
cur = cur->next;
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
char *mc_lock_path;
|
char *mc_lock_path;
|
||||||
char *mc_tmp_path;
|
char *mc_tmp_path;
|
||||||
char *mc_root;
|
char *mc_root;
|
||||||
|
char *mc_home;
|
||||||
char *mc_dir;
|
char *mc_dir;
|
||||||
|
|
||||||
char *append_root(char *pth) {
|
char *append_root(char *pth) {
|
||||||
|
@ -28,7 +28,7 @@ bool target_is_valid(target_t *t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool target_copy_dir(char *src, char *dst) {
|
bool target_copy_dir(char *src, char *dst) {
|
||||||
if (!mksubdirsp(dst, 755))
|
if (!mksubdirsp(dst, 0755))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
DIR *dir = opendir(src);
|
DIR *dir = opendir(src);
|
||||||
@ -44,6 +44,9 @@ bool target_copy_dir(char *src, char *dst) {
|
|||||||
size_t dst_len = strlen(dst);
|
size_t dst_len = strlen(dst);
|
||||||
|
|
||||||
while ((ent = readdir(dir)) != NULL) {
|
while ((ent = readdir(dir)) != NULL) {
|
||||||
|
if(eq(ent->d_name, ".") || eq(ent->d_name, ".."))
|
||||||
|
continue;
|
||||||
|
|
||||||
size_t len = strlen(ent->d_name);
|
size_t len = strlen(ent->d_name);
|
||||||
char src_fp[src_len + len + 2], dst_fp[dst_len + len + 2];
|
char src_fp[src_len + len + 2], dst_fp[dst_len + len + 2];
|
||||||
|
|
||||||
@ -72,7 +75,7 @@ bool target_copy(target_t *t, bool fromdst) {
|
|||||||
dst = t->src;
|
dst = t->src;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!exists(t->src)) {
|
if (!exists(src)) {
|
||||||
error_set(_("Source directory \"%s\" does not exist"), src);
|
error_set(_("Source directory \"%s\" does not exist"), src);
|
||||||
errno = TargetSrcFail;
|
errno = TargetSrcFail;
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user