emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 1ab3b48 43/92: Implemented file copying


From: Alexey Veretennikov
Subject: [elpa] master 1ab3b48 43/92: Implemented file copying
Date: Thu, 11 Jun 2015 19:48:04 +0000

branch: master
commit 1ab3b48b1045c06999953db4c669288a7d138c27
Author: Alexey Veretennikov <address@hidden>
Commit: Alexey Veretennikov <address@hidden>

    Implemented file copying
---
 ztree-diff.el |   26 ++++++++++++++++++++++++--
 1 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/ztree-diff.el b/ztree-diff.el
index 50c8b7c..00e9067 100644
--- a/ztree-diff.el
+++ b/ztree-diff.el
@@ -165,8 +165,30 @@ including . and ..")
                                           (ztree-diff-node-short-name node)
                                           (if copy-to-right "RIGHT" "LEFT")
                                           destination-path)))
-            nil                         ; do copy
-            ))))))
+            (if (file-directory-p source-path)
+                nil                     ; TODO: implement directory copy
+              (let ((target-path (concat
+                                  (file-name-as-directory destination-path)
+                                  (file-name-nondirectory
+                                   (directory-file-name source-path)))))
+                (let ((err (condition-case error-trap
+                               (progn
+                                 ;; ask for overwrite
+                                 ;; keep time stamp
+                                 (copy-file source-path target-path 1 t)
+                                 nil)
+                             (error error-trap))))
+                  ;; error message if failed
+                  (if err (message (concat "Error: " (nth 2 err)))
+                    (progn              ; otherwise:
+                      ;; assuming all went ok when left and right nodes are 
the same
+                      ;; set both as not different
+                      (ztree-diff-node-set-different node nil)
+                      ;; update left/right paths
+                      (if copy-to-right
+                          (ztree-diff-node-set-right-path node target-path)
+                        (ztree-diff-node-set-left-path node target-path))
+                      (ztree-refresh-buffer (line-number-at-pos)))))))))))))
 
           
 (defun ztree-diff (dir1 dir2)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]