summaryrefslogtreecommitdiff
path: root/Utility
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-02-04 12:24:00 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-02-04 12:44:51 -0400
commitf1c7dc12127fcbad411c28df57e9ce194bd66509 (patch)
tree0d0eb4c787e8324c4992537c9b194c9d7d6154ad /Utility
parent44b115e0b11b3cb64301ed6dc478c597062ac0b6 (diff)
fix touch and statfs to work on any files in any locale
Use withCAString rather than withCString. XXX Actually, this only works in non-unicode locales when presented with unicode characters. Help?
Diffstat (limited to 'Utility')
-rw-r--r--Utility/StatFS.hsc4
-rw-r--r--Utility/Touch.hsc4
2 files changed, 3 insertions, 5 deletions
diff --git a/Utility/StatFS.hsc b/Utility/StatFS.hsc
index 937571dfa..6b9627463 100644
--- a/Utility/StatFS.hsc
+++ b/Utility/StatFS.hsc
@@ -50,8 +50,6 @@ module Utility.StatFS ( FileSystemStats(..), getFileSystemStats ) where
import Foreign
import Foreign.C.Types
import Foreign.C.String
-import Data.ByteString (useAsCString)
-import Data.ByteString.Char8 (pack)
#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__) || defined (__APPLE__)
# include <sys/param.h>
@@ -105,7 +103,7 @@ getFileSystemStats path =
return Nothing
#else
allocaBytes (#size struct statfs) $ \vfs ->
- useAsCString (pack path) $ \cpath -> do
+ withCAString path $ \cpath -> do
res <- c_statfs cpath vfs
if res == -1 then return Nothing
else do
diff --git a/Utility/Touch.hsc b/Utility/Touch.hsc
index fd3320cd1..41d3e17b8 100644
--- a/Utility/Touch.hsc
+++ b/Utility/Touch.hsc
@@ -64,7 +64,7 @@ foreign import ccall "utimensat"
touchBoth file atime mtime follow =
allocaArray 2 $ \ptr ->
- withCString file $ \f -> do
+ withCAString file $ \f -> do
pokeArray ptr [atime, mtime]
r <- c_utimensat at_fdcwd f ptr flags
when (r /= 0) $ throwErrno "touchBoth"
@@ -101,7 +101,7 @@ foreign import ccall "lutimes"
touchBoth file atime mtime follow =
allocaArray 2 $ \ptr ->
- withCString file $ \f -> do
+ withCAString file $ \f -> do
pokeArray ptr [atime, mtime]
r <- syscall f ptr
if (r /= 0)