summaryrefslogtreecommitdiff
path: root/Utility/Directory.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-06-18 21:29:30 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-06-18 21:29:30 -0400
commit2bfcc0b09c5dd37c5e0ab65cb089232bfcc31934 (patch)
treec76335917d4753dbe07854baa6ffde905e10c7c8 /Utility/Directory.hs
parentae7d07ddcb5768cf477410e019d42601d8c2b744 (diff)
kqueue: add directory content tracking, and change determination
This *may* now return Add or Delete Changes as appropriate. All I know for sure is that it compiles. I had hoped to avoid maintaining my own state about the content of the directory tree, and rely on git to check what was changed. But I can't; I need to know about new and deleted subdirectories to add them to the watch list, and git doesn't deal with (empty) directories. So, wrote all the code to scan directories, remember their past contents, compare with current contents, generate appropriate Change events, and update bookkeeping info appropriately.
Diffstat (limited to 'Utility/Directory.hs')
-rw-r--r--Utility/Directory.hs27
1 files changed, 0 insertions, 27 deletions
diff --git a/Utility/Directory.hs b/Utility/Directory.hs
index b8ed63a36..2f2960a9d 100644
--- a/Utility/Directory.hs
+++ b/Utility/Directory.hs
@@ -56,33 +56,6 @@ dirContentsRecursive' topdir (dir:dirs) = unsafeInterleaveIO $ do
, collect (dirEntry:files) dirs' entries
)
-{- Gets the subdirectories in a directory, and their subdirectories,
- - recursively, and lazily. Prunes sections of the tree matching a
- - condition. -}
-dirTree :: FilePath -> (FilePath -> Bool) -> IO [FilePath]
-dirTree topdir prune
- | prune topdir = return []
- | otherwise = (:) topdir <$> dirTree' topdir prune [""]
-
-dirTree' :: FilePath -> (FilePath -> Bool) -> [FilePath] -> IO [FilePath]
-dirTree' _ _ [] = return []
-dirTree' topdir prune (dir:dirs)
- | prune dir = dirTree' topdir prune dirs
- | otherwise = unsafeInterleaveIO $ do
- subdirs <- collect [] =<< dirContents (topdir </> dir)
- subdirs' <- dirTree' topdir prune (subdirs ++ dirs)
- return $ subdirs ++ subdirs'
- where
- collect dirs' [] = return dirs'
- collect dirs' (entry:entries)
- | dirCruft entry || prune entry = collect dirs' entries
- | otherwise = do
- let dirEntry = dir </> entry
- ifM (doesDirectoryExist $ topdir </> dirEntry)
- ( collect (dirEntry:dirs') entries
- , collect dirs' entries
- )
-
{- Moves one filename to another.
- First tries a rename, but falls back to moving across devices if needed. -}
moveFile :: FilePath -> FilePath -> IO ()