(re)Hi,
when copying symlinks, it creates a symlink to the
destination but with the name of the pointed file/folder.

It causes problems, ex: we can't copy two symlinks
pointing to the same file, because they will have the
same name.

Here is a patch which corrects this. I also found other
problems and bugs in file managing; I will look at it
tomorrow.

ps: I don't have svn commit access.

Thanks,
Maxime

--- e_fm_op.c	2012-07-20 20:34:03.000000000 +0200
+++ e_fm_op.c	2012-07-20 21:09:15.828917681 +0200
@@ -1163,29 +1163,37 @@
 static int
 _e_fm_op_copy_link(E_Fm_Op_Task *task)
 {
-   int len;
-   char path[PATH_MAX];
+   char dst_path[PATH_MAX];
+   char *dst_dir, *lnk_path;
+   const char *dst_name;
 
-   len = readlink(task->src.name, path, sizeof(path) - 1);
-   if (len < 0)
+   lnk_path = ecore_file_readlink(task->src.name);
+   if (!lnk_path)
      {
         _E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot read link '%s'.", task->src.name);
      }
    else
      {
-        path[len] = 0;
+        dst_dir = ecore_file_dir_get(task->dst.name);
+        dst_name = ecore_file_file_get(task->src.name);
 
-        if (symlink(path, task->dst.name) != 0)
+        if ((strlen(dst_dir)+strlen(dst_name)) >= PATH_MAX)
+           _E_FM_OP_ERROR_SEND_WORK(task, 0, "Not copying: path too long", dst_path);
+
+        snprintf(dst_path, sizeof(dst_path), "%s/%s", dst_dir, dst_name);
+        E_FM_OP_DEBUG("Creating link from '%s' to '%s'\n", lnk_path, dst_path);
+
+        if (symlink(lnk_path, dst_path) != 0)
           {
              if (errno == EEXIST)
                {
-                  if (unlink(task->dst.name) == -1)
-                    _E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot unlink '%s': %s.", task->dst.name);
-                  if (symlink(path, task->dst.name) == -1)
-                    _E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot create link from '%s' to '%s': %s.", path, task->dst.name);
+                  if (unlink(dst_path) == -1)
+                    _E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot unlink '%s': %s.", dst_path);
+                  if (symlink(lnk_path, dst_path) == -1)
+                    _E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot create link from '%s' to '%s': %s.", lnk_path, dst_path);
                }
              else
-               _E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot create link from '%s' to '%s': %s.", path, task->dst.name);
+               _E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot create link from '%s' to '%s': %s.", lnk_path, dst_path);
           }
      }
    task->dst.done += task->src.st.st_size;
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to