base-4.7.0.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 HANDLE = Ptr () Source

type LPTSTR = LPWSTR Source

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

failIf :: (a -> Bool) -> String -> IO a -> IO a Source

failIf_ :: (a -> Bool) -> String -> IO a -> IO () Source

failIfNull :: String -> IO (Ptr a) -> IO (Ptr a) Source

failIfZero :: (Eq a, Num a) => String -> IO a -> IO a Source

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 () 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.