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
LPWSTR
type alias. I'm not a Windows expert, but I think we should avoid LPTSTR in our FFI declarations. It depends on whether or not theUNICODE
macro is defined—a notion that makes little sense in a Haskell program. UsingLPWSTR
makes our intention clearer.
I left LPTSTR
in for compatibility. Should we DEPRECATE it?
-
c_maperrno_func
. The existingc_maperrno
callsGetLastError
, converts the result, then setserrno
.c_maperrno_func
exposes 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 |