Changeset 50
- Timestamp:
- 04/15/09 02:58:13 (3 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
-
directory_watcher.erl (modified) (1 diff)
-
directory_watcher_test.erl (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/directory_watcher.erl
r49 r50 5 5 -module (directory_watcher). 6 6 -export ([init/3]). 7 -export ([recursive/1]). 7 8 -include_lib ("kernel/include/file.hrl"). 9 10 recursive (Fun) -> 11 fun (directory, P, found, S) -> 12 spawn_link (directory_watcher, init, [P, Fun, S]); 13 (T, E, P, S) -> 14 Fun (T, E, P, S) 15 end. 8 16 9 17 init (Directory, Action, Action_state) -> -
trunk/src/directory_watcher_test.erl
r49 r50 9 9 -export ([tests_with_several/0]). 10 10 -export ([bad_symlinks_are_ignored/0]). 11 -export ([recursive/0]). 11 12 12 13 tests_from_empty () -> … … 36 37 ok = fixtures: use_tree ([], fun bad_symlinks_are_ignored/2). 37 38 39 recursive () -> 40 Tree = [{file, "foo.txt", "Hello"}, 41 {file, "bar.txt", "G'day"}, 42 {file, "toto.erl", "-module(toto)."}, 43 {directory, "subdir", [{file, "subfile.ext", "toto"}]}], 44 ok = fixtures: use_tree (Tree, fun recursive/2). 45 46 recursive (Dir, _) -> 47 Notify = directory_watcher: recursive (notify ()), 48 Watcher = spawn_link (directory_watcher, init, [Dir, Notify, ignore]), 49 Filename = filename: join ([Dir, "subdir", "subfile.ext"]), 50 Expected = {watcher, {file, ".ext"}, Filename, found, ignore}, 51 ok = receive_until_found (Expected). 52 38 53 bad_symlinks_are_ignored (Dir, _) -> 39 54 Watcher = spawn_link (directory_watcher, init, [Dir, notify (), ignore]), … … 53 68 Watcher = spawn_link (directory_watcher, init, [Dir, notify (), State]), 54 69 timeout = receive_one (), 55 70 56 71 Filename = filename: join (Dir, "myfile.txt"), 57 72 ok = file: write_file (Filename, list_to_binary ("Hello")), … … 120 135 receive_one () -> 121 136 receive M -> M after 500 -> timeout end. 137 138 receive_until_found (Message) -> 139 receive Message -> ok after 500 -> timeout end.
Note: See TracChangeset
for help on using the changeset viewer.
