Add wxFSW_EVENT_ATTRIB wxFileSystemWatcher flag.
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
This commit is contained in:
@@ -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).
|
||||
|
@@ -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
|
||||
};
|
||||
|
||||
|
@@ -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
|
||||
};
|
||||
|
||||
|
@@ -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";
|
||||
|
@@ -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!
|
||||
|
@@ -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 },
|
||||
|
@@ -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
|
||||
// ----------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user