1 // AttributeDirectory.h 2 3 #ifndef NET_FS_ATTRIBUTE_DIRECTORY_H 4 #define NET_FS_ATTRIBUTE_DIRECTORY_H 5 6 #include <fs_attr.h> 7 8 #include "SLList.h" 9 10 class BNode; 11 12 // attribute directory status 13 enum { 14 ATTRIBUTE_DIRECTORY_NOT_LOADED, 15 ATTRIBUTE_DIRECTORY_VALID, 16 ATTRIBUTE_DIRECTORY_TOO_BIG, 17 }; 18 19 // Attribute 20 class Attribute : public SLListLinkImpl<Attribute> { 21 Attribute(const char* name, 22 const attr_info& info, const void* data); 23 ~Attribute(); 24 public: 25 static status_t CreateAttribute(const char* name, 26 const attr_info& info, const void* data, 27 Attribute** attribute); 28 static void DeleteAttribute(Attribute* attribute); 29 30 const char* GetName() const; 31 void GetInfo(attr_info* info) const; 32 uint32 GetType() const; 33 off_t GetSize() const; 34 const void* GetData() const; 35 36 private: 37 attr_info fInfo; 38 char fDataAndName[1]; 39 }; 40 41 // AttributeDirectory 42 class AttributeDirectory { 43 public: 44 AttributeDirectory(); 45 virtual ~AttributeDirectory(); 46 47 uint32 GetAttrDirStatus() const; 48 bool IsAttrDirValid() const; 49 50 status_t LoadAttrDir(); 51 void ClearAttrDir(); 52 53 status_t AddAttribute(const char* name, 54 const attr_info& info, const void* data); 55 bool RemoveAttribute(const char* name); 56 void RemoveAttribute(Attribute* attribute); 57 status_t UpdateAttribute(const char* name, bool* removed, 58 attr_info* info, const void** data); 59 Attribute* GetAttribute(const char* name) const; 60 Attribute* GetFirstAttribute() const; 61 Attribute* GetNextAttribute(Attribute* attribute) const; 62 63 virtual status_t OpenNode(BNode& node) = 0; 64 65 private: 66 status_t _LoadAttribute(BNode& node, const char* name, 67 attr_info& info, void* data, 68 bool& dataLoaded); 69 70 private: 71 SLList<Attribute> fAttributes; 72 uint32 fStatus; 73 }; 74 75 #endif // NET_FS_ATTRIBUTE_DIRECTORY_H 76