on master help sign in
Update documentation remove redundant comments
4ce545eHarendra Kumar
src/Streamly/Internal/FileSystem/Event.hs+6−4
@@ -94,14 +94,16 @@ import qualified Streamly.Internal.FileSystem.Event.Windows as Event
94-- setFollowSymLinks on Linux.
94-- setFollowSymLinks on Linux.
95
95
96-- XXX Verify all the cases mentioned below using test cases.
96-- 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.
97
99
98−-- | Start monitoring a list of file system paths for file system events. The
100+-- | Start monitoring a list of directories or symbolic links to directories
99−-- paths could be files or directories. Monitoring starts from the current
101+-- for file system events. Monitoring starts from the current time onwards.
100−-- time onwards. The paths are specified as UTF-8 encoded 'Array' of 'Word8'.
102+-- The paths are specified as UTF-8 encoded 'Array' of 'Word8'.
101--
103--
102-- If a watch root is a symbolic link then the target of the link is watched.
104-- If a watch root is a symbolic link then the target of the link is watched.
103-- Fails if the watched path does not exist. If the user does not have
105-- 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
105-- generated. No events are generated if the watch root itself is renamed or
107-- generated. No events are generated if the watch root itself is renamed or
106-- deleted.
108-- deleted.
107--
109--
src/Streamly/Internal/FileSystem/Event/Linux.hs+2−2
@@ -175,6 +175,7 @@ import GHC.IO.Handle.FD (mkHandleFromFD)
175import Streamly.Prelude (SerialT)
175import Streamly.Prelude (SerialT)
176import Streamly.Internal.Data.Parser (Parser)
176import Streamly.Internal.Data.Parser (Parser)
177import Streamly.Internal.Data.Array.Foreign.Type (Array(..), byteLength)
177import Streamly.Internal.Data.Array.Foreign.Type (Array(..), byteLength)
178+import System.Directory (doesDirectoryExist)
178import System.IO (Handle, hClose, IOMode(ReadMode))
179import System.IO (Handle, hClose, IOMode(ReadMode))
179#if !MIN_VERSION_base(4,10,0)
180#if !MIN_VERSION_base(4,10,0)
180import Control.Concurrent.MVar (readMVar)
181import Control.Concurrent.MVar (readMVar)
@@ -193,7 +194,6 @@ import qualified Streamly.Internal.Data.Fold as FL
193import qualified Streamly.Internal.Data.Parser as PR
194import qualified Streamly.Internal.Data.Parser as PR
194import qualified Streamly.Internal.Data.Stream.IsStream as S
195import qualified Streamly.Internal.Data.Stream.IsStream as S
195import qualified Streamly.Internal.FileSystem.Dir as Dir
196import qualified Streamly.Internal.FileSystem.Dir as Dir
196−import qualified System.Directory as Dir
197import qualified Streamly.Internal.FileSystem.Handle as FH
197import qualified Streamly.Internal.FileSystem.Handle as FH
198import qualified Streamly.Internal.Unicode.Stream as U
198import qualified Streamly.Internal.Unicode.Stream as U
199
199
@@ -746,7 +746,7 @@ addToWatch cfg@Config{..} watch0@(Watch handle wdMap) root0 path0 = do
746 --
746 --
747 -- XXX toDirs currently uses paths as String, we need to convert it
747 -- XXX toDirs currently uses paths as String, we need to convert it
748 -- to "/" separated by byte arrays.
748 -- to "/" separated by byte arrays.
749− pathIsDir <- Dir.doesDirectoryExist $ utf8ToString absPath
749+ pathIsDir <- doesDirectoryExist $ utf8ToString absPath
750 when (watchRec && pathIsDir) $ do
750 when (watchRec && pathIsDir) $ do
751 S.mapM_ (\p -> addToWatch cfg watch0 root (appendPaths path p))
751 S.mapM_ (\p -> addToWatch cfg watch0 root (appendPaths path p))
752 $ S.mapM toUtf8
752 $ S.mapM toUtf8
src/Streamly/Internal/FileSystem/Event/Windows.hs+9−10
@@ -447,16 +447,15 @@ closePathHandleStream = S.mapM_ (\(h, _, _) -> closeHandle h)
447-- based on the configured code page?
447-- based on the configured code page?
448-- https://docs.microsoft.com/en-us/windows/uwp/design/globalizing/use-utf8-code-page
448-- https://docs.microsoft.com/en-us/windows/uwp/design/globalizing/use-utf8-code-page
449--
449--
450−-- | Start monitoring a list of file system paths for file system events with
450+-- | Start monitoring a list of directory paths for file system events with the
451−-- the supplied configuration modifier operation over the' defaultConfig'. The
451+-- supplied configuration modifier operation over the' defaultConfig'. The
452−-- paths could be files or directories.
452+-- paths could be directories or symbolic links to directories.
453−--
453+--
454−-- When recursive mode is True and the path is a directory, the whole directory
454+-- When recursive mode is True, the whole directory tree under the path is
455−-- tree under it is watched recursively. When recursive mode is False and the
455+-- watched recursively. When recursive mode is False, only the files and
456−-- path is a directory, only the files and directories directly under the
457−-- watched directory are monitored, contents of subdirectories are not
456+-- directories directly under the watched directory are monitored, contents of
458−-- monitored. Monitoring starts from the current time onwards. The paths are
457+-- subdirectories are not monitored. Monitoring starts from the current time
459−-- specified as UTF-8 encoded 'Array' of 'Word8'.
458+-- onwards. The paths are specified as UTF-8 encoded 'Array' of 'Word8'.
460--
459--
461-- /Symbolic Links:/ If the pathname to be watched is a symbolic link then
460-- /Symbolic Links:/ If the pathname to be watched is a symbolic link then
462-- watch the target of the symbolic link instead of the symbolic link itself.
461-- 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
147
147
148 runRec DirType recRegTests
148 runRec DirType recRegTests
149 runRec SymLinkOrigPath recSymTests
149 runRec SymLinkOrigPath recSymTests
150− -- XXX This fails with exceptions, ideally it should work the same as in
151− -- non-recursive mode
152 runRec FileType fileRootTests
150 runRec FileType fileRootTests
test/Streamly/Test/FileSystem/Event/Windows.hs−4
@@ -35,10 +35,6 @@ main = do
35
35
36 run DirType regularRootTests
36 run DirType regularRootTests
37 run SymLinkOrigPath commonTests
37 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.
42
38
43 let recTests =
39 let recTests =
44 [ dirCreateWithParent "subdir\\dir"
40 [ dirCreateWithParent "subdir\\dir"