simplify
authorJoey Hess <joeyh@joeyh.name>
Thu, 26 Oct 2023 17:59:33 +0000 (13:59 -0400)
committerJoey Hess <joeyh@joeyh.name>
Thu, 26 Oct 2023 18:00:02 +0000 (14:00 -0400)
Utility/Path/AbsRel.hs

index 4007fbbb0fc1ddbdbf48f85625d1f09ad76bbb62..b339c5234d3e81f361d213824dc0a9eeab075aa9 100644 (file)
@@ -6,7 +6,6 @@
  -}
 
 {-# LANGUAGE OverloadedStrings #-}
-{-# LANGUAGE CPP #-}
 {-# OPTIONS_GHC -fno-warn-tabs #-}
 
 module Utility.Path.AbsRel (
@@ -20,17 +19,13 @@ module Utility.Path.AbsRel (
 
 import System.FilePath.ByteString
 import qualified Data.ByteString as B
-#ifdef mingw32_HOST_OS
-import System.Directory (getCurrentDirectory)
-#else
-import System.Posix.Directory.ByteString (getWorkingDirectory)
-#endif
 import Control.Applicative
 import Prelude
 
 import Utility.Path
 import Utility.UserInfo
 import Utility.FileSystemEncoding
+import qualified Utility.RawFilePath as R
 
 {- Makes a path absolute.
  -
@@ -58,11 +53,7 @@ absPath file
        -- so also used here for consistency.
        | isAbsolute file = return $ simplifyPath file
        | otherwise = do
-#ifdef mingw32_HOST_OS
-               cwd <- toRawFilePath <$> getCurrentDirectory
-#else
-               cwd <- getWorkingDirectory
-#endif
+               cwd <- R.getCurrentDirectory
                return $ absPathFrom cwd file
 
 {- Constructs the minimal relative path from the CWD to a file.
@@ -78,11 +69,7 @@ relPathCwdToFile f
        -- and does not contain any ".." component.
        | isRelative f && not (".." `B.isInfixOf` f) = return f
        | otherwise = do
-#ifdef mingw32_HOST_OS
-               c <- toRawFilePath <$> getCurrentDirectory
-#else
-               c <- getWorkingDirectory
-#endif
+               c <- R.getCurrentDirectory
                relPathDirToFile c f
 
 {- Constructs a minimal relative path from a directory to a file. -}