virtual void OnFileSystemEvent(wxFileSystemWatcherEvent& evt)
    {
        wxLogDebug("--- %s ---", evt.ToString());
        m_lastEvent = wxDynamicCast(evt.Clone(), wxFileSystemWatcherEvent);
        m_events.Add(m_lastEvent);

        // test finished
        SendIdle();
        tested = true;
    }
    virtual void CheckResult()
    {
        CPPUNIT_ASSERT_MESSAGE( "No events received", !m_events.empty() );

        const wxFileSystemWatcherEvent * const e = m_events.front();

        // this is our "reference event"
        const wxFileSystemWatcherEvent expected = ExpectedEvent();

        CPPUNIT_ASSERT_EQUAL( expected.GetChangeType(), e->GetChangeType() );

        CPPUNIT_ASSERT_EQUAL((int)wxEVT_FSWATCHER, e->GetEventType());

        // XXX this needs change
        CPPUNIT_ASSERT_EQUAL(wxEVT_CATEGORY_UNKNOWN, e->GetEventCategory());

        CPPUNIT_ASSERT_EQUAL(expected.GetPath(), e->GetPath());
        CPPUNIT_ASSERT_EQUAL(expected.GetNewPath(), e->GetNewPath());

        // Under MSW extra modification events are sometimes reported after a
        // rename and we just can't get rid of them, so ignore them in this
        // test if they do happen.
        if ( e->GetChangeType() == wxFSW_EVENT_RENAME &&
                m_events.size() == 2 )
        {
            const wxFileSystemWatcherEvent* const e2 = m_events.back();
            if ( e2->GetChangeType() == wxFSW_EVENT_MODIFY &&
                    e2->GetPath() == e->GetNewPath() )
            {
                // This is a modify event for the new file, ignore it.
                return;
            }
        }

        WX_ASSERT_EQUAL_MESSAGE
        (
            (
                "Extra events received, last one is of type %x, path=\"%s\" "
                "(the original event was for \"%s\" (\"%s\")",
                m_events.back()->GetChangeType(),
                m_events.back()->GetPath().GetFullPath(),
                e->GetPath().GetFullPath(),
                e->GetNewPath().GetFullPath()
            ),
            1, m_events.size()
        );

    }
void SigUIFrame::OnChange(wxFileSystemWatcherEvent &event)
{
    if (event.IsError()) {
	wxLogVerbose("fswatcher error: %s", event.GetErrorDescription());
	return;
    }
    wxLogVerbose("event on %s", event.GetPath().GetFullPath());
    switch (event.GetChangeType()) {
	default:
	    break;
	case wxFSW_EVENT_CREATE:
	case wxFSW_EVENT_MODIFY:
	    wxFileName filename = event.GetPath();
	    if (filename.GetName() != "lastupd")
		return;
	    show_db(false);
	    break;
    }
}
void t4p::FileListingClass::OnFsWatcher(wxFileSystemWatcherEvent& event) {
    wxFileName modFile = event.GetNewPath();
    if (modFile.GetPathWithSep() != WorkingDir.GetPathWithSep()) {
        // event from directory we are not showing
        return;
    }
    if (event.GetChangeType() == wxFSW_EVENT_WARNING && event.GetWarningType() == wxFSW_WARNING_OVERFLOW) {
        // restart the watch
        delete Watcher;
        Watcher = new wxFileSystemWatcher();
        Watcher->SetOwner(this);
        Watcher->Add(WorkingDir, wxFSW_EVENT_CREATE | wxFSW_EVENT_DELETE | wxFSW_EVENT_RENAME | wxFSW_EVENT_WARNING | wxFSW_EVENT_ERROR);
    } else if (event.GetChangeType() == wxFSW_EVENT_ERROR) {
        // restart the watch
        delete Watcher;
        Watcher = new wxFileSystemWatcher();
        Watcher->SetOwner(this);
        Watcher->Add(WorkingDir, wxFSW_EVENT_CREATE | wxFSW_EVENT_DELETE | wxFSW_EVENT_RENAME | wxFSW_EVENT_WARNING | wxFSW_EVENT_ERROR);
    } else if (event.GetChangeType() == wxFSW_EVENT_CREATE
               || event.GetChangeType() == wxFSW_EVENT_DELETE
               || event.GetChangeType() == wxFSW_EVENT_RENAME) {
        // naive implementation for now, just refresh the entire dir
        // this is because we have labels to update, and the
        // items must be kept sorted (first dirs, then files)
        // each sorted, AND taking the filters into account
        wxPostEvent(&Handler, event);
    }
}
void t4p::FileWatcherFeatureClass::OnFsWatcher(wxFileSystemWatcherEvent& event) {
    LastWatcherEventTime = wxDateTime::Now();
    wxString path = event.GetPath().GetFullPath();
    wxFileName fileName = event.GetPath();
    if (wxFSW_EVENT_MODIFY == event.GetChangeType()) {
        PathsExternallyModified[path] = 1;
    } else if (wxFSW_EVENT_CREATE == event.GetChangeType()) {
        PathsExternallyCreated[path] = 1;
    } else if (wxFSW_EVENT_DELETE == event.GetChangeType()) {
        PathsExternallyDeleted[path] = 1;
    } else if (wxFSW_EVENT_RENAME == event.GetChangeType()) {
        PathsExternallyRenamed[path] = event.GetNewPath().GetFullPath();
    } else if (wxFSW_EVENT_WARNING == event.GetChangeType()) {
        // too many files being added/removed
        // this is probably a big directory being added / removed
        // hopefully the root directory is caught
    } else if (wxFSW_EVENT_ERROR == event.GetChangeType()) {
        // in MSW, an error event could be due to the watched directoty being deleted / renamed.
        // in this case, we need to restart the watch
        IsWatchError = true;
        wxASSERT_MSG(false, event.GetErrorDescription());
    }
}
Exemple #6
0
void wxIOCPThread::SendEvent(wxFileSystemWatcherEvent& evt)
{
    wxLogTrace(wxTRACE_FSWATCHER, "[iocp] EVT: %s", evt.ToString());
    m_service->SendEvent(evt);
}
Exemple #7
0
void wxFSWatcherImplMSW::SendEvent(wxFileSystemWatcherEvent& evt)
{
    // called from worker thread, so posting event in thread-safe way
    wxQueueEvent(m_watcher->GetOwner(), evt.Clone());
}
 void SendEvent(wxFileSystemWatcherEvent& evt)
 {
     wxLogTrace(wxTRACE_FSWATCHER, evt.ToString());
     m_watcher->GetOwner()->ProcessEvent(evt);
 }
