xattr 0.5 → 0.5.1
raw patch · 2 files changed
+18/−18 lines, 2 files
Files
- src/System/Xattr.hsc +13/−15
- xattr.cabal +5/−3
src/System/Xattr.hsc view
@@ -80,7 +80,7 @@ x' <- iox x cName <- newCString attrName val <- BS.useAsCStringLen attrData $ \(binaryData, dataLen) ->- cFunc x' cName binaryData (fromIntegral dataLen) (fromIntegral $ fromEnum mode)+ cFunc x' cName binaryData (fromIntegral dataLen) (fromIntegral $ fromEnum mode) if val /= 0 then throwErrno funcName else return ()@@ -106,10 +106,10 @@ x' <- iox x cName <- newCString attrName allocaBytes allocBufSize $ \mem -> do- buflen <- cFunc x' cName mem allocCSize- if buflen == -1- then throwErrno funcName- else BS.packCStringLen (mem, fromIntegral buflen)+ buflen <- cFunc x' cName mem allocCSize+ if buflen == -1+ then throwErrno funcName+ else BS.packCStringLen (mem, fromIntegral buflen) -- |Get an attribute on a regular file, by path getxattr :: String -> String -> IO BS.ByteString@@ -127,20 +127,18 @@ splitNull :: String -> [String] splitNull [] = [] splitNull s = case suf of- "" -> [pre]- _ -> pre : (splitNull $ tail suf)- where- (pre, suf) = break (\c -> ord c == 0) s+ "" -> [pre]+ _ -> pre : (splitNull $ tail suf)+ where (pre, suf) = break (\c -> ord c == 0) s mkListxattr :: String -> a -> (a -> IO b) -> (b -> CString -> CSize -> IO CSsize) -> IO [String] mkListxattr funcName x iox cFunc = do x' <- iox x- allocaBytes allocBufSize $ \mem -> do- buflen <- cFunc x' mem allocCSize- if buflen == -1- then throwErrno funcName- else do s <- peekCStringLen (mem, fromIntegral buflen)- return $ splitNull s+ allocaBytes allocBufSize $ \mem -> do buflen <- cFunc x' mem allocCSize+ if buflen == -1+ then throwErrno funcName+ else do s <- peekCStringLen (mem, fromIntegral buflen)+ return $ splitNull s -- |Get a list of all of the attributes set on a path listxattr :: String -> IO [String]
xattr.cabal view
@@ -1,15 +1,17 @@ Author: Evan Klitzke Maintainer: Evan Klitzke <evan@eklitzke.org> Name: xattr-Version: 0.5+Version: 0.5.1 Cabal-Version: >= 1.2 License: BSD3 License-File: LICENSE Category: System Copyright: (c) 2009 by Evan Klitzke-Synopsis: Haskell binding to libattr+Synopsis: Haskell bindings to libattr Description:- Stuff+ Relatively low-level interface to work with extended attributes on Unix+ systems. This is a fairly straightforward port of the API exposed by SGI's+ libattr. Build-Type: Configure Extra-Source-Files: