Comment 0 for bug 1267540

Revision history for this message
Timofei Shatrov (timofei-shatrov) wrote :

If Unicode support is enabled, sb-posix:stat fails with Unicode filenames on Windows. After some digging in SBCL source code/ MSFT documentations, I have found that calling foreign function _wstat instead of _stat does the trick.

See: https://github.com/sbcl/sbcl/blob/master/contrib/sb-posix/interface.lisp#L597

I used the following code to define sb-posix::wstat which I had to use in my code instead of sb-posix:stat.

(sb-posix::define-stat-call "_wstat"
                  sb-posix::pathname sb-posix::filename
                  (function sb-posix::int (sb-posix::c-string :external-format :ucs-2)
                            (* sb-posix::alien-stat)))

Which is a rather hacky workaround, so it would be nice if SBCL supported this out of the box.

To reproduce run (sb-posix:stat "some filename containing unicode characters")

I was using Windows threaded build "1.1.4.0.mswin.1288-90ab477", but the same problem clearly exists in the latest source code as linked above.