Browse Source

Add isSpecialDirectoryEntry

travis
Julian Ospald 4 years ago
parent
commit
22ddeeadcc
No known key found for this signature in database GPG Key ID: 511B62C09D50CD28
1 changed files with 16 additions and 0 deletions
  1. +16
    -0
      hpath-filepath/src/System/Posix/FilePath.hs

+ 16
- 0
hpath-filepath/src/System/Posix/FilePath.hs View File

@@ -73,6 +73,7 @@ module System.Posix.FilePath (
, isAbsolute
, isValid
, makeValid
, isSpecialDirectoryEntry
, isFileName
, hasParentDir
, hiddenFile
@@ -724,6 +725,21 @@ makeValid 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
-- "." and "..".
--


Loading…
Cancel
Save