Permalink
Browse files

add os version and api support query

  • Loading branch information...
luite committed Jun 5, 2012
1 parent 6928c04 commit 33ee46575f08c881750c6076dfca45ac3917785f
Showing with 29 additions and 1 deletion.
  1. +19 −0 System/OSX/FSEvents.hs
  2. +5 −0 cbits/c_fsevents.c
  3. +4 −0 cbits/c_fsevents.h
  4. +1 −1 hfsevents.cabal
View
@@ -16,6 +16,8 @@ module System.OSX.FSEvents
, eventFlagItemRenamed, eventFlagItemModified, eventFlagItemFinderInfoMod
, eventFlagItemChangeOwner, eventFlagItemXattrMod
, eventFlagItemIsFile, eventFlagItemIsDir, eventFlagItemIsSymlink
+ -- query api support
+ , fileLevelEventsSupported, osVersion
) where
import Control.Concurrent
@@ -25,6 +27,7 @@ import Control.Monad
import Data.Bits
import Data.Serialize.Get
import Data.Word
+import Data.Int
import Foreign.C.String
import Foreign.C.Types
import Foreign.Marshal.Alloc
@@ -170,6 +173,18 @@ consumeMsgs h a = readEvents
stop = hClose h >> return ()
readHeader = liftM3 (,,) getWord64host getWord64host getWord64host
+osVersion :: IO (Integer, Integer, Integer)
+osVersion = alloca $ \major -> do
+ alloca $ \minor -> do
+ alloca $ \bugfix -> do
+ c_osVersion major minor bugfix
+ liftM3 (,,) (peekfi major) (peekfi minor) (peekfi bugfix)
+ where
+ peekfi = fmap fromIntegral . peek
+
+fileLevelEventsSupported :: IO Bool
+fileLevelEventsSupported = fmap (>= (10,7,0)) osVersion
+
foreign import ccall safe "c_fsevents.h createWatch" c_createWatch :: Ptr (Ptr CChar)
-> CInt
-> Word32
@@ -181,4 +196,8 @@ foreign import ccall safe "c_fsevents.h createWatch" c_createWatch :: Ptr (Ptr C
foreign import ccall safe "c_fsevents.h destroyWatch" c_destroyWatch :: Ptr CWatch
-> IO ()
+foreign import ccall safe "c_fsevents.h osVersion" c_osVersion :: Ptr Int32
+ -> Ptr Int32
+ -> Ptr Int32
+ -> IO ()
View
@@ -96,3 +96,8 @@ int destroyWatch(watch* w) {
free(w);
}
+void osVersion(SInt32 *majorVersion, SInt32 *minorVersion, SInt32 *bugFixVersion) {
+ Gestalt(gestaltSystemVersionMajor, majorVersion);
+ Gestalt(gestaltSystemVersionMinor, minorVersion);
+ Gestalt(gestaltSystemVersionBugFix, bugFixVersion);
+}
View
@@ -21,5 +21,9 @@ int createWatch ( char** folders
int destroyWatch(watch* w);
+void osVersion( SInt32 *majorVersion
+ , SInt32 *minorVersion
+ , SInt32 *bugFixVersion);
+
#endif
View
@@ -1,5 +1,5 @@
name: hfsevents
-version: 0.1.1
+version: 0.1.2
synopsis: File/folder watching for OS X
homepage: http://github.com/luite/hfsevents
license: BSD3

0 comments on commit 33ee465

Please sign in to comment.