Add isSpecialDirectoryEntry
This commit is contained in:
parent
1f4e289903
commit
22ddeeadcc
@ -73,6 +73,7 @@ module System.Posix.FilePath (
|
|||||||
, isAbsolute
|
, isAbsolute
|
||||||
, isValid
|
, isValid
|
||||||
, makeValid
|
, makeValid
|
||||||
|
, isSpecialDirectoryEntry
|
||||||
, isFileName
|
, isFileName
|
||||||
, hasParentDir
|
, hasParentDir
|
||||||
, hiddenFile
|
, hiddenFile
|
||||||
@ -724,6 +725,21 @@ makeValid path
|
|||||||
| otherwise = BS.map (\x -> if x == _nul then _underscore else x) path
|
| otherwise = BS.map (\x -> if x == _nul then _underscore else x) path
|
||||||
|
|
||||||
|
|
||||||
|
-- | Is a FilePath valid, i.e. could you create a file like it?
|
||||||
|
--
|
||||||
|
-- >>> isSpecialDirectoryEntry "."
|
||||||
|
-- True
|
||||||
|
-- >>> isSpecialDirectoryEntry ".."
|
||||||
|
-- True
|
||||||
|
-- >>> isSpecialDirectoryEntry "/random_ path:*"
|
||||||
|
-- False
|
||||||
|
isSpecialDirectoryEntry :: RawFilePath -> Bool
|
||||||
|
isSpecialDirectoryEntry filepath
|
||||||
|
| BS.pack [_period, _period] == filepath = True
|
||||||
|
| BS.pack [_period] == filepath = True
|
||||||
|
| otherwise = False
|
||||||
|
|
||||||
|
|
||||||
-- | Is the given path a valid filename? This includes
|
-- | Is the given path a valid filename? This includes
|
||||||
-- "." and "..".
|
-- "." and "..".
|
||||||
--
|
--
|
||||||
|
Loading…
Reference in New Issue
Block a user