RawFilePath will need to support Windows too

Of course, readSymbolicLink always fails on Windows, but now it's ready
for other things that don't fail there.
This commit is contained in:
Joey Hess 2019-12-06 14:17:48 -04:00
parent f39f018ee0
commit 360942ba12
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -1,4 +1,11 @@
{- Portability shim around System.Posix.Files.ByteString
-
- On unix, this makes syscalls using RawFilesPaths as efficiently as
- possible.
-
- On Windows, filenames are in unicode, so RawFilePaths have to be
- decoded. So this library will work, but less efficiently than using
- FilePath would.
-
- Copyright 2019 Joey Hess <id@joeyh.name>
-
@ -17,12 +24,9 @@ import System.Posix.Files.ByteString
import System.Posix.ByteString.FilePath
#else
import qualified Data.ByteString as B
import System.IO.Error
type RawFilePath = B.ByteString
import qualified System.PosixCompat as P
import Utility.FileSystemEncoding
readSymbolicLink :: RawFilePath -> IO RawFilePath
readSymbolicLink _ = ioError $ mkIOError illegalOperationErrorType x Nothing Nothing
where
x = "Utility.RawFilePath.readSymbolicLink: not supported"
readSymbolicLink f = toRawFilePath <$> P.readSymbolicLink (fromRawFilePath f)
#endif