Add 'hiddenFile' to System.Posix.FilePath
This commit is contained in:
parent
3da8533b48
commit
3bbde22377
25
src/HPath.hs
25
src/HPath.hs
@ -48,8 +48,6 @@ module HPath
|
||||
-- * ByteString operations
|
||||
,fpToString
|
||||
,userStringToFP
|
||||
-- * ByteString Query functions
|
||||
,hiddenFile
|
||||
-- * Queries
|
||||
,hasParentDir
|
||||
,isFileName
|
||||
@ -359,29 +357,6 @@ withFnPath :: Path Fn -> (ByteString -> IO a) -> IO a
|
||||
withFnPath (MkPath p) action = action p
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- ByteString Query functions
|
||||
|
||||
|
||||
-- | Whether the file is a hidden file.
|
||||
--
|
||||
-- >>> hiddenFile (MkPath ".foo")
|
||||
-- True
|
||||
-- >>> hiddenFile (MkPath "..foo.bar")
|
||||
-- True
|
||||
-- >>> hiddenFile (MkPath "...")
|
||||
-- True
|
||||
-- >>> hiddenFile (MkPath "dod")
|
||||
-- False
|
||||
-- >>> hiddenFile (MkPath "dod.bar")
|
||||
-- False
|
||||
hiddenFile :: Path Fn -> Bool
|
||||
hiddenFile (MkPath fp)
|
||||
| fp == BS.pack [_period, _period] = False
|
||||
| fp == BS.pack [_period] = False
|
||||
| otherwise = BS.pack [extSeparator]
|
||||
`BS.isPrefixOf` fp
|
||||
|
||||
------------------------
|
||||
-- ByteString helpers
|
||||
|
||||
|
@ -61,6 +61,7 @@ module System.Posix.FilePath (
|
||||
, isFileName
|
||||
, hasParentDir
|
||||
, equalFilePath
|
||||
, hiddenFile
|
||||
|
||||
, fpToString
|
||||
, userStringToFP
|
||||
@ -587,6 +588,26 @@ equalFilePath p1 p2 = f p1 == f p2
|
||||
where
|
||||
f x = dropTrailingPathSeparator $ normalise x
|
||||
|
||||
|
||||
-- | Whether the file is a hidden file.
|
||||
--
|
||||
-- >>> hiddenFile ".foo"
|
||||
-- True
|
||||
-- >>> hiddenFile "..foo.bar"
|
||||
-- True
|
||||
-- >>> hiddenFile "..."
|
||||
-- True
|
||||
-- >>> hiddenFile "dod"
|
||||
-- False
|
||||
-- >>> hiddenFile "dod.bar"
|
||||
-- False
|
||||
hiddenFile :: RawFilePath -> Bool
|
||||
hiddenFile fp
|
||||
| fp == BS.pack [_period, _period] = False
|
||||
| fp == BS.pack [_period] = False
|
||||
| otherwise = BS.pack [extSeparator]
|
||||
`BS.isPrefixOf` fp
|
||||
|
||||
------------------------
|
||||
-- conversion
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user