diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2016-07-13 03:28:51 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2016-07-13 03:28:51 +0300 |
commit | 54db9a94963826141c79ffe30df0453f85a117c8 (patch) | |
tree | 22190418728ed381c1c0c45c2d58c5acfda06423 /src/Registry.hs | |
parent | reorder imports (diff) | |
download | windows-env-54db9a94963826141c79ffe30df0453f85a117c8.tar.gz windows-env-54db9a94963826141c79ffe30df0453f85a117c8.zip |
bugfix + refactoring
Diffstat (limited to 'src/Registry.hs')
-rw-r--r-- | src/Registry.hs | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/Registry.hs b/src/Registry.hs index 4aac81d..4a7c593 100644 --- a/src/Registry.hs +++ b/src/Registry.hs @@ -83,9 +83,6 @@ exitCodeSuccess = 0 exitCodeFileNotFound :: WinAPI.ErrCode exitCodeFileNotFound = 0x2 -exitCodeMoreData :: WinAPI.ErrCode -exitCodeMoreData = 0xea - raiseError :: String -> WinAPI.ErrCode -> IO a raiseError functionName ret | ret == exitCodeFileNotFound = raiseDoesNotExistError functionName @@ -121,11 +118,9 @@ getString keyHandle valueName = alloca $ \dataSizePtr -> do poke dataSizePtr 0 ret <- WinAPI.c_RegQueryValueEx keyPtr valueNamePtr WinAPI.nullPtr WinAPI.nullPtr WinAPI.nullPtr dataSizePtr - if ret == exitCodeSuccess - then return "" - else if ret /= exitCodeMoreData - then raiseError "RegQueryValueEx" ret - else getStringTerminated keyPtr valueNamePtr dataSizePtr + if ret /= exitCodeSuccess + then raiseError "RegQueryValueEx" ret + else getStringTerminated keyPtr valueNamePtr dataSizePtr where getStringTerminated keyPtr valueNamePtr dataSizePtr = do dataSize <- peek dataSizePtr |