1 /* 2 * Copyright 2005-2008, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef NODE_REF_H 6 #define NODE_REF_H 7 8 #include <sys/stat.h> 9 10 namespace BPrivate { 11 12 struct NodeRef { 13 dev_t device; 14 ino_t node; 15 16 NodeRef(dev_t device = 0, ino_t node = 0) 17 : device(device), 18 node(node) 19 { 20 } 21 22 NodeRef(const struct stat &st) 23 : device(st.st_dev), 24 node(st.st_ino) 25 { 26 } 27 28 NodeRef(const NodeRef &other) 29 { 30 device = other.device; 31 node = other.node; 32 } 33 34 NodeRef &operator=(const NodeRef &other) 35 { 36 device = other.device; 37 node = other.node; 38 return *this; 39 } 40 41 bool operator==(const NodeRef &other) const 42 { 43 return (device == other.device && node == other.node); 44 } 45 46 bool operator!=(const NodeRef &other) const 47 { 48 return !(*this == other); 49 } 50 51 bool operator<(const NodeRef &other) const 52 { 53 return (device < other.device 54 || (device == other.device && node < other.node)); 55 } 56 57 }; 58 59 } // namespace BPrivate 60 61 #endif // NODE_REF_H 62