]> git.saurik.com Git - wxWidgets.git/commitdiff
Add wxFSW_EVENT_ATTRIB wxFileSystemWatcher flag.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 17 Nov 2012 23:56:00 +0000 (23:56 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 17 Nov 2012 23:56:00 +0000 (23:56 +0000)
This flag allows to monitor changes to the file attributes, such as file
modification time.

This patch adds the flag, support for it under Linux and the corresponding
modifications to the sample and the test suite.

Closes #14833.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72977 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
include/wx/fswatcher.h
interface/wx/fswatcher.h
samples/fswatcher/fswatcher.cpp
src/common/fswatchercmn.cpp
src/unix/fswatcher_inotify.cpp
tests/fswatcher/fswatchertest.cpp

index 817b3bfcffa9cce92bfff407ca8a2630e118e6cd..0612f427a58cde26ea433d2da5ce6abe1f32cd37 100644 (file)
@@ -541,6 +541,7 @@ All:
 - Add wxDIR_NO_FOLLOW flag for wxDir traversal (David Hart).
 - Allow testing for symlink/FIFO/socket existence in wxFileName (David Hart).
 - Many important bug fixes in wxFileSystemWatcher (David Hart).
+- Add wxFSW_EVENT_ATTRIB flag support to wxFileSystemWatcher (David Hart).
 - Add separate read/written bytes counters and per-direction NOWAIT and WAITALL
   flags to wxSocket (Rob Bresalier).
 - Add wxDir::Close() method (Silverstorm82).
index 30656714ef6683b92d126f81106a436a8b6b8408..cb31a78f53555f39298d5186403e043da9baf678 100644 (file)
@@ -44,14 +44,14 @@ enum
     wxFSW_EVENT_RENAME = 0x04,
     wxFSW_EVENT_MODIFY = 0x08,
     wxFSW_EVENT_ACCESS = 0x10,
+    wxFSW_EVENT_ATTRIB = 0x20, // Currently this is wxGTK-only
 
     // error events
-    wxFSW_EVENT_WARNING = 0x20,
-    wxFSW_EVENT_ERROR = 0x40,
-
+    wxFSW_EVENT_WARNING = 0x40,
+    wxFSW_EVENT_ERROR = 0x80,
     wxFSW_EVENT_ALL = wxFSW_EVENT_CREATE | wxFSW_EVENT_DELETE |
                          wxFSW_EVENT_RENAME | wxFSW_EVENT_MODIFY |
-                         wxFSW_EVENT_ACCESS |
+                         wxFSW_EVENT_ACCESS | wxFSW_EVENT_ATTRIB |
                          wxFSW_EVENT_WARNING | wxFSW_EVENT_ERROR
 };
 
index 77f2e15a172bae6528673e56895220c85b6fe176..b2981a0e5b532341fc244e3374749bbba45e75af 100644 (file)
@@ -248,6 +248,15 @@ enum wxFSWFlags
      */
     wxFSW_EVENT_ACCESS = 0x10,
 
+    /**
+        The item's metadata was changed, e.g.\ its permissions or timestamps.
+
+        This event is currently only detected under Linux.
+
+        @since 2.9.5
+     */
+    wxFSW_EVENT_ATTRIB = 0x20,
+
     /**
         A warning condition arose.
 
@@ -257,7 +266,7 @@ enum wxFSWFlags
         more events will still be coming in the future, unlike for the error
         condition below.
      */
-    wxFSW_EVENT_WARNING = 0x20,
+    wxFSW_EVENT_WARNING = 0x40,
 
     /**
         An error condition arose.
@@ -266,11 +275,11 @@ enum wxFSWFlags
         and the program can stop watching the directories currently being
         monitored.
     */
-    wxFSW_EVENT_ERROR = 0x40,
+    wxFSW_EVENT_ERROR = 0x80,
 
     wxFSW_EVENT_ALL = wxFSW_EVENT_CREATE | wxFSW_EVENT_DELETE |
                          wxFSW_EVENT_RENAME | wxFSW_EVENT_MODIFY |
-                         wxFSW_EVENT_ACCESS |
+                         wxFSW_EVENT_ACCESS | wxFSW_EVENT_ATTRIB |
                          wxFSW_EVENT_WARNING | wxFSW_EVENT_ERROR
 };
 
