1 //---------------------------------------------------------------------- 2 // This software is part of the OpenBeOS distribution and is covered 3 // by the OpenBeOS license. 4 //--------------------------------------------------------------------- 5 /*! 6 \file Node.h 7 BNode and node_ref interface declarations. 8 */ 9 10 #ifndef _NODE_H 11 #define _NODE_H 12 13 #include <Statable.h> 14 15 #ifdef USE_OPENBEOS_NAMESPACE 16 namespace OpenBeOS { 17 #endif 18 19 //--------------------------------------------------------------- 20 // node_ref 21 //--------------------------------------------------------------- 22 23 //! Reference structure to a particular vnode on a particular device 24 /*! <b>node_ref</b> - A node reference. 25 26 @author <a href="mailto:tylerdauwalder@users.sf.net">Tyler Dauwalder</a> 27 @author Be Inc. 28 @version 0.0.0 29 */ 30 struct node_ref { 31 node_ref(); 32 node_ref(const node_ref &ref); 33 34 bool operator==(const node_ref &ref) const; 35 bool operator!=(const node_ref &ref) const; 36 node_ref& operator=(const node_ref &ref); 37 38 bool operator<(const node_ref &ref) const 39 { 40 return (device < ref.device 41 || device == ref.device && node < ref.node); 42 } 43 44 dev_t device; 45 ino_t node; 46 }; 47 48 49 //--------------------------------------------------------------- 50 // BNode 51 //--------------------------------------------------------------- 52 53 //! A BNode represents a chunk of data in the filesystem. 54 /*! The BNode class provides an interface for manipulating the data and attributes 55 belonging to filesystem entries. The BNode is unaware of the name that refers 56 to it in the filesystem (i.e. its entry); a BNode is solely concerned with 57 the entry's data and attributes. 58 59 60 @author <a href='mailto:tylerdauwalder@users.sf.net'>Tyler Dauwalder</a> 61 @version 0.0.0 62 63 */ 64 class BNode : public BStatable { 65 public: 66 67 BNode(); 68 BNode(const entry_ref *ref); 69 BNode(const BEntry *entry); 70 BNode(const char *path); 71 BNode(const BDirectory *dir, const char *path); 72 BNode(const BNode &node); 73 virtual ~BNode(); 74 75 status_t InitCheck() const; 76 77 virtual status_t GetStat(struct stat *st) const; 78 79 status_t SetTo(const entry_ref *ref); 80 status_t SetTo(const BEntry *entry); 81 status_t SetTo(const char *path); 82 status_t SetTo(const BDirectory *dir, const char *path); 83 void Unset(); 84 85 status_t Lock(); 86 status_t Unlock(); 87 88 status_t Sync(); 89 90 ssize_t WriteAttr(const char *name, type_code type, off_t offset, 91 const void *buffer, size_t len); 92 ssize_t ReadAttr(const char *name, type_code type, off_t offset, 93 void *buffer, size_t len) const; 94 status_t RemoveAttr(const char *name); 95 status_t RenameAttr(const char *oldname, const char *newname); 96 status_t GetAttrInfo(const char *name, struct attr_info *info) const; 97 status_t GetNextAttrName(char *buffer); 98 status_t RewindAttrs(); 99 status_t WriteAttrString(const char *name, const BString *data); 100 status_t ReadAttrString(const char *name, BString *result) const; 101 102 BNode& operator=(const BNode &node); 103 bool operator==(const BNode &node) const; 104 bool operator!=(const BNode &node) const; 105 106 int Dup(); // This should be "const" but R5's is not... Ugggh. 107 108 private: 109 friend class BFile; 110 friend class BDirectory; 111 friend class BSymLink; 112 113 virtual void _RudeNode1(); 114 virtual void _RudeNode2(); 115 virtual void _RudeNode3(); 116 virtual void _RudeNode4(); 117 virtual void _RudeNode5(); 118 virtual void _RudeNode6(); 119 120 uint32 rudeData[4]; 121 122 private: 123 status_t set_fd(int fd); 124 virtual void close_fd(); 125 void set_status(status_t newStatus); 126 127 status_t _SetTo(int fd, const char *path, bool traverse); 128 status_t _SetTo(const entry_ref *ref, bool traverse); 129 130 virtual status_t set_stat(struct stat &st, uint32 what); 131 132 int fFd; 133 int fAttrFd; 134 status_t fCStatus; 135 136 status_t InitAttrDir(); 137 }; 138 139 140 141 #ifdef USE_OPENBEOS_NAMESPACE 142 }; // namespace OpenBeOS 143 #endif 144 145 #endif // _NODE_H 146 147 148