- alloca $ \ ptr_dEnt -> do
- p <- withCString path $ \s ->
- throwErrnoIfNullRetry "getDirectoryContents" (c_opendir s)
- loop ptr_dEnt p
+ alloca $ \ ptr_dEnt ->
+ bracket
+ (withCString path $ \s ->
+ throwErrnoIfNullRetry desc (c_opendir s))
+ (\p -> throwErrnoIfMinus1_ desc (c_closedir p))
+ (\p -> loop ptr_dEnt p)