File monitor

From Hegemon Wiki
Jump to navigation Jump to search

Simplified File Watching Interface

Use cases

  • Watch for source code changes and rerun unit tests
    • Shell command, should be cancelable
    • Needs to be filterable (ie .go, .cpp, .hpp)
  • Watch for kernel/nvidia driver changes and copy to EFI

Requirements

  • Must support cancelable shell command.
  • Functions/GoRoutines can't be canceled.
  • Different editors have differnt save strategies.
  • Most changes result in multiple events (touch for example CREAT+CHMOD).
  • Should support a delay (could stop spamming changes).
  • Delay should be reset each time a new action occurs.

Modification time? Might not help if you copy an old file onto a new one...

fsnotify event examples

touch a

2016/04/09 11:59:47 Event: "/home/hegemon/programming/ansible/a": CREATE
2016/04/09 11:59:47 Event: "/home/hegemon/programming/ansible/a": CHMOD

vim :wq

2016/04/09 12:00:19 Event: "/home/hegemon/programming/ansible/4913": CREATE
2016/04/09 12:00:19 Event: "/home/hegemon/programming/ansible/a": RENAME
2016/04/09 12:00:19 Event: "/home/hegemon/programming/ansible/a": CREATE
2016/04/09 12:00:19 Event: "/home/hegemon/programming/ansible/a": WRITE
2016/04/09 12:00:19 Event: "/home/hegemon/programming/ansible/a": CHMOD

atom (save existing file):

2016/04/09 13:32:59 Event: "/home/hegemon/programming/ansible/a": WRITE
2016/04/09 13:32:59 Event: "/home/hegemon/programming/ansible/a": WRITE


mv b a

2016/04/09 13:31:24 Event: "/home/hegemon/programming/ansible/b": RENAME
2016/04/09 13:31:24 Event: "/home/hegemon/programming/ansible/a": CREATE