Provide conversions between PosixPath and WindowsPath
- Dominant language
- Haskell
- Stars
- 74
- Forks
- 38
- PR merge metrics
- No merged PRs in 30d
Description
https://github.com/haskell/tar/pull/88 introduces
```haskell
-- | We assume UTF-8 on posix and UTF-16 on windows.
toWindowsPath :: MonadThrow m => PosixPath -> m WindowsPath
toWindowsPath posix = do
str <- PFP.decodeUtf posix
win <- WFP.encodeUtf str
pure $ WS.map (\c -> if WFP.isPathSeparator c then WFP.pathSeparator else c) win
-- | We assume UTF-8 on posix and UTF-16 on windows.
toPosixPath :: MonadThrow m => WindowsPath -> m PosixPath
toPosixPath win = do
str <- WFP.decodeUtf win
posix <- PFP.encodeUtf str
pure $ PS.map (\c -> if PFP.isPathSeparator c then PFP.pathSeparator else c) posix
```
IMHO such utilities should better be provided by `filepath` itself, ideally optimized to a single pass without any intermediate structures.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.