base-4.9.1.0: Basic libraries

Copyright(c) The University of Glasgow 2009
Licensesee libraries/base/LICENSE
Maintainerlibraries@haskell.org
Stabilityinternal
Portabilitynon-portable
Safe HaskellTrustworthy
LanguageHaskell2010

GHC.Windows

Contents

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

Types

type BOOL = Bool #

type LPBOOL = Ptr BOOL #

type BYTE = Word8 #

type DWORD = Word32 #

type UINT = Word32 #

type ErrCode = DWORD #

type HANDLE = Ptr () #

type LPTSTR = LPWSTR #

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 #

Get the last system error, and throw it as an IOError exception.

failWith :: String -> ErrCode -> IO a #

Convert a Windows error code to an exception, then throw it.

getLastError :: IO ErrCode #

Get the last system error produced in the current thread.

getErrorMessage :: ErrCode -> IO String #

Get a string describing a Windows error code. This uses the FormatMessage system call.

errCodeToIOError :: String -> ErrCode -> IO IOError #

Convert a Windows error code to an exception.

Guards for system calls that might fail

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 #

Mapping system errors to errno

On Windows, errno is defined by msvcrt.dll for compatibility with other systems, and is distinct from the system error as returned by GetLastError.

c_maperrno :: IO () #

Map the last system error to an errno value, and assign it to errno.

c_maperrno_func :: ErrCode -> Errno #

Pure function variant of c_maperrno that does not call GetLastError or modify errno.