Merge pull request #86 from phst/bug83
Adapt to changes in Emacs 26
Philipp authored 6 years ago
GitHub committed 6 years ago
283 | 283 |
(f--destructive path (make-symbolic-link source path)))
|
284 | 284 |
|
285 | 285 |
(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."
|
287 | 288 |
(f--destructive to (rename-file from to t)))
|
288 | 289 |
|
289 | 290 |
(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."
|
291 | 294 |
(f--destructive to
|
292 | 295 |
(if (f-file? from)
|
293 | 296 |
(copy-file from to)
|
|
311 | 314 |
(unless (f-dir? from)
|
312 | 315 |
(error "Cannot copy contents as %s is a file" from))
|
313 | 316 |
(--each (f-entries from)
|
314 | |
(f-copy it to)))
|
|
317 |
(f-copy it (file-name-as-directory to))))
|
315 | 318 |
|
316 | 319 |
(defun f-touch (path)
|
317 | 320 |
"Update PATH last modification date or create if it does not exist."
|
102 | 102 |
(with-playground
|
103 | 103 |
(f-touch "foo.txt")
|
104 | 104 |
(f-mkdir "bar")
|
105 | |
(f-move "foo.txt" "bar")
|
|
105 |
(f-move "foo.txt" "bar/")
|
106 | 106 |
(should-exist "bar/foo.txt")))
|
107 | 107 |
|
108 | 108 |
(ert-deftest f-move-test/move-absolute-path ()
|
|
111 | 111 |
(f-mkdir "bar")
|
112 | 112 |
(f-move
|
113 | 113 |
(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)))
|
115 | 115 |
(should-exist "bar/foo.txt")))
|
116 | 116 |
|
117 | 117 |
(ert-deftest f-move-test/rename-relative-path ()
|
|
152 | 152 |
(f-mkdir "foo")
|
153 | 153 |
(f-mkdir "bar")
|
154 | 154 |
(f-write "FILE" 'utf-8 "foo/file.txt")
|
155 | |
(f-copy "foo" "bar")
|
|
155 |
(f-copy "foo" "bar/")
|
156 | 156 |
(should-exist "foo/file.txt" "FILE")
|
157 | 157 |
(should-exist "bar/foo/file.txt" "FILE")))
|
158 | 158 |
|
|
171 | 171 |
(f-write "FILE" 'utf-8 "foo/file.txt")
|
172 | 172 |
(f-copy
|
173 | 173 |
(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)))
|
175 | 175 |
(should-exist "foo/file.txt" "FILE")
|
176 | 176 |
(should-exist "bar/foo/file.txt" "FILE")))
|
177 | 177 |
|