Add more error code support to GHC.Windows (patch)
This patch adds some infrastructure for the Windows I/O manager currently in progress. It organizes
GHC.Windows a little, and adds some things:
LPWSTRtype alias. I'm not a Windows expert, but I think we should avoid LPTSTR in our FFI declarations. It depends on whether or not the
UNICODEmacro is defined—a notion that makes little sense in a Haskell program. Using
LPWSTRmakes our intention clearer.
LPTSTR in for compatibility. Should we DEPRECATE it?
c_maperrno_func. The existing
GetLastError, converts the result, then sets
c_maperrno_funcexposes the conversion as a pure function.
This helps eliminate a caveat in failWith, which expects
GetLastError to return the error passed to
failWith. This is not the case, for example, when throwing the error in another thread.
failIf, ... error guards from System.Win32.Types.
errCodeToIOError: Lets you work with the system error code more directly.
throwGetLastError now attaches the system error message, making it (almost) equivalent to errorWin from
System.Win32.Types. Moreover, it no longer has the side effect of setting
errno, thanks to