xref: /haiku/src/build/libroot/NodeRef.h (revision ed6250c95736c0b55da79d6e9dd01369532260c0)
1 #ifndef NODE_REF_H
2 #define NODE_REF_H
3 
4 #include <sys/stat.h>
5 
6 namespace BPrivate {
7 
8 struct NodeRef {
9 	dev_t	device;
10 	ino_t	node;
11 
12 	NodeRef(dev_t device = 0, ino_t node = 0)
13 		: device(device),
14 		  node(node)
15 	{
16 	}
17 
18 	NodeRef(const struct stat &st)
19 		: device(st.st_dev),
20 		  node(st.st_ino)
21 	{
22 	}
23 
24 	NodeRef(const NodeRef &other)
25 	{
26 		device = other.device;
27 		node = other.node;
28 	}
29 
30 	NodeRef &operator=(const NodeRef &other)
31 	{
32 		device = other.device;
33 		node = other.node;
34 		return *this;
35 	}
36 
37 	bool operator==(const NodeRef &other) const
38 	{
39 		return (device == other.device && node == other.node);
40 	}
41 
42 	bool operator!=(const NodeRef &other) const
43 	{
44 		return !(*this == other);
45 	}
46 
47 	bool operator<(const NodeRef &other) const
48 	{
49 		return (device < other.device
50 			|| device == other.device && node < other.node);
51 	}
52 
53 };
54 
55 } // namespace BPrivate
56 
57 #endif	// NODE_REF_H
58