Codebase list f-el / c032ec9
Merge pull request #86 from phst/bug83 Adapt to changes in Emacs 26 Philipp authored 6 years ago GitHub committed 6 years ago
2 changed file(s) with 10 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
283283 (f--destructive path (make-symbolic-link source path)))
284284
285285 (defun f-move (from to)
286 "Move or rename FROM to TO."
286 "Move or rename FROM to TO.
287 If TO is a directory name, move FROM into TO."
287288 (f--destructive to (rename-file from to t)))
288289
289290 (defun f-copy (from to)
290 "Copy file or directory FROM to TO."
291 "Copy file or directory FROM to TO.
292 If FROM names a directory and TO is a directory name, copy FROM
293 into TO as a subdirectory."
291294 (f--destructive to
292295 (if (f-file? from)
293296 (copy-file from to)
311314 (unless (f-dir? from)
312315 (error "Cannot copy contents as %s is a file" from))
313316 (--each (f-entries from)
314 (f-copy it to)))
317 (f-copy it (file-name-as-directory to))))
315318
316319 (defun f-touch (path)
317320 "Update PATH last modification date or create if it does not exist."
102102 (with-playground
103103 (f-touch "foo.txt")
104104 (f-mkdir "bar")
105 (f-move "foo.txt" "bar")
105 (f-move "foo.txt" "bar/")
106106 (should-exist "bar/foo.txt")))
107107
108108 (ert-deftest f-move-test/move-absolute-path ()
111111 (f-mkdir "bar")
112112 (f-move
113113 (f-expand "foo.txt" f-test/playground-path)
114 (f-expand "bar" f-test/playground-path))
114 (file-name-as-directory (f-expand "bar" f-test/playground-path)))
115115 (should-exist "bar/foo.txt")))
116116
117117 (ert-deftest f-move-test/rename-relative-path ()
152152 (f-mkdir "foo")
153153 (f-mkdir "bar")
154154 (f-write "FILE" 'utf-8 "foo/file.txt")
155 (f-copy "foo" "bar")
155 (f-copy "foo" "bar/")
156156 (should-exist "foo/file.txt" "FILE")
157157 (should-exist "bar/foo/file.txt" "FILE")))
158158
171171 (f-write "FILE" 'utf-8 "foo/file.txt")
172172 (f-copy
173173 (f-expand "foo" f-test/playground-path)
174 (f-expand "bar" f-test/playground-path))
174 (file-name-as-directory (f-expand "bar" f-test/playground-path)))
175175 (should-exist "foo/file.txt" "FILE")
176176 (should-exist "bar/foo/file.txt" "FILE")))
177177