simplify
This commit is contained in:
parent
e4ef688b98
commit
0f3b78ec29
1 changed files with 3 additions and 16 deletions
|
@ -6,7 +6,6 @@
|
||||||
-}
|
-}
|
||||||
|
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
{-# LANGUAGE CPP #-}
|
|
||||||
{-# OPTIONS_GHC -fno-warn-tabs #-}
|
{-# OPTIONS_GHC -fno-warn-tabs #-}
|
||||||
|
|
||||||
module Utility.Path.AbsRel (
|
module Utility.Path.AbsRel (
|
||||||
|
@ -20,17 +19,13 @@ module Utility.Path.AbsRel (
|
||||||
|
|
||||||
import System.FilePath.ByteString
|
import System.FilePath.ByteString
|
||||||
import qualified Data.ByteString as B
|
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 Control.Applicative
|
||||||
import Prelude
|
import Prelude
|
||||||
|
|
||||||
import Utility.Path
|
import Utility.Path
|
||||||
import Utility.UserInfo
|
import Utility.UserInfo
|
||||||
import Utility.FileSystemEncoding
|
import Utility.FileSystemEncoding
|
||||||
|
import qualified Utility.RawFilePath as R
|
||||||
|
|
||||||
{- Makes a path absolute.
|
{- Makes a path absolute.
|
||||||
-
|
-
|
||||||
|
@ -58,11 +53,7 @@ absPath file
|
||||||
-- so also used here for consistency.
|
-- so also used here for consistency.
|
||||||
| isAbsolute file = return $ simplifyPath file
|
| isAbsolute file = return $ simplifyPath file
|
||||||
| otherwise = do
|
| otherwise = do
|
||||||
#ifdef mingw32_HOST_OS
|
cwd <- R.getCurrentDirectory
|
||||||
cwd <- toRawFilePath <$> getCurrentDirectory
|
|
||||||
#else
|
|
||||||
cwd <- getWorkingDirectory
|
|
||||||
#endif
|
|
||||||
return $ absPathFrom cwd file
|
return $ absPathFrom cwd file
|
||||||
|
|
||||||
{- Constructs the minimal relative path from the CWD to a file.
|
{- Constructs the minimal relative path from the CWD to a file.
|
||||||
|
@ -78,11 +69,7 @@ relPathCwdToFile f
|
||||||
-- and does not contain any ".." component.
|
-- and does not contain any ".." component.
|
||||||
| isRelative f && not (".." `B.isInfixOf` f) = return f
|
| isRelative f && not (".." `B.isInfixOf` f) = return f
|
||||||
| otherwise = do
|
| otherwise = do
|
||||||
#ifdef mingw32_HOST_OS
|
c <- R.getCurrentDirectory
|
||||||
c <- toRawFilePath <$> getCurrentDirectory
|
|
||||||
#else
|
|
||||||
c <- getWorkingDirectory
|
|
||||||
#endif
|
|
||||||
relPathDirToFile c f
|
relPathDirToFile c f
|
||||||
|
|
||||||
{- Constructs a minimal relative path from a directory to a file. -}
|
{- Constructs a minimal relative path from a directory to a file. -}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue