@@ -44,7 +44,7 @@ module System.OsPath
44
44
, PS. encodeUtf
45
45
, PS. unsafeEncodeUtf
46
46
, PS. encodeWith
47
- , PS. encodeFS
47
+ , encodeFS
48
48
#if defined(WINDOWS) || defined(POSIX)
49
49
, pstr
50
50
#else
@@ -55,7 +55,7 @@ module System.OsPath
55
55
-- * Filepath deconstruction
56
56
, PS. decodeUtf
57
57
, PS. decodeWith
58
- , PS. decodeFS
58
+ , decodeFS
59
59
, PS. unpack
60
60
61
61
-- * Word construction
@@ -115,12 +115,10 @@ import System.OsString.Windows as PS
115
115
, toChar
116
116
, decodeUtf
117
117
, decodeWith
118
- , decodeFS
119
118
, pack
120
119
, encodeUtf
121
120
, unsafeEncodeUtf
122
121
, encodeWith
123
- , encodeFS
124
122
, unpack
125
123
)
126
124
import Data.Bifunctor ( bimap )
@@ -148,12 +146,10 @@ import System.OsString.Posix as PS
148
146
, toChar
149
147
, decodeUtf
150
148
, decodeWith
151
- , decodeFS
152
149
, pack
153
150
, encodeUtf
154
151
, unsafeEncodeUtf
155
152
, encodeWith
156
- , encodeFS
157
153
, unpack
158
154
)
159
155
import Data.Bifunctor ( bimap )
@@ -165,12 +161,10 @@ import System.OsPath.Internal as PS
165
161
( osp
166
162
, decodeUtf
167
163
, decodeWith
168
- , decodeFS
169
164
, pack
170
165
, encodeUtf
171
166
, unsafeEncodeUtf
172
167
, encodeWith
173
- , encodeFS
174
168
, unpack
175
169
)
176
170
import System.OsPath.Types
@@ -187,6 +181,7 @@ import Data.Bifunctor
187
181
( bimap )
188
182
#endif
189
183
import System.OsString.Internal.Types
184
+ import System.OsString.Encoding.Internal
190
185
191
186
192
187
------------------------
@@ -1439,3 +1434,36 @@ isRelative (OSSTRING_NAME x) = C.isRelative x
1439
1434
-- > isAbsolute x == not (isRelative x)
1440
1435
isAbsolute :: FILEPATH_NAME -> Bool
1441
1436
isAbsolute (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