index 7d3d0815a3dc9371b8f0a382ea8128a8275ea62c..3fde2baa265c8ae207d253c415a77a399ed0ea86 100644 (file)
@@ -535,6 +535,8 @@ static wxString GetFSWEventChangeTypeName(int changeType)
         return "MODIFY";
     case wxFSW_EVENT_ACCESS:
         return "ACCESS";
+    case wxFSW_EVENT_ATTRIB: // Currently this is wxGTK-only
+        return "ATTRIBUTE";
     }
 
     return "INVALID_TYPE";
index 14c16bb5434994cbd4d71421d90f6b6b4c9987e5..1fbf26b9ca7846e2cc3bcb31a74df3d03d17b794 100644 (file)
@@ -40,6 +40,8 @@ static wxString GetFSWEventChangeTypeName(int type)
         return "MODIFY";
     case wxFSW_EVENT_ACCESS:
         return "ACCESS";
+    case wxFSW_EVENT_ATTRIB: // Currently this is wxGTK-only
+        return "ATTRIBUTE";
     }
 
     // should never be reached!
index f7bcc030570edc3913ffdbf683f9ec46747f3e2a..6f02d7071e7bd276f6c0940adcf440ebc4fe0a78 100644 (file)
@@ -490,6 +490,7 @@ protected:
         static const int flag_mapping[][2] = {
             { wxFSW_EVENT_ACCESS, IN_ACCESS },
             { wxFSW_EVENT_MODIFY, IN_MODIFY },
+            { wxFSW_EVENT_ATTRIB, IN_ATTRIB },
             { wxFSW_EVENT_RENAME, IN_MOVE   },
             { wxFSW_EVENT_CREATE, IN_CREATE },
             { wxFSW_EVENT_DELETE, IN_DELETE|IN_DELETE_SELF|IN_MOVE_SELF }
@@ -511,7 +512,7 @@ protected:
         static const int flag_mapping[][2] = {
             { IN_ACCESS,        wxFSW_EVENT_ACCESS }, // generated during read!
             { IN_MODIFY,        wxFSW_EVENT_MODIFY },
-            { IN_ATTRIB,        0 },
+            { IN_ATTRIB,        wxFSW_EVENT_ATTRIB },
             { IN_CLOSE_WRITE,   0 },
             { IN_CLOSE_NOWRITE, 0 },
             { IN_OPEN,          0 },
index caca07bab11525fa0cc8ab262a5db95384fb3694..5b238a49d54d4681d26b17bbee132f274f19c99a 100644 (file)
@@ -439,6 +439,7 @@ private:
 #endif // !wxHAS_KQUEUE
 
 #ifdef wxHAS_INOTIFY
+        CPPUNIT_TEST( TestEventAttribute );
         CPPUNIT_TEST( TestSingleWatchtypeEvent );
 #endif // wxHAS_INOTIFY
 
@@ -451,6 +452,7 @@ private:
     void TestEventModify();
     void TestEventAccess();
 #ifdef wxHAS_INOTIFY
+    void TestEventAttribute();
     void TestSingleWatchtypeEvent();
 #endif // wxHAS_INOTIFY
 #if !defined(__VISUALC__) || wxCHECK_VISUALC_VERSION(7)
@@ -645,6 +647,37 @@ void FileSystemWatcherTestCase::TestEventAccess()
 }
 
 #ifdef wxHAS_INOTIFY
+// ----------------------------------------------------------------------------
+// TestEventAttribute
+// ----------------------------------------------------------------------------
+void FileSystemWatcherTestCase::TestEventAttribute()
+{
+    wxLogDebug("TestEventAttribute()");
+
+    class EventTester : public EventHandler
+    {
+    public:
+        virtual void GenerateEvent()
+        {
+            CPPUNIT_ASSERT(eg.TouchFile());
+        }
+
+        virtual wxFileSystemWatcherEvent ExpectedEvent()
+        {
+            wxFileSystemWatcherEvent event(wxFSW_EVENT_ATTRIB);
+            event.SetPath(eg.m_file);
+            event.SetNewPath(eg.m_file);
+            return event;
+        }
+    };
+
+    // we need to create a file to touch
+    EventGenerator::Get().CreateFile();
+
+    EventTester tester;
+    tester.Run();
+}
+
 // ----------------------------------------------------------------------------
 // TestSingleWatchtypeEvent: Watch only wxFSW_EVENT_ACCESS
 // ----------------------------------------------------------------------------