From f1c7dc12127fcbad411c28df57e9ce194bd66509 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 4 Feb 2012 12:24:00 -0400 Subject: 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? --- Utility/StatFS.hsc | 4 +--- Utility/Touch.hsc | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'Utility') 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 @@ -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) -- cgit v1.2.3