* Turn the debug output for node monitoring optional tracing.
* Output something if the node monitor message does not contain the expected fields (Haiku node monitoring is soo much easier...) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26869 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -50,6 +50,13 @@ using std::nothrow;
|
|||||||
|
|
||||||
static const bigtime_t kChangesPulseInterval = 500000;
|
static const bigtime_t kChangesPulseInterval = 500000;
|
||||||
|
|
||||||
|
#define TRACE_NODE_MONITORING
|
||||||
|
#ifdef TRACE_NODE_MONITORING
|
||||||
|
# define TRACE_NM(x...) printf(x)
|
||||||
|
#else
|
||||||
|
# define TRACE_NM(x...)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
GrepWindow::GrepWindow(BMessage* message)
|
GrepWindow::GrepWindow(BMessage* message)
|
||||||
: BWindow(BRect(0, 0, 1, 1), NULL, B_DOCUMENT_WINDOW, 0),
|
: BWindow(BRect(0, 0, 1, 1), NULL, B_DOCUMENT_WINDOW, 0),
|
||||||
@@ -691,7 +698,7 @@ GrepWindow::_StartNodeMonitoring()
|
|||||||
// watch the top level folder
|
// watch the top level folder
|
||||||
BPath path(&fModel->fDirectory);
|
BPath path(&fModel->fDirectory);
|
||||||
if (path.InitCheck() == B_OK) {
|
if (path.InitCheck() == B_OK) {
|
||||||
//printf("start monitoring root folder: %s\n", path.Path());
|
TRACE_NM("start monitoring root folder: %s\n", path.Path());
|
||||||
BPrivate::BPathMonitor::StartWatching(path.Path(), dirFlags, messenger);
|
BPrivate::BPathMonitor::StartWatching(path.Path(), dirFlags, messenger);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -703,13 +710,13 @@ GrepWindow::_StartNodeMonitoring()
|
|||||||
if (entry.IsDirectory()) {
|
if (entry.IsDirectory()) {
|
||||||
// subfolder
|
// subfolder
|
||||||
if (iterator.FollowSubdir(entry)) {
|
if (iterator.FollowSubdir(entry)) {
|
||||||
//printf("start monitoring folder: %s\n", path.Path());
|
TRACE_NM("start monitoring folder: %s\n", path.Path());
|
||||||
BPrivate::BPathMonitor::StartWatching(path.Path(),
|
BPrivate::BPathMonitor::StartWatching(path.Path(),
|
||||||
dirFlags | B_WATCH_RECURSIVELY, messenger);
|
dirFlags | B_WATCH_RECURSIVELY, messenger);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// regular file
|
// regular file
|
||||||
//printf("start monitoring file: %s\n", path.Path());
|
TRACE_NM("start monitoring file: %s\n", path.Path());
|
||||||
BPrivate::BPathMonitor::StartWatching(path.Path(), fileFlags,
|
BPrivate::BPathMonitor::StartWatching(path.Path(), fileFlags,
|
||||||
messenger);
|
messenger);
|
||||||
}
|
}
|
||||||
@@ -850,6 +857,8 @@ GrepWindow::_OnNodeMonitorEvent(BMessage* message)
|
|||||||
case B_ENTRY_CREATED:
|
case B_ENTRY_CREATED:
|
||||||
case B_ENTRY_REMOVED:
|
case B_ENTRY_REMOVED:
|
||||||
{
|
{
|
||||||
|
TRACE_NM("%s\n", opCode == B_ENTRY_CREATED ? "B_ENTRY_CREATED"
|
||||||
|
: "B_ENTRY_REMOVED");
|
||||||
const char* name;
|
const char* name;
|
||||||
BString path;
|
BString path;
|
||||||
if (message->FindString("path", &path) == B_OK
|
if (message->FindString("path", &path) == B_OK
|
||||||
@@ -859,25 +868,40 @@ GrepWindow::_OnNodeMonitorEvent(BMessage* message)
|
|||||||
fChangesIterator->EntryAdded(path.String());
|
fChangesIterator->EntryAdded(path.String());
|
||||||
else
|
else
|
||||||
fChangesIterator->EntryRemoved(path.String());
|
fChangesIterator->EntryRemoved(path.String());
|
||||||
|
} else {
|
||||||
|
#ifdef TRACE_NODE_MONITORING
|
||||||
|
printf("B_ENTRY_CREATED/REMOVED - incompatible message:\n");
|
||||||
|
message->PrintToStream();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_ENTRY_MOVED:
|
case B_ENTRY_MOVED:
|
||||||
printf("B_ENTRY_MOVED\n");
|
#ifdef TRACE_NODE_MONITORING
|
||||||
message->PrintToStream();
|
printf("B_ENTRY_MOVED\n");
|
||||||
|
message->PrintToStream();
|
||||||
|
#endif
|
||||||
// TODO: If the path is now outside the folder hierarchy, it's just
|
// TODO: If the path is now outside the folder hierarchy, it's just
|
||||||
// a "removed" entry. If the move happened within the hierarchy,
|
// a "removed" entry. If the move happened within the hierarchy,
|
||||||
// it should be a combined removed/added event.
|
// it should be a combined removed/added event.
|
||||||
break;
|
break;
|
||||||
case B_STAT_CHANGED:
|
case B_STAT_CHANGED:
|
||||||
{
|
{
|
||||||
|
TRACE_NM("B_STAT_CHANGED\n");
|
||||||
BString path;
|
BString path;
|
||||||
if (message->FindString("path", &path) == B_OK)
|
if (message->FindString("path", &path) == B_OK)
|
||||||
fChangesIterator->EntryChanged(path.String());
|
fChangesIterator->EntryChanged(path.String());
|
||||||
|
else {
|
||||||
|
#ifdef TRACE_NODE_MONITORING
|
||||||
|
printf("incompatible message:\n");
|
||||||
|
message->PrintToStream();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
TRACE_NM("unkown op code\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user