void ReplayProvider::OnFileSystemChange(wxFileSystemWatcherEvent& event)
{
	wxLogDebug(event.ToString());
	if (!event.GetPath().GetExt().IsSameAs("replay", false))
		return;

	if (event.GetChangeType() & wxFSW_EVENT_CREATE)
	{
		Replay* existingReplay = FindReplay(event.GetPath().GetFullPath());
		if (existingReplay) // Replay is already in list
			return;

		// Give rocket league some time to write the file
		wxMilliSleep(500);

		// Add new file
		Replay::Ptr ri(new Replay(event.GetPath().GetFullPath()));
		replay.push_back(ri);

		if (wxConfig::Get()->ReadBool("AutoUpload", false))
		{
			TransferManager::Get().Upload(ri);
		}

		wxCommandEvent evt(wxEVT_REPLAY_ADDED);
		evt.SetInt(replay.size() - 1);
		evt.SetEventObject(this);
		GetRoot()->ProcessEvent(evt);
	}
	else if (event.GetChangeType() & wxFSW_EVENT_DELETE)
	{
		// Find replay and remove it
		size_t index = 0;
		wxString changePath = event.GetPath().GetFullPath();

		for (auto replayIT = replay.begin(); replayIT != replay.end(); ++replayIT, ++index)
		{
			if ((*replayIT)->GetFileName().IsSameAs(changePath, false))
			{
				replay.erase(replayIT);
				break;
			}
		}

		wxCommandEvent evt(wxEVT_REPLAY_REMOVED);
		evt.SetInt(index);
		evt.SetEventObject(this);
		GetRoot()->ProcessEvent(evt);
	}
	else if (event.GetChangeType() & wxFSW_EVENT_RENAME)
	{
		wxString changePath = event.GetPath().GetFullPath();

		// Find replay and update filename
		for (auto replayIT = replay.begin(); replayIT != replay.end(); ++replayIT)
		{
			if ((*replayIT)->GetFileName().IsSameAs(changePath, false))
			{
				(*replayIT)->SetFileName(event.GetNewPath().GetFullPath());
				break;
			}
		}
	}

	event.Skip();
}
Exemple #10
0
void wxGxDiscConnection::OnFileSystemEvent(wxFileSystemWatcherEvent& event)
{
    wxLogDebug(wxT("*** %s ***"), event.ToString().c_str());
    switch(event.GetChangeType())
    {
    case wxFSW_EVENT_CREATE:
        {
            //get object parent
            wxFileName oName = event.GetPath();
            wxGxObjectContainer *parent = wxDynamicCast(FindGxObjectByPath(oName.GetPath()), wxGxObjectContainer);
            if(!parent)
                return;
            //check doubles
            if(parent->IsNameExist(event.GetPath().GetFullName()))
                return;

            CPLString szPath(event.GetPath().GetFullPath().mb_str(wxConvUTF8));
            char **papszFileList = NULL;  
            papszFileList = CSLAddString( papszFileList, szPath );
	        if(m_pCatalog)
            {
                wxArrayLong ChildrenIds;
                m_pCatalog->CreateChildren(parent, papszFileList, ChildrenIds);
                for(size_t i = 0; i < ChildrenIds.GetCount(); ++i)
                    m_pCatalog->ObjectAdded(ChildrenIds[i]);
	        }
            CSLDestroy( papszFileList );
        }
        break;
    case wxFSW_EVENT_DELETE:
        {
            //search gxobject
            wxGxObject *current = FindGxObjectByPath(event.GetPath().GetFullPath());
            if(current)
            {
                current->Destroy();
                return;
            }
        }
        break;
    case wxFSW_EVENT_RENAME:
        {
            wxGxObject *current = FindGxObjectByPath(event.GetPath().GetFullPath());
            if(current)
            {
                current->SetName(event.GetNewPath().GetFullName());
                current->SetPath( CPLString( event.GetNewPath().GetFullPath().mb_str(wxConvUTF8) ) );
                wxGIS_GXCATALOG_EVENT_ID(ObjectChanged, current->GetId());

#ifdef __WXGTK__
                m_pWatcher->Remove(event.GetPath());
                if(!IsPathWatched(event.GetNewPath().GetFullPath()))
                {
                    m_pWatcher->Add(event.GetNewPath());

                }
#endif
                return;
            }
        }
        break;
    case wxFSW_EVENT_MODIFY:
        break;
    default:
    case wxFSW_EVENT_ACCESS:
    case wxFSW_EVENT_WARNING:
    case wxFSW_EVENT_ERROR:
        break;
    };
}