packages feed

xattr 0.6.0 → 0.6.1

raw patch · 3 files changed

+83/−41 lines, 3 files

Files

System/Xattr.hsc view
@@ -19,12 +19,6 @@ -------------------------------------------------------------------------------- #include "HsXattrConfig.h" -#if !(HAVE_LIBATTR && HAVE_ATTR_XATTR_H && HAVE_SYS_TYPES_H)--module System.Xattr () where--#else- module System.Xattr     (     -- * Functions@@ -51,7 +45,11 @@     where  #include <sys/types.h>+#ifdef __APPLE__+#include <sys/xattr.h>+#else #include <attr/xattr.h>+#endif  import Data.Functor ((<$>)) import Foreign.C@@ -66,6 +64,7 @@                        , packCStringLen                        , split) import Data.ByteString.Char8 (unpack)+import System.Xattr.CFuncs  -- | Mode for setting attributes. data XattrMode =@@ -98,9 +97,6 @@ -- the value be at most 64KB. type AttrValue = ByteString --- | Type for void.-type Void = CChar- -- -- Set extended attributes --@@ -129,9 +125,6 @@ #if HAVE_SETXATTR setxattr path name val mode = withCString path $ \cName ->   mkSetxattr "setxattr" cName c_setxattr name val mode--foreign import ccall unsafe "setxattr"-  c_setxattr  :: CString -> CString -> Ptr Void -> CSize -> CInt -> IO CInt #else setxattr = error "System.Xattr.setxattr: not supported" #endif@@ -144,9 +137,6 @@ #if HAVE_LSETXATTR lsetxattr path name val mode = withCString path $ \cName ->   mkSetxattr "lsetxattr" cName c_lsetxattr name val mode--foreign import ccall unsafe "lsetxattr"-  c_lsetxattr :: CString -> CString -> Ptr Void -> CSize -> CInt -> IO CInt #else lsetxattr = error "System.Xattr.lsetxattr: not supported" #endif@@ -156,9 +146,6 @@ #if HAVE_FSETXATTR fsetxattr handle name val mode = handleToFd handle >>= \fd ->   mkSetxattr "fsetxattr" (fromIntegral fd) c_fsetxattr name val mode--foreign import ccall unsafe "fsetxattr"-  c_fsetxattr :: CInt    -> CString -> Ptr Void -> CSize -> CInt -> IO CInt #else fsetxattr = error "System.Xattr.fsetxattr: not supported" #endif@@ -170,7 +157,7 @@ -- | High level wrapper for a @getxattr@ variant mkGetxattr :: String            -- ^ Function name            -> cStringOrCInt     -- ^ Filepath ('CString') or handle ('CInt')-           -> (cStringOrCInt -> CString -> Ptr Void -> CSize -> IO CSsize)+           -> (cStringOrCInt -> CString -> Ptr Void -> CSize -> IO CSize)            -> AttrName          -- ^ Attribute name            -> IO AttrValue mkGetxattr funcName pathOrHandle cFunc attrName = do@@ -187,9 +174,6 @@ #if HAVE_GETXATTR getxattr path name = withCString path $ \cName ->   mkGetxattr "getxattr" cName c_getxattr name--foreign import ccall unsafe "getxattr"-  c_getxattr  :: CString -> CString -> Ptr Void -> CSize -> IO CSsize #else getxattr = error "System.Xattr.getxattr: not supported" #endif@@ -201,9 +185,6 @@ #if HAVE_LGETXATTR lgetxattr path name = withCString path $ \cName ->   mkGetxattr "lgetxattr" cName c_lgetxattr name--foreign import ccall unsafe "lgetxattr"                           -  c_lgetxattr :: CString -> CString -> Ptr Void -> CSize -> IO CSsize #else lgetxattr = error "System.Xattr.lgetxattr: not supported" #endif@@ -213,9 +194,6 @@ #if HAVE_FGETXATTR fgetxattr handle name = handleToFd handle >>= \fd ->   mkGetxattr "fgetxattr" (fromIntegral fd) c_fgetxattr name--foreign import ccall unsafe "fgetxattr"                           -  c_fgetxattr :: CInt    -> CString -> Ptr Void -> CSize -> IO CSsize #else fgetxattr = error "System.Xattr.fgetxattr: not supported" #endif@@ -243,9 +221,6 @@ #if HAVE_LISTXATTR listxattr path = withCString path $ \cName ->   mkListxattr "listxattr" cName c_listxattr--foreign import ccall unsafe "listxattr"-  c_listxattr  :: CString -> CString -> CSize -> IO CSsize #else listxattr = error "System.Xattr.listxattr: not supported" #endif@@ -256,9 +231,6 @@ #if HAVE_LLISTXATTR llistxattr path = withCString path $ \cName ->   mkListxattr "llistxattr" cName c_llistxattr--foreign import ccall unsafe "llistxattr"-  c_llistxattr :: CString -> CString -> CSize -> IO CSsize #else llistxattr = error "System.Xattr.llistxattr: not supported" #endif@@ -268,11 +240,7 @@ #if HAVE_FLISTXATTR flistxattr handle = handleToFd handle >>= \fd ->   mkListxattr "flistxattr" (fromIntegral fd) c_flistxattr--foreign import ccall unsafe "flistxattr"-  c_flistxattr :: CInt    -> CString -> CSize -> IO CSsize #else flistxattr = error "System.Xattr.flistxattr: not supported" #endif -#endif
+ System/Xattr/CFuncs.hsc view
@@ -0,0 +1,71 @@++module System.Xattr.CFuncs where++import Foreign.C+import Foreign.Ptr+#ifdef __APPLE__+import Data.Bits ((.|.))+#endif+import System.Posix.Types++type Void = CChar++#ifdef __APPLE__++#include <sys/xattr.h>++foreign import ccall unsafe "setxattr" c_osx_setxattr :: CString -> CString -> Ptr Void -> CSize -> CInt -> CInt -> IO CInt+foreign import ccall unsafe "fsetxattr" c_osx_fsetxattr :: CInt -> CString -> Ptr Void -> CSize -> CInt -> CInt -> IO CInt++c_setxattr :: CString -> CString -> Ptr Void -> CSize -> CInt -> IO CInt+c_setxattr path name value size flags = c_osx_setxattr path name value size 0 flags++c_lsetxattr :: CString -> CString -> Ptr Void -> CSize -> CInt -> IO CInt+c_lsetxattr path name value size flags = c_osx_setxattr path name value size 0 (#{const XATTR_NOFOLLOW} .|. flags)++c_fsetxattr :: CInt -> CString -> Ptr Void -> CSize -> CInt -> IO CInt+c_fsetxattr fd name value size flags = c_osx_fsetxattr fd name value size 0 flags+++foreign import ccall unsafe "getxattr" c_osx_getxattr :: CString -> CString -> Ptr Void -> CSize -> CInt -> CInt -> IO CSize+foreign import ccall unsafe "fgetxattr" c_osx_fgetxattr :: CInt -> CString -> Ptr Void -> CSize -> CInt -> CInt -> IO CSize++c_getxattr :: CString -> CString -> Ptr Void -> CSize -> IO CSize+c_getxattr path name value size = c_osx_getxattr path name value size 0 0++c_lgetxattr :: CString -> CString -> Ptr Void -> CSize -> IO CSize+c_lgetxattr path name value size = c_osx_getxattr path name value size 0 #{const XATTR_NOFOLLOW}++c_fgetxattr :: CInt -> CString -> Ptr Void -> CSize -> IO CSize+c_fgetxattr fd name value size = c_osx_fgetxattr fd name value size 0 0+++foreign import ccall unsafe "listxattr" c_osx_listxattr :: CString -> CString -> CSize -> CInt -> IO CSsize+foreign import ccall unsafe "flistxattr" c_osx_flistxattr :: CInt -> CString -> CSize -> CInt -> IO CSsize++c_listxattr :: CString -> CString -> CSize -> IO CSsize+c_listxattr path list size = c_osx_listxattr path list size 0++c_llistxattr :: CString -> CString -> CSize -> IO CSsize+c_llistxattr path list size = c_osx_listxattr path list size #{const XATTR_NOFOLLOW}++c_flistxattr :: CInt -> CString -> CSize -> IO CSsize+c_flistxattr fd list size = c_osx_flistxattr fd list size 0++#else++-- We assume Linux.++foreign import ccall unsafe "setxattr" c_setxattr :: CString -> CString -> Ptr Void -> CSize -> CInt -> IO CInt+foreign import ccall unsafe "lsetxattr" c_lsetxattr :: CString -> CString -> Ptr Void -> CSize -> CInt -> IO CInt+foreign import ccall unsafe "fsetxattr" c_fsetxattr :: CInt -> CString -> Ptr Void -> CSize -> CInt -> IO CInt++foreign import ccall unsafe "getxattr" c_getxattr :: CString -> CString -> Ptr Void -> CSize -> IO CSize+foreign import ccall unsafe "lgetxattr" c_lgetxattr :: CString -> CString -> Ptr Void -> CSize -> IO CSize+foreign import ccall unsafe "fgetxattr" c_fgetxattr :: CInt -> CString -> Ptr Void -> CSize -> IO CSize++foreign import ccall unsafe "listxattr" c_listxattr :: CString -> CString -> CSize -> IO CSsize+foreign import ccall unsafe "llistxattr" c_llistxattr :: CString -> CString -> CSize -> IO CSsize+foreign import ccall unsafe "flistxattr" c_flistxattr :: CInt -> CString -> CSize -> IO CSsize++#endif
xattr.cabal view
@@ -1,12 +1,12 @@ Author:        Evan Klitzke, Deian Stefan Maintainer:    Deian Stefan <deian@cs.stanford.edu> Name:          xattr-Version:       0.6.0+Version:       0.6.1 Cabal-Version: >= 1.8 License:       BSD3 License-File:  LICENSE Category:      System-Copyright:     (c) 2009 by Evan Klitzke, (c) 2012 by Deian Stefan+Copyright:     (c) 2009 by Evan Klitzke, (c) 2012 by Deian Stefan, (c) 2012 by Amit Levy Synopsis:      Haskell extended file attributes interface Description:   Relatively low-level interface to work with extended attributes@@ -27,12 +27,15 @@ Library   Exposed-Modules:     System.Xattr+  Other-Modules:+    System.Xattr.CFuncs   Build-Depends:     base >= 4.0 && < 5,     bytestring,     unix   Extensions: CPP, ForeignFunctionInterface-  Extra-Libraries: attr+  if !os(darwin)+    Extra-Libraries: attr   Include-Dirs: include   Includes: HsXattrConfig.h   Install-Includes: HsXattrConfig.h