refactor
This commit is contained in:
parent
581dc819e1
commit
789254747b
1 changed files with 18 additions and 0 deletions
18
Utility/FileSystemEncoding.hs
Normal file
18
Utility/FileSystemEncoding.hs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
{- File system encoding handling.
|
||||||
|
-
|
||||||
|
- Copyright 2012 Joey Hess <joey@kitenet.net>
|
||||||
|
-
|
||||||
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
|
-}
|
||||||
|
|
||||||
|
module Utility.FileSystemEncoding where
|
||||||
|
|
||||||
|
import GHC.IO.Encoding (getFileSystemEncoding)
|
||||||
|
import GHC.Foreign as GHC
|
||||||
|
|
||||||
|
{- Marshal a Haskell FilePath into a NUL terminated C string using temporary
|
||||||
|
- storage. The FilePath is encoded using the filesystem encoding,
|
||||||
|
- reversing the decoding that should have been done when the FilePath
|
||||||
|
- was obtained. -}
|
||||||
|
withFilePath :: FilePath -> (CString -> IO a) -> IO a
|
||||||
|
withFilePath fp f = getFileSystemEncoding >>= \enc -> GHC.withCString enc fp f
|
Loading…
Reference in a new issue