v / examples / process / monitor_for_file_changes_with_inotifywait.v
15 lines · 14 sloc · 387 bytes · 10dff915005abd046294b6db847313fbd22a3ede
Raw
1import os
2
3os.find_abs_path_of_executable('inotifywait') or {
4 eprintln('This program uses the inotifywait executable, which is missing.')
5 exit(1)
6}
7mut cmd := os.start_new_command('inotifywait -q -r -m -e move,modify,create,delete .')!
8defer { cmd.close() or {} }
9for !cmd.eof {
10 line := cmd.read_line()
11 if line == '' && cmd.eof {
12 continue
13 }
14 eprintln('> notification: ${line}')
15}
16