From 083ab36d08569dd64a7ed94cdfd49753964c7bdd Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 16 Feb 2014 17:39:54 -0400 Subject: 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. --- Utility/Path.hs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'Utility') 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 -- cgit v1.2.3