[Openmcl-devel] pathname-encoding-name

Takehiko Abe keke at gol.com
Sun Sep 12 04:28:30 PDT 2010


;;; On Linux x86_64

I realized that DIRECTORY won't work with non-ascii filenames
unless I set PATHNAME-ENCODING-NAME (to :utf-8 in my case).
This is odd because DIRECTORY worked before without it.

Then, I found that RENAME-FILE does not work with non-ascii filenames
and discovered that CCL::UNIX-RENAME uses plain WITH-CSTRS. This is
even odder because I think I remember RENAME-FILE worked with Japanese
filenames before.

Here's my attempt to fix CCL::UNIX-RENAME for Linux. I left darwin and
windows version intact but they also wouldn't work for non-latin chars
as is? And nobody noticed it before? Or am I missing something?


diff --git a/source/lib/pathnames.lisp b/source/lib/pathnames.lisp
index 3dd42d6..886c045 100644
--- a/source/lib/pathnames.lisp
+++ b/source/lib/pathnames.lisp
@@ -78,6 +78,7 @@
 ;-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
 ;File or directory Manipulations

+#+(or darwin-target windows-target)
 (defun unix-rename (old-name new-name)
   (with-cstrs ((old old-name)
                (new new-name))
@@ -89,6 +90,16 @@
         (values t nil)
         (values nil (%get-errno))))))

+#-(or darwin-target windows-target)
+(defun unix-rename (old-name new-name)
+  (with-encoded-cstrs (pathname-encoding-name) ((old old-name)
+                                                (new new-name))
+    (let* ((res (#_rename old new)))
+      (declare (fixnum res))
+      (if (zerop res)
+        (values t nil)
+        (values nil (%get-errno))))))
+
 (defun rename-file (file new-name &key (if-exists :error))
   "Rename FILE to have the specified NEW-NAME. If FILE is a stream open to a
   file, then the associated file is renamed."



More information about the Openmcl-devel mailing list