| Copyright | (c) The University of Glasgow 2009 |
|---|---|
| License | see libraries/base/LICENSE |
| Maintainer | libraries@haskell.org |
| Stability | internal |
| Portability | non-portable |
| Safe Haskell | Safe |
| Language | Haskell2010 |
GHC.Windows
Description
Windows functionality used by several modules.
ToDo: this just duplicates part of System.Win32.Types, which isn't available yet. We should move some Win32 functionality down here, maybe as part of the grand reorganisation of the base package...
Synopsis
- type BOOL = Bool
- type LPBOOL = Ptr BOOL
- type BYTE = Word8
- type DWORD = Word32
- type DDWORD = Word64
- type UINT = Word32
- type ULONG = Word32
- type ErrCode = DWORD
- type HANDLE = Ptr ()
- type LPWSTR = Ptr CWchar
- type LPTSTR = LPWSTR
- type LPCTSTR = LPTSTR
- type LPVOID = Ptr ()
- type LPDWORD = Ptr DWORD
- type LPSTR = Ptr CChar
- type LPCSTR = LPSTR
- type LPCWSTR = LPWSTR
- type WORD = Word16
- type UCHAR = Word8
- type NTSTATUS = Int32
- iNFINITE :: DWORD
- iNVALID_HANDLE_VALUE :: HANDLE
- throwGetLastError :: String -> IO a
- failWith :: String -> ErrCode -> IO a
- getLastError :: IO ErrCode
- getErrorMessage :: ErrCode -> IO String
- errCodeToIOError :: String -> ErrCode -> IO IOError
- failIf :: (a -> Bool) -> String -> IO a -> IO a
- failIf_ :: (a -> Bool) -> String -> IO a -> IO ()
- failIfNull :: String -> IO (Ptr a) -> IO (Ptr a)
- failIfZero :: (Eq a, Num a) => String -> IO a -> IO a
- failIfFalse_ :: String -> IO Bool -> IO ()
- failUnlessSuccess :: String -> IO ErrCode -> IO ()
- failUnlessSuccessOr :: ErrCode -> String -> IO ErrCode -> IO Bool
- c_maperrno :: IO ()
- c_maperrno_func :: ErrCode -> Errno
- ddwordToDwords :: DDWORD -> (DWORD, DWORD)
- dwordsToDdword :: (DWORD, DWORD) -> DDWORD
- nullHANDLE :: HANDLE
Types
Be careful with this. LPTSTR can mean either WCHAR* or CHAR*, depending on whether the UNICODE macro is defined in the corresponding C code. Consider using LPWSTR instead.
Constants
System errors
throwGetLastError :: String -> IO a Source #
Get the last system error, and throw it as an IOError exception.
failWith :: String -> ErrCode -> IO a Source #
Convert a Windows error code to an exception, then throw it.
getLastError :: IO ErrCode Source #
Get the last system error produced in the current thread.
getErrorMessage :: ErrCode -> IO String Source #
Get a string describing a Windows error code. This uses the
FormatMessage system call.
errCodeToIOError :: String -> ErrCode -> IO IOError Source #
Convert a Windows error code to an exception.
Guards for system calls that might fail
Mapping system errors to errno
c_maperrno :: IO () Source #
Map the last system error to an errno value, and assign it to errno.
c_maperrno_func :: ErrCode -> Errno Source #
Pure function variant of c_maperrno that does not call GetLastError
or modify errno.
Misc
nullHANDLE :: HANDLE Source #