diff options
author | Joey Hess <joey@kitenet.net> | 2012-03-09 18:52:03 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-03-09 18:52:03 -0400 |
commit | 789254747bceeaac004236275a6c1906f859945a (patch) | |
tree | 9e42656963f86f839a94d8fd9bd787cc833b6ad6 /Utility/FileSystemEncoding.hs | |
parent | 581dc819e1025d00a6979a245a5c839fad116ea7 (diff) |
refactor
Diffstat (limited to 'Utility/FileSystemEncoding.hs')
-rw-r--r-- | Utility/FileSystemEncoding.hs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Utility/FileSystemEncoding.hs b/Utility/FileSystemEncoding.hs new file mode 100644 index 000000000..6970a10de --- /dev/null +++ b/Utility/FileSystemEncoding.hs @@ -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 |