Skip to content

Commit

Permalink
Merge pull request #14 from joeyh/master
Browse files Browse the repository at this point in the history
use file system encoding when peeking the filename from the event
  • Loading branch information
kolmodin committed Aug 3, 2015
2 parents e47e59c + 340da3c commit d28f59c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/System/INotify.hsc
Expand Up @@ -41,7 +41,7 @@ import Control.Exception as E (bracket, catch, mask_, SomeException)
import Data.Maybe
import Data.Map (Map)
import qualified Data.Map as Map
import Foreign.C hiding (withCString)
import Foreign.C hiding (withCString, peekCString)
import Foreign.Marshal hiding (void)
import Foreign.Ptr
import Foreign.Storable
Expand All @@ -56,7 +56,7 @@ import System.Posix.Internals
#endif
import System.Posix.Files
import GHC.IO.Encoding (getFileSystemEncoding)
import GHC.Foreign (withCString)
import GHC.Foreign (withCString, peekCString)

import System.INotify.Masks

Expand Down Expand Up @@ -268,7 +268,9 @@ read_events h =
len <- (#peek struct inotify_event, len) ptr :: IO CUInt
nameM <- if len == 0
then return Nothing
else fmap Just $ peekCString ((#ptr struct inotify_event, name) ptr)
else do
enc <- getFileSystemEncoding
fmap Just $ peekCString enc ((#ptr struct inotify_event, name) ptr)
let event_size = (#size struct inotify_event) + (fromIntegral len)
event = cEvent2Haskell (FDEvent wd mask cookie nameM)
rest <- read_events' (ptr `plusPtr` event_size) (r - event_size)
Expand Down

0 comments on commit d28f59c

Please sign in to comment.