]> git.eshelyaron.com Git - emacs.git/commitdiff
Ensure that directories exist when copying files from archive
authorVisuwesh <visuweshm@gmail.com>
Sun, 17 Jul 2022 09:22:32 +0000 (11:22 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Sun, 17 Jul 2022 09:22:32 +0000 (11:22 +0200)
* lisp/arc-mode.el (archive-copy-file): If the directory the file is
being extracted to does not exist, then create it (bug#56603).

lisp/arc-mode.el

index 35189f1bfd8cd2a3bfb037c950445e21359d3064..dbb8c202091e0964574867b727e47ab2a75726ce 100644 (file)
@@ -1073,13 +1073,16 @@ NEW-NAME."
     (user-error "Can't copy a list of files to a single file"))
   (save-excursion
     (dolist (file files)
-      (let ((write-to (if (file-directory-p new-name)
-                          (expand-file-name file new-name)
-                        new-name)))
+      (let* ((write-to (if (file-directory-p new-name)
+                           (expand-file-name file new-name)
+                         new-name))
+             (write-to-dir (file-name-directory write-to)))
         (when (and (file-exists-p write-to)
                    (not (yes-or-no-p (format "%s already exists; overwrite? "
                                              write-to))))
           (user-error "Not overwriting %s" write-to))
+        (unless (file-directory-p write-to-dir)
+          (make-directory write-to-dir t))
         (archive-goto-file file)
         (let* ((descr (archive-get-descr))
                (archive (buffer-file-name))