| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- // Copyright (C) 2009-2021, Panagiotis Christopoulos Charitos and contributors.
- // All rights reserved.
- // Code licensed under the BSD License.
- // http://www.anki3d.org/LICENSE
- #pragma once
- #include <AnKi/Util/String.h>
- namespace anki
- {
- /// @addtogroup util_file
- /// @{
- /// A wrapper on top of inotify. Check for filesystem updates.
- class INotify
- {
- public:
- INotify() = default;
- // Non-copyable
- INotify(const INotify&) = delete;
- ~INotify()
- {
- destroyInternal();
- m_path.destroy(m_alloc);
- }
- // Non-copyable
- INotify& operator=(const INotify&) = delete;
- /// @param path Path to file or directory.
- ANKI_USE_RESULT Error init(GenericMemoryPoolAllocator<U8> alloc, CString path)
- {
- m_alloc = alloc;
- m_path.create(alloc, path);
- return initInternal();
- }
- /// Check if the file was modified in any way.
- ANKI_USE_RESULT Error pollEvents(Bool& modified);
- private:
- GenericMemoryPoolAllocator<U8> m_alloc;
- String m_path;
- #if ANKI_POSIX
- int m_fd = -1;
- int m_watch = -1;
- #endif
- void destroyInternal();
- ANKI_USE_RESULT Error initInternal();
- };
- /// @}
- } // end namespace anki
|