[Openmcl-devel] pathname-encoding-name

Takehiko Abe keke at gol.com
Mon Oct 4 00:58:29 PDT 2010


Sorry for my slow response.

Gary Byers wrote:

> Something that I read a few years ago suggested that trying to (do
> the equivalent of) set PATHNAME-ENCODING-NAME automatically (from
> locale information) was a bad idea, because that locale information
> was often wrong.  That might be true, but it might be reasonable to
> do that (and suggest that people fix incorrect locale information,
> which might affect other programs as well) rather than require that
> it be set in one's init file (when it's only really needed/used on
> some platforms.)

I think linux is moving to UTF-8 filenames and it is the only sane
choice for modern desktop. Only that it is not enforced or mandated by
the system.  Use of other national encodings can be considered legacy.
For instance, Gnome already assumes UTF-8 filenames unless specified
otherwise via G_FILENAME_ENCODING or G_BROKEN_FILENAMES.

http://library.gnome.org/devel/glib/stable/glib-running.html

So, I don't think setting PATHNAME-ENCODING-NAME through locales info
is worth the trouble.

> There's a macro called WITH-FILENAME-CSTRs that expands into the
> right platform-specific code.  That symbol's exported from CCL; I
> don't remember whether or where it was documented, but it's probably
> the right thing to use to fix UNIX-RENAME.

%DELETE-FILES also needs a fix.

diff --git a/source/level-1/linux-files.lisp b/source/level-1/linux-files.lisp
index 7ba7c93..0b482ca 100644
--- a/source/level-1/linux-files.lisp
+++ b/source/level-1/linux-files.lisp
@@ -864,7 +864,7 @@ environment variable. Returns NIL if there is no user with the ID uid."
               (return nil))))))))

 (defun %delete-file (name)
-  (with-cstrs ((n name))
+  (with-filename-cstrs ((n name))
     (int-errno-call (#+windows-target #__unlink #-windows-target #_unlink n))))

 (defun os-command (string)
diff --git a/source/lib/pathnames.lisp b/source/lib/pathnames.lisp
index 3dd42d6..b5a65b6 100644
--- a/source/lib/pathnames.lisp
+++ b/source/lib/pathnames.lisp
@@ -79,8 +79,8 @@
 ;File or directory Manipulations

 (defun unix-rename (old-name new-name)
-  (with-cstrs ((old old-name)
-               (new new-name))
+  (with-filename-cstrs ((old old-name)
+                        (new new-name))
     #+windows-target
     (#__unlink new)
     (let* ((res (#_rename old new)))



More information about the Openmcl-devel mailing list