-- no input from stdin

{- | runs an action in a different directory without changing the current
     directory globally. -}
withinDirectory :: FilePath -> IO a -> IO a
withinDirectory p a = do
  d <- getCurrentDirectory
  setCurrentDirectory p
  r <- a
  setCurrentDirectory d
  return r

-- | calls openTempFile but directly writes content and closes the file
withinDirectory :: FilePath -> IO a -> IO a
withinDirectory p a = do
  d <- getCurrentDirectory
  setCurrentDirectory p
  r <- a
  setCurrentDirectory d
  return r

-- | calls openTempFile but directly writes content and closes the file
withinDirectory p a = do
  d <- getCurrentDirectory
  setCurrentDirectory p
  r <- a
  setCurrentDirectory d
  return r

-- | calls openTempFile but directly writes content and closes the file