mirror of https://github.com/voidlizard/hbs2
wip
This commit is contained in:
parent
71eb40c3e2
commit
7e5fa70503
|
@ -35,33 +35,27 @@ glob pat ignore dir action = do
|
||||||
|
|
||||||
where
|
where
|
||||||
|
|
||||||
ppat = zip (repeat True) pat
|
matches p f = or [ i ?== f | i <- p ]
|
||||||
spat = zip (repeat True) ignore
|
skip p = or [ i ?== p | i <- ignore ]
|
||||||
|
|
||||||
go f = do
|
go f = do
|
||||||
isF <- liftIO $ doesFileExist f
|
|
||||||
|
|
||||||
when isF do
|
|
||||||
liftIO $ print f
|
|
||||||
|
|
||||||
isD <- liftIO $ doesDirectoryExist f
|
isD <- liftIO $ doesDirectoryExist f
|
||||||
|
|
||||||
when isD do
|
if not isD then do
|
||||||
co <- liftIO (try @_ @IOError $ listDirectory f)
|
isF <- liftIO $ doesFileExist f
|
||||||
|
when (isF && matches pat f) do
|
||||||
|
liftIO $ print f
|
||||||
|
-- do shit with file
|
||||||
|
else do
|
||||||
|
co' <- liftIO (try @_ @IOError $ listDirectory f)
|
||||||
<&> fromRight mempty
|
<&> fromRight mempty
|
||||||
|
|
||||||
let fns = matchMany ppat [ (f </> x, x) | x <- co ]
|
let co = [ normalise (f </> x) | x <- co' ]
|
||||||
let stop = matchMany spat [ (f </> x, x) | x <- co ]
|
& filter (not . skip)
|
||||||
let ss = HS.fromList $ (fmap (view _2)) stop
|
|
||||||
|
|
||||||
-- matchMany :: [(a, FilePattern)] -> [(b, FilePath)] -> [(a, b, [String])]
|
for_ co $ \p -> do
|
||||||
|
go p
|
||||||
liftIO $ print spat
|
|
||||||
liftIO $ print stop
|
|
||||||
-- for_ co $ \p -> do
|
|
||||||
-- liftIO $ print p
|
|
||||||
-- unless (HS.member p ss) do
|
|
||||||
-- go (f </> p)
|
|
||||||
|
|
||||||
-- q <- newTQueueIO
|
-- q <- newTQueueIO
|
||||||
|
|
||||||
|
@ -98,8 +92,6 @@ glob pat ignore dir action = do
|
||||||
-- Just e -> void (action e) >> next
|
-- Just e -> void (action e) >> next
|
||||||
|
|
||||||
-- where
|
-- where
|
||||||
-- matches p f = or [ i ?== f | i <- p ]
|
|
||||||
-- skip p = or [ i ?== p | i <- ignore ]
|
|
||||||
|
|
||||||
entries :: forall c m . ( IsContext c
|
entries :: forall c m . ( IsContext c
|
||||||
, Exception (BadFormException c)
|
, Exception (BadFormException c)
|
||||||
|
|
Loading…
Reference in New Issue