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:
- A
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 theUNICODEmacro is defined—a notion that makes little sense in a Haskell program. UsingLPWSTRmakes our intention clearer.
I left LPTSTR in for compatibility. Should we DEPRECATE it?
-
c_maperrno_func. The existingc_maperrnocallsGetLastError, converts the result, then setserrno.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.
-
failWith,failIf, ... error guards from System.Win32.Types. -
ErrCode,getLastError,getErrorMessage,errCodeToIOError: Lets you work with the system error code more directly. iNVALID_HANDLE_VALUE
Behavior change: 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 c_maperrno_func.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 7.6.1 |
| Type | FeatureRequest |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | libraries/base |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | #7353 (closed) |
| CC | |
| Operating system | |
| Architecture |