btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / tests / system / kernel / node_monitor_test.cpp
blob81d3738800fd058af36a037526535c3001fc0ec6
1 /*
2 * Copyright 2010, Axel Dörfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
4 */
7 #include <stdio.h>
9 #include <Application.h>
10 #include <Entry.h>
11 #include <NodeMonitor.h>
14 class Application : public BApplication {
15 public:
16 Application();
17 virtual ~Application();
19 protected:
20 virtual void ArgvReceived(int32 argCount, char** args);
21 virtual void ReadyToRun();
22 virtual void MessageReceived(BMessage* message);
24 private:
25 bool fWatchingNode;
29 Application::Application()
31 BApplication("application/x-vnd.test-node-monitor-test"),
32 fWatchingNode(false)
37 Application::~Application()
42 void
43 Application::ArgvReceived(int32 argCount, char** args)
45 uint32 flags = B_WATCH_STAT;
47 for (int32 i = 0; i < argCount; i++) {
48 BEntry entry(args[i]);
49 if (!entry.Exists()) {
50 fprintf(stderr, "Entry does not exist: %s\n", args[i]);
51 continue;
54 node_ref nodeRef;
55 entry.GetNodeRef(&nodeRef);
56 if (watch_node(&nodeRef, flags, this) == B_OK)
57 fWatchingNode = true;
62 void
63 Application::ReadyToRun()
65 if (!fWatchingNode)
66 Quit();
70 void
71 Application::MessageReceived(BMessage* message)
73 switch (message->what) {
74 case B_NODE_MONITOR:
75 message->PrintToStream();
76 break;
78 default:
79 BApplication::MessageReceived(message);
84 // #pragma mark -
87 int
88 main(int argc, char** argv)
90 Application app;
91 app.Run();
93 return 0;