work around absNormPath not working on Windows

When making git-annex links, we want unix-style paths in the link targets.
This commit is contained in:
Joey Hess 2014-02-06 17:08:54 -04:00
parent 28cabd9909
commit 897d877472
5 changed files with 27 additions and 5 deletions

View file

@ -21,10 +21,10 @@ import Control.Applicative
import Data.Char
import qualified System.FilePath.Posix as Posix
#else
import qualified "MissingH" System.Path as MissingH
import System.Posix.Files
#endif
import qualified "MissingH" System.Path as MissingH
import Utility.Monad
import Utility.UserInfo
@ -42,7 +42,18 @@ absNormPath :: FilePath -> FilePath -> Maybe FilePath
#ifndef mingw32_HOST_OS
absNormPath dir path = MissingH.absNormPath dir path
#else
absNormPath dir path = Just $ combine dir path
absNormPath dir path = MissingH.absNormPath dir path
#endif
{- On Windows, this converts the paths to unix-style, in order to run
- MissingH's absNormPath on them. Resulting path will use / separators. -}
#ifndef mingw32_HOST_OS
absNormPathUnix dir path = MissingH.absNormPath dir path
#else
absNormPathUnix dir path = Just $ combine dir path
absNormPathUnix dir path = MissingH.absNormPath (fromdos dir) (fromdos path)
where
fromdos = replace "\\" "/"
#endif
{- Returns the parent directory of a path.