INotify.h 914 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma once
  6. #include <AnKi/Util/String.h>
  7. namespace anki {
  8. /// @addtogroup util_file
  9. /// @{
  10. /// A wrapper on top of inotify. Check for filesystem updates.
  11. class INotify
  12. {
  13. public:
  14. INotify() = default;
  15. // Non-copyable
  16. INotify(const INotify&) = delete;
  17. ~INotify()
  18. {
  19. destroyInternal();
  20. }
  21. // Non-copyable
  22. INotify& operator=(const INotify&) = delete;
  23. /// @param path Path to file or directory.
  24. Error init(CString path)
  25. {
  26. m_path = path;
  27. return initInternal();
  28. }
  29. /// Check if the file was modified in any way.
  30. Error pollEvents(Bool& modified);
  31. private:
  32. String m_path;
  33. #if ANKI_POSIX
  34. int m_fd = -1;
  35. int m_watch = -1;
  36. #endif
  37. void destroyInternal();
  38. Error initInternal();
  39. };
  40. /// @}
  41. } // end namespace anki