sb-posix should use _wstat instead of _stat on Windows

Bug #1267540 reported by Timofei Shatrov on 2014-01-09
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Undecided
Unassigned

Bug Description

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

Reference for _stat, _wstat: http://msdn.microsoft.com/en-us/library/14h5k7ff.aspx

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.

description: updated
Paul F. Dietz (paul-f-dietz) wrote :

Poster Grue on u/lisp on Reddit requests this bug be fixed.

https://www.reddit.com/r/lisp/comments/9s6nen/sbcl_1413_released/e92nb4k/?context=3

"May I suggest this one? It seems easy to fix, but would be a huge win."

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers