avoid using Utility.Path.AbsRel in Utility.Path.Windows
AbsRel depends on unix, but Utility.Path.Windows will be used in some libraries that are part of the setup-depends, which cannot depend on unix. The only reason that AbsRel uses getWorkingDirectory on unix is that it returns RawFilePath. getCurrentDirectory returns FilePath and so needs a conversion to RawFilePath. Looks like a newer version of directory will fix that, by using OsPath, so eventually AbsPath should be able to switch to using getCurrentDirectory on unix, and then the small code duplication in this commit won't be needed. Sponsored-by: Dartmouth College's Datalad project
This commit is contained in:
parent
3c08af0da1
commit
505f1a654b
1 changed files with 6 additions and 3 deletions
|
@ -12,11 +12,13 @@ module Utility.Path.Windows (
|
|||
convertToWindowsNativeNamespace
|
||||
) where
|
||||
|
||||
import Utility.Path.AbsRel
|
||||
import Utility.Path
|
||||
import Utility.FileSystemEncoding
|
||||
|
||||
import System.FilePath.ByteString (RawFilePath)
|
||||
import System.FilePath.ByteString (RawFilePath, combine)
|
||||
import qualified Data.ByteString as B
|
||||
import qualified System.FilePath.Windows.ByteString as P
|
||||
import System.Directory (getCurrentDirectory)
|
||||
|
||||
{- Convert a filepath to use Windows's native namespace.
|
||||
- This avoids filesystem length limits.
|
||||
|
@ -34,7 +36,8 @@ convertToWindowsNativeNamespace f
|
|||
| otherwise = do
|
||||
-- Make absolute because any '.' and '..' in the path
|
||||
-- will not be resolved once it's converted.
|
||||
p <- absPath f
|
||||
cwd <- toRawFilePath <$> getCurrentDirectory
|
||||
let p = simplifyPath (combine cwd f)
|
||||
-- Normalize slashes.
|
||||
let p' = P.normalise p
|
||||
return (win32_file_namespace <> p')
|
||||
|
|
Loading…
Reference in a new issue