diff options
author | Joey Hess <joey@kitenet.net> | 2012-03-10 11:38:38 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-03-10 11:38:38 -0400 |
commit | f9d44cccd993926ce0180437ebcb6d08fdb1efd7 (patch) | |
tree | e2d6ac9bc8e6af956212f3796c2352289154130f /Utility/FileSystemEncoding.hs | |
parent | 10d9315b59ce1c0d1be91ab7034f87e1f58a0710 (diff) |
perhaps more clear type
Diffstat (limited to 'Utility/FileSystemEncoding.hs')
-rw-r--r-- | Utility/FileSystemEncoding.hs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Utility/FileSystemEncoding.hs b/Utility/FileSystemEncoding.hs index fe4202a75..cf1a6a731 100644 --- a/Utility/FileSystemEncoding.hs +++ b/Utility/FileSystemEncoding.hs @@ -12,6 +12,7 @@ import qualified GHC.IO.Encoding as Encoding import Foreign.C import System.IO import System.IO.Unsafe +import qualified Data.Hash.MD5 as MD5 {- Sets a Handle to use the filesystem encoding. This causes data - written or read from it to be encoded/decoded the same @@ -28,8 +29,7 @@ withFilePath :: FilePath -> (CString -> IO a) -> IO a withFilePath fp f = Encoding.getFileSystemEncoding >>= \enc -> GHC.withCString enc fp f -{- Encodes a FilePath into a String of encoded bytes, applying the - - filesystem encoding. +{- Encodes a FilePath into a Str, applying the filesystem encoding. - - This use of unsafePerformIO is belived to be safe; GHC's interface - only allows doing this conversion with CStrings, and the CString buffer @@ -37,7 +37,7 @@ withFilePath fp f = Encoding.getFileSystemEncoding - effects. -} {-# NOINLINE encodeFilePath #-} -encodeFilePath :: FilePath -> String -encodeFilePath fp = unsafePerformIO $ do +encodeFilePath :: FilePath -> MD5.Str +encodeFilePath fp = MD5.Str $ unsafePerformIO $ do enc <- Encoding.getFileSystemEncoding GHC.withCString enc fp $ GHC.peekCString Encoding.char8 |