summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS1
-rw-r--r--src/bin/e_fm_op.c38
2 files changed, 30 insertions, 9 deletions
diff --git a/AUTHORS b/AUTHORS
index be4dbcadb..d93288ec6 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -34,3 +34,4 @@ Gwanglim Lee <gl77.lee@samsung.com>
34Thomas Gstädtner <thomas@gstaedtner.net> 34Thomas Gstädtner <thomas@gstaedtner.net>
35q66 <quaker66@gmail.com> 35q66 <quaker66@gmail.com>
36Tom Hacohen (TAsn) <tom@stosb.com> 36Tom Hacohen (TAsn) <tom@stosb.com>
37Maxime Villard <rustyBSD@gmx.fr>
diff --git a/src/bin/e_fm_op.c b/src/bin/e_fm_op.c
index e593a9a8c..dfec0fea8 100644
--- a/src/bin/e_fm_op.c
+++ b/src/bin/e_fm_op.c
@@ -1163,30 +1163,30 @@ _e_fm_op_copy_dir(E_Fm_Op_Task *task)
1163static int 1163static int
1164_e_fm_op_copy_link(E_Fm_Op_Task *task) 1164_e_fm_op_copy_link(E_Fm_Op_Task *task)
1165{ 1165{
1166 int len; 1166 char *lnk_path;
1167 char path[PATH_MAX];
1168 1167
1169 len = readlink(task->src.name, path, sizeof(path) - 1); 1168 lnk_path = ecore_file_readlink(task->src.name);
1170 if (len < 0) 1169 if (!lnk_path)
1171 { 1170 {
1172 _E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot read link '%s'.", task->src.name); 1171 _E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot read link '%s'.", task->src.name);
1173 } 1172 }
1174 else 1173 else
1175 { 1174 {
1176 path[len] = 0; 1175 E_FM_OP_DEBUG("Creating link from '%s' to '%s'\n", lnk_path, task->dst.name);
1177 1176
1178 if (symlink(path, task->dst.name) != 0) 1177 if (symlink(lnk_path, task->dst.name) != 0)
1179 { 1178 {
1180 if (errno == EEXIST) 1179 if (errno == EEXIST)
1181 { 1180 {
1182 if (unlink(task->dst.name) == -1) 1181 if (unlink(task->dst.name) == -1)
1183 _E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot unlink '%s': %s.", task->dst.name); 1182 _E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot unlink '%s': %s.", task->dst.name);
1184 if (symlink(path, task->dst.name) == -1) 1183 if (symlink(lnk_path, task->dst.name) == -1)
1185 _E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot create link from '%s' to '%s': %s.", path, task->dst.name); 1184 _E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot create link from '%s' to '%s': %s.", lnk_path, task->dst.name);
1186 } 1185 }
1187 else 1186 else
1188 _E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot create link from '%s' to '%s': %s.", path, task->dst.name); 1187 _E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot create link from '%s' to '%s': %s.", lnk_path, task->dst.name);
1189 } 1188 }
1189 free(lnk_path);
1190 } 1190 }
1191 task->dst.done += task->src.st.st_size; 1191 task->dst.done += task->src.st.st_size;
1192 1192
@@ -1347,6 +1347,26 @@ _e_fm_op_copy_atom(E_Fm_Op_Task *task)
1347 return 1; 1347 return 1;
1348 } 1348 }
1349 1349
1350 if (S_ISLNK(task->src.st.st_mode))
1351 {
1352 char *dst_dir;
1353
1354 dst_dir = ecore_file_dir_get(task->dst.name);
1355 if (dst_dir)
1356 {
1357 char dst_path[PATH_MAX];
1358 const char *dst_name;
1359
1360 dst_name = ecore_file_file_get(task->src.name);
1361 if ((strlen(dst_dir) + strlen(dst_name)) >= PATH_MAX)
1362 _E_FM_OP_ERROR_SEND_WORK(task, 0, "Not copying link: path too long", dst_path);
1363
1364 snprintf(dst_path, sizeof(dst_path), "%s/%s", dst_dir, dst_name);
1365 task->dst.name = strdup(dst_path);
1366 free(dst_dir);
1367 }
1368 }
1369
1350 if (_e_fm_op_handle_overwrite(task)) return 1; 1370 if (_e_fm_op_handle_overwrite(task)) return 1;
1351 1371
1352 if (S_ISDIR(task->src.st.st_mode)) 1372 if (S_ISDIR(task->src.st.st_mode))