Rev 23 | Rev 33 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 23 | Rev 29 | ||
---|---|---|---|
Line 49... | Line 49... | ||
49 | /**
|
49 | /**
|
50 | * It prepends the message by the function name.
|
50 | * It prepends the message by the function name.
|
51 | */
|
51 | */
|
52 | #define IN_EXC_MSG(msg) (std::string(__PRETTY_FUNCTION__) + ": " + msg)
|
52 | #define IN_EXC_MSG(msg) (std::string(__PRETTY_FUNCTION__) + ": " + msg)
|
53 | 53 | ||
- | 54 | /// inotify capability/limit identifiers
|
|
- | 55 | typedef enum |
|
- | 56 | {
|
|
- | 57 | IN_MAX_EVENTS = 0, ///< max. events in the kernel queue |
|
- | 58 | IN_MAX_INSTANCES = 1, ///< max. inotify file descriptors per process |
|
- | 59 | IN_MAX_WATCHES = 2 ///< max. watches per file descriptor |
|
- | 60 | } InotifyCapability_t; |
|
- | 61 | ||
54 | /// inotify-cxx thread safety
|
62 | /// inotify-cxx thread safety
|
55 | /**
|
63 | /**
|
56 | * If this symbol is defined you can use this interface safely
|
64 | * If this symbol is defined you can use this interface safely
|
57 | * threaded applications. Remember that it slightly degrades
|
65 | * threaded applications. Remember that it slightly degrades
|
58 | * performance.
|
66 | * performance.
|
Line 467... | Line 475... | ||
467 | inline bool IsEnabled() const |
475 | inline bool IsEnabled() const |
468 | {
|
476 | {
|
469 | return m_fEnabled; |
477 | return m_fEnabled; |
470 | }
|
478 | }
|
471 | 479 | ||
- | 480 | /// Checks whether the watch is recursive.
|
|
- | 481 | /**
|
|
- | 482 | * A recursive watch monitors a directory itself and all
|
|
- | 483 | * its subdirectories. This watch is a logical object
|
|
- | 484 | * which may have many underlying kernel watches.
|
|
- | 485 | *
|
|
- | 486 | * \return currently always false (recursive watches not yet supported)
|
|
- | 487 | * \attention Recursive watches are currently NOT supported.
|
|
- | 488 | * They are planned for future versions.
|
|
- | 489 | */
|
|
- | 490 | inline bool IsRecursive() const |
|
- | 491 | {
|
|
- | 492 | return false; |
|
- | 493 | }
|
|
- | 494 | ||
472 | private: |
495 | private: |
473 | friend class Inotify; |
496 | friend class Inotify; |
474 | 497 | ||
475 | std::string m_path; ///< watched file path |
498 | std::string m_path; ///< watched file path |
476 | uint32_t m_uMask; ///< event mask |
499 | uint32_t m_uMask; ///< event mask |
Line 717... | Line 740... | ||
717 | * \throw InotifyException thrown if setting mode failed
|
740 | * \throw InotifyException thrown if setting mode failed
|
718 | *
|
741 | *
|
719 | * \sa GetDescriptor()
|
742 | * \sa GetDescriptor()
|
720 | */
|
743 | */
|
721 | void SetNonBlock(bool fNonBlock) throw (InotifyException); |
744 | void SetNonBlock(bool fNonBlock) throw (InotifyException); |
- | 745 | ||
- | 746 | /// Acquires a particular inotify capability/limit.
|
|
- | 747 | /**
|
|
- | 748 | * \param[in] cap capability/limit identifier
|
|
- | 749 | * \return capability/limit value
|
|
- | 750 | * \throw InotifyException thrown if the given value cannot be acquired
|
|
- | 751 | */
|
|
- | 752 | static uint32_t GetCapability(InotifyCapability_t cap) throw (InotifyException); |
|
- | 753 | ||
- | 754 | /// Modifies a particular inotify capability/limit.
|
|
- | 755 | /**
|
|
- | 756 | * \param[in] cap capability/limit identifier
|
|
- | 757 | * \param[in] val new capability/limit value
|
|
- | 758 | * \throw InotifyException thrown if the given value cannot be set
|
|
- | 759 | * \attention Using this function requires root privileges.
|
|
- | 760 | * Beware of setting extensive values - it may seriously
|
|
- | 761 | * affect system performance and/or stability.
|
|
- | 762 | */
|
|
- | 763 | static void SetCapability(InotifyCapability_t cap, uint32_t val) throw (InotifyException); |
|
- | 764 | ||
- | 765 | /// Returns the maximum number of events in the kernel queue.
|
|
- | 766 | /**
|
|
- | 767 | * \return maximum number of events in the kernel queue
|
|
- | 768 | * \throw InotifyException thrown if the given value cannot be acquired
|
|
- | 769 | */
|
|
- | 770 | inline static uint32_t GetMaxEvents() throw (InotifyException) |
|
- | 771 | {
|
|
- | 772 | return GetCapability(IN_MAX_EVENTS); |
|
- | 773 | }
|
|
- | 774 | ||
- | 775 | /// Sets the maximum number of events in the kernel queue.
|
|
- | 776 | /**
|
|
- | 777 | * \param[in] val new value
|
|
- | 778 | * \throw InotifyException thrown if the given value cannot be set
|
|
- | 779 | * \attention Using this function requires root privileges.
|
|
- | 780 | * Beware of setting extensive values - the greater value
|
|
- | 781 | * is set here the more physical memory may be used for the inotify
|
|
- | 782 | * infrastructure.
|
|
- | 783 | */
|
|
- | 784 | inline static void SetMaxEvents(uint32_t val) throw (InotifyException) |
|
- | 785 | {
|
|
- | 786 | SetCapability(IN_MAX_EVENTS, val); |
|
- | 787 | }
|
|
- | 788 | ||
- | 789 | /// Returns the maximum number of inotify instances per process.
|
|
- | 790 | /**
|
|
- | 791 | * It means the maximum number of open inotify file descriptors
|
|
- | 792 | * per running process.
|
|
- | 793 | *
|
|
- | 794 | * \return maximum number of inotify instances
|
|
- | 795 | * \throw InotifyException thrown if the given value cannot be acquired
|
|
- | 796 | */
|
|
- | 797 | inline static uint32_t GetMaxInstances() throw (InotifyException) |
|
- | 798 | {
|
|
- | 799 | return GetCapability(IN_MAX_INSTANCES); |
|
- | 800 | }
|
|
- | 801 | ||
- | 802 | /// Sets the maximum number of inotify instances per process.
|
|
- | 803 | /**
|
|
- | 804 | * \param[in] val new value
|
|
- | 805 | * \throw InotifyException thrown if the given value cannot be set
|
|
- | 806 | * \attention Using this function requires root privileges.
|
|
- | 807 | * Beware of setting extensive values - the greater value
|
|
- | 808 | * is set here the more physical memory may be used for the inotify
|
|
- | 809 | * infrastructure.
|
|
- | 810 | */
|
|
- | 811 | inline static void SetMaxInstances(uint32_t val) throw (InotifyException) |
|
- | 812 | {
|
|
- | 813 | SetCapability(IN_MAX_INSTANCES, val); |
|
- | 814 | }
|
|
- | 815 | ||
- | 816 | /// Returns the maximum number of inotify watches per instance.
|
|
- | 817 | /**
|
|
- | 818 | * It means the maximum number of inotify watches per inotify
|
|
- | 819 | * file descriptor.
|
|
- | 820 | *
|
|
- | 821 | * \return maximum number of inotify watches
|
|
- | 822 | * \throw InotifyException thrown if the given value cannot be acquired
|
|
- | 823 | */
|
|
- | 824 | inline static uint32_t GetMaxWatches() throw (InotifyException) |
|
- | 825 | {
|
|
- | 826 | return GetCapability(IN_MAX_WATCHES); |
|
- | 827 | }
|
|
- | 828 | ||
- | 829 | /// Sets the maximum number of inotify watches per instance.
|
|
- | 830 | /**
|
|
- | 831 | * \param[in] val new value
|
|
- | 832 | * \throw InotifyException thrown if the given value cannot be set
|
|
- | 833 | * \attention Using this function requires root privileges.
|
|
- | 834 | * Beware of setting extensive values - the greater value
|
|
- | 835 | * is set here the more physical memory may be used for the inotify
|
|
- | 836 | * infrastructure.
|
|
- | 837 | */
|
|
- | 838 | inline static void SetMaxWatches(uint32_t val) throw (InotifyException) |
|
- | 839 | {
|
|
- | 840 | SetCapability(IN_MAX_WATCHES, val); |
|
- | 841 | }
|
|
722 | 842 | ||
723 | private: |
843 | private: |
724 | int m_fd; ///< file descriptor |
844 | int m_fd; ///< file descriptor |
725 | IN_WATCH_MAP m_watches; ///< watches (by descriptors) |
845 | IN_WATCH_MAP m_watches; ///< watches (by descriptors) |
726 | IN_WP_MAP m_paths; ///< watches (by paths) |
846 | IN_WP_MAP m_paths; ///< watches (by paths) |
Line 728... | Line 848... | ||
728 | std::deque<InotifyEvent> m_events; ///< event queue |
848 | std::deque<InotifyEvent> m_events; ///< event queue |
729 | 849 | ||
730 | IN_LOCK_DECL |
850 | IN_LOCK_DECL |
731 | 851 | ||
732 | friend class InotifyWatch; |
852 | friend class InotifyWatch; |
- | 853 | ||
- | 854 | static std::string GetCapabilityPath(InotifyCapability_t cap) throw (InotifyException); |
|
733 | }; |
855 | }; |
734 | 856 | ||
735 | 857 | ||
736 | #endif //_INOTIFYCXX_H_
|
858 | #endif //_INOTIFYCXX_H_
|
737 | 859 |