diff options
author | Joey Hess <joey@kitenet.net> | 2014-02-16 17:39:54 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-02-16 17:39:54 -0400 |
commit | 083ab36d08569dd64a7ed94cdfd49753964c7bdd (patch) | |
tree | 27403db8f2304ada025dd8911d03df5801603861 /Utility | |
parent | 16af107d2d573046ab09af964257cf3573889974 (diff) |
filter branches (incomplete)
Promosing work toward metadata driven filter branches. A few methods
to construct them are stubbed out; all the data types and pure code
seems good.
This commit was sponsored by Walter Somerville.
Diffstat (limited to 'Utility')
-rw-r--r-- | Utility/Path.hs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Utility/Path.hs b/Utility/Path.hs index 2bcd110d8..e22d0c3f7 100644 --- a/Utility/Path.hs +++ b/Utility/Path.hs @@ -277,3 +277,18 @@ sanitizeFilePath = map sanitize | c == '.' = c | isSpace c || isPunctuation c || isSymbol c || isControl c || c == '/' = '_' | otherwise = c + +{- Similar to splitExtensions, but knows that some things in FilePaths + - after a dot are too long to be extensions. -} +splitShortExtensions :: FilePath -> (FilePath, [String]) +splitShortExtensions = splitShortExtensions' 5 -- enough for ".jpeg" +splitShortExtensions' :: Int -> FilePath -> (FilePath, [String]) +splitShortExtensions' maxextension = go [] + where + go c f + | len > 0 && len <= maxextension && not (null base) = + go (ext:c) base + | otherwise = (f, c) + where + (base, ext) = splitExtension f + len = length ext |