OsPath build flag no longer depends on filepath-bytestring
However, filepath-bytestring is still in Setup-Depends. That's because Utility.OsPath uses it when not built with OsPath. It would be maybe possible to make Utility.OsPath fall back to using filepath, and eliminate that dependency too, but it would mean either wrapping all of System.FilePath's functions, or using `type OsPath = FilePath` Annex.Import uses ifdefs to avoid converting back to FilePath when not on windows. On windows it's a bit slower due to that conversion. Utility.Path.Windows.convertToWindowsNativeNamespace got a bit slower too, but not really worth optimising I think. Note that importing Utility.FileSystemEncoding at the same time as System.Posix.ByteString will result in conflicting definitions for RawFilePath. filepath-bytestring avoids that by importing RawFilePath from System.Posix.ByteString, but that's not possible in Utility.FileSystemEncoding, since Setup-Depends does not include unix. This turned out not to affect any code in git-annex though. Sponsored-by: Leon Schuermann
This commit is contained in:
parent
ce697aa8ae
commit
2ff716be30
13 changed files with 81 additions and 68 deletions
|
@ -15,9 +15,10 @@ module Utility.Path.Windows (
|
|||
import Utility.Path
|
||||
import Utility.OsPath
|
||||
import Utility.SystemDirectory
|
||||
import Utility.FileSystemEncoding
|
||||
|
||||
import qualified Data.ByteString as B
|
||||
import qualified System.FilePath.Windows.ByteString as P
|
||||
import qualified System.FilePath.Windows as WinPath
|
||||
|
||||
{- Convert a filepath to use Windows's native namespace.
|
||||
- This avoids filesystem length limits.
|
||||
|
@ -36,9 +37,9 @@ convertToWindowsNativeNamespace f
|
|||
-- Make absolute because any '.' and '..' in the path
|
||||
-- will not be resolved once it's converted.
|
||||
cwd <- getCurrentDirectory
|
||||
let p = fromOsPath (simplifyPath (combine cwd (toOsPath f)))
|
||||
let p = simplifyPath (combine cwd (toOsPath f))
|
||||
-- Normalize slashes.
|
||||
let p' = P.normalise p
|
||||
let p' = encodeBS $ WinPath.normalise $ fromOsPath p
|
||||
return (win32_file_namespace <> p')
|
||||
where
|
||||
win32_dev_namespace = "\\\\.\\"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue