summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
1a50efd)
The :IF-EXISTS option is only in very new versions of CLisp. It turns
out that the bizarre double-pathname-merging bug in POSIX:COPY-FILE
doesn't cause trouble if the source is absolute (unsurprising, in
retrospect) so I could use TRUENAME to dig my way out of this mess; but
COPY-FILE will clobber the target file before looking to see whether the
source succeeds (unless persuaded otherwise with :IF-EXISTS, which only
works if RENAME-FILE understands that option).
Give up, and use rename(2) through the FFI.
(safely-trail safe))
stream))
(safely-trail safe))
stream))
+#+clisp
+(progn
+ (ffi:def-call-out %rename (:name "rename")
+ (:language :stdc)
+ (:arguments (from ffi:c-string)
+ (to ffi:c-string))
+ (:return-type ffi:int)))
+
(declaim (inline rename))
(defun rename (old new)
(declaim (inline rename))
(defun rename (old new)
(let ((target (make-pathname :directory '(:relative)
:defaults new)))
(let ((target (make-pathname :directory '(:relative)
:defaults new)))
- #-clisp (rename-file old target)
- #+clisp (rename-file old target :if-exists :overwrite)))
+ (rename-file old target))
+
+ #+clisp
+ (let ((rc (%rename (namestring old) (namestring new))))
+ (when (= rc -1)
+ (error "Failed to rename ~S to ~S: ~A" old new (posix:strerror)))))
(defun delete-file-without-moaning (file)
"Delete the FILE, ignoring errors."
(defun delete-file-without-moaning (file)
"Delete the FILE, ignoring errors."