@@ -44,7 +44,7 @@ module System.OsPath
4444 , PS. encodeUtf
4545 , PS. unsafeEncodeUtf
4646 , PS. encodeWith
47- , PS. encodeFS
47+ , encodeFS
4848#if defined(WINDOWS) || defined(POSIX)
4949 , pstr
5050#else
@@ -55,7 +55,7 @@ module System.OsPath
5555 -- * Filepath deconstruction
5656 , PS. decodeUtf
5757 , PS. decodeWith
58- , PS. decodeFS
58+ , decodeFS
5959 , PS. unpack
6060
6161 -- * Word construction
@@ -115,12 +115,10 @@ import System.OsString.Windows as PS
115115 , toChar
116116 , decodeUtf
117117 , decodeWith
118- , decodeFS
119118 , pack
120119 , encodeUtf
121120 , unsafeEncodeUtf
122121 , encodeWith
123- , encodeFS
124122 , unpack
125123 )
126124import Data.Bifunctor ( bimap )
@@ -148,12 +146,10 @@ import System.OsString.Posix as PS
148146 , toChar
149147 , decodeUtf
150148 , decodeWith
151- , decodeFS
152149 , pack
153150 , encodeUtf
154151 , unsafeEncodeUtf
155152 , encodeWith
156- , encodeFS
157153 , unpack
158154 )
159155import Data.Bifunctor ( bimap )
@@ -165,12 +161,10 @@ import System.OsPath.Internal as PS
165161 ( osp
166162 , decodeUtf
167163 , decodeWith
168- , decodeFS
169164 , pack
170165 , encodeUtf
171166 , unsafeEncodeUtf
172167 , encodeWith
173- , encodeFS
174168 , unpack
175169 )
176170import System.OsPath.Types
@@ -187,6 +181,7 @@ import Data.Bifunctor
187181 ( bimap )
188182#endif
189183import System.OsString.Internal.Types
184+ import System.OsString.Encoding.Internal
190185
191186
192187------------------------
@@ -1439,3 +1434,36 @@ isRelative (OSSTRING_NAME x) = C.isRelative x
14391434-- > isAbsolute x == not (isRelative x)
14401435isAbsolute :: FILEPATH_NAME -> Bool
14411436isAbsolute (OSSTRING_NAME x) = C. isAbsolute x
1437+
1438+
1439+ -- things not defined in os-string
1440+
1441+ #ifdef WINDOWS
1442+ encodeFS :: String -> IO WindowsPath
1443+ encodeFS = fmap WindowsString . encodeWithBaseWindows
1444+
1445+ decodeFS :: WindowsPath -> IO String
1446+ decodeFS (WindowsString x) = decodeWithBaseWindows x
1447+ #elif defined(POSIX)
1448+ encodeFS :: String -> IO PosixPath
1449+ encodeFS = fmap PosixString . encodeWithBasePosix
1450+
1451+ decodeFS :: PosixPath -> IO String
1452+ decodeFS (PosixString x) = decodeWithBasePosix x
1453+ #else
1454+ encodeFS :: String -> IO OsPath
1455+ #if defined(mingw32_HOST_OS) || defined(__MINGW32__)
1456+ encodeFS = fmap (OsString . WindowsString ) . encodeWithBaseWindows
1457+ #else
1458+ encodeFS = fmap (OsString . PosixString ) . encodeWithBasePosix
1459+ #endif
1460+
1461+ decodeFS :: OsPath -> IO String
1462+ #if defined(mingw32_HOST_OS) || defined(__MINGW32__)
1463+ decodeFS (OsString (WindowsString x)) = decodeWithBaseWindows x
1464+ #else
1465+ decodeFS (OsString (PosixString x)) = decodeWithBasePosix x
1466+ #endif
1467+
1468+ #endif
1469+
0 commit comments