on master help sign in
Update documentation remove redundant comments
commit4ce545e30c8ab97996b4dd7c5f1ea8dadfd72ed4 authorHarendra Kumar <harendra@composewell.com> dateTue 30 Nov 2021, 16:30 (5 years ago) parent842d0ca
5 files changed+17−22
src/Streamly/Internal/FileSystem/Event.hs+6−4 src/Streamly/Internal/FileSystem/Event/Linux.hs+2−2 src/Streamly/Internal/FileSystem/Event/Windows.hs+9−10 test/Streamly/Test/FileSystem/Event/Linux.hs−2 test/Streamly/Test/FileSystem/Event/Windows.hs−4
src/Streamly/Internal/FileSystem/Event.hs+6−4
@@ -94,14 +94,16 @@ import qualified Streamly.Internal.FileSystem.Event.Windows as Event
9494-- setFollowSymLinks on Linux.
9595
9696-- XXX Verify all the cases mentioned below using test cases.
97+-- XXX Make it fail if the watch root is a file. It works on macOS and Linux
98+-- but does not work on Windows.
9799
98−-- | Start monitoring a list of file system paths for file system events. The
99−-- paths could be files or directories. Monitoring starts from the current
100−-- time onwards. The paths are specified as UTF-8 encoded 'Array' of 'Word8'.
100+-- | Start monitoring a list of directories or symbolic links to directories
101+-- for file system events. Monitoring starts from the current time onwards.
102+-- The paths are specified as UTF-8 encoded 'Array' of 'Word8'.
101103--
102104-- If a watch root is a symbolic link then the target of the link is watched.
103105-- Fails if the watched path does not exist. If the user does not have
104−-- permissions (specific permissions?) on the watch root then no events are
106+-- permissions (read and execute?) on the watch root then no events are
105107-- generated. No events are generated if the watch root itself is renamed or
106108-- deleted.
107109--
src/Streamly/Internal/FileSystem/Event/Linux.hs+2−2
@@ -175,6 +175,7 @@ import GHC.IO.Handle.FD (mkHandleFromFD)
175175import Streamly.Prelude (SerialT)
176176import Streamly.Internal.Data.Parser (Parser)
177177import Streamly.Internal.Data.Array.Foreign.Type (Array(..), byteLength)
178+import System.Directory (doesDirectoryExist)
178179import System.IO (Handle, hClose, IOMode(ReadMode))
179180#if !MIN_VERSION_base(4,10,0)
180181import Control.Concurrent.MVar (readMVar)
@@ -193,7 +194,6 @@ import qualified Streamly.Internal.Data.Fold as FL
193194import qualified Streamly.Internal.Data.Parser as PR
194195import qualified Streamly.Internal.Data.Stream.IsStream as S
195196import qualified Streamly.Internal.FileSystem.Dir as Dir
196−import qualified System.Directory as Dir
197197import qualified Streamly.Internal.FileSystem.Handle as FH
198198import qualified Streamly.Internal.Unicode.Stream as U
199199
@@ -746,7 +746,7 @@ addToWatch cfg@Config{..} watch0@(Watch handle wdMap) root0 path0 = do
746746 --
747747 -- XXX toDirs currently uses paths as String, we need to convert it
748748 -- to "/" separated by byte arrays.
749− pathIsDir <- Dir.doesDirectoryExist $ utf8ToString absPath
749+ pathIsDir <- doesDirectoryExist $ utf8ToString absPath
750750 when (watchRec && pathIsDir) $ do
751751 S.mapM_ (\p -> addToWatch cfg watch0 root (appendPaths path p))
752752 $ S.mapM toUtf8
src/Streamly/Internal/FileSystem/Event/Windows.hs+9−10
@@ -447,16 +447,15 @@ closePathHandleStream = S.mapM_ (\(h, _, _) -> closeHandle h)
447447-- based on the configured code page?
448448-- https://docs.microsoft.com/en-us/windows/uwp/design/globalizing/use-utf8-code-page
449449--
450−-- | Start monitoring a list of file system paths for file system events with
451−-- the supplied configuration modifier operation over the' defaultConfig'. The
452−-- paths could be files or directories.
453−--
454−-- When recursive mode is True and the path is a directory, the whole directory
455−-- tree under it is watched recursively. When recursive mode is False and the
456−-- path is a directory, only the files and directories directly under the
457−-- watched directory are monitored, contents of subdirectories are not
458−-- monitored. Monitoring starts from the current time onwards. The paths are
459−-- specified as UTF-8 encoded 'Array' of 'Word8'.
450+-- | Start monitoring a list of directory paths for file system events with the
451+-- supplied configuration modifier operation over the' defaultConfig'. The
452+-- paths could be directories or symbolic links to directories.
453+--
454+-- When recursive mode is True, the whole directory tree under the path is
455+-- watched recursively. When recursive mode is False, only the files and
456+-- directories directly under the watched directory are monitored, contents of
457+-- subdirectories are not monitored. Monitoring starts from the current time
458+-- onwards. The paths are specified as UTF-8 encoded 'Array' of 'Word8'.
460459--
461460-- /Symbolic Links:/ If the pathname to be watched is a symbolic link then
462461-- watch the target of the symbolic link instead of the symbolic link itself.
test/Streamly/Test/FileSystem/Event/Linux.hs−2
@@ -147,6 +147,4 @@ main = do
147147
148148 runRec DirType recRegTests
149149 runRec SymLinkOrigPath recSymTests
150− -- XXX This fails with exceptions, ideally it should work the same as in
151− -- non-recursive mode
152150 runRec FileType fileRootTests
test/Streamly/Test/FileSystem/Event/Windows.hs−4
@@ -35,10 +35,6 @@ main = do
3535
3636 run DirType regularRootTests
3737 run SymLinkOrigPath commonTests
38− -- TODO create/modify/delete/move with root path as a regular file, copy
39− -- from macOS tests
40− -- run FileType fileRootTests
41− -- Windows watch events only supports dir path as root.
4238
4339 let recTests =
4440 [ dirCreateWithParent "subdir\\dir"