1// EntryRef.cpp 2 3#include "EntryRef.h" 4#include "HashString.h" 5 6// constructor 7EntryRef::EntryRef() 8 : entry_ref() 9{ 10} 11 12// constructor 13EntryRef::EntryRef(dev_t volumeID, ino_t nodeID, const char* name) 14 : entry_ref(volumeID, nodeID, name) 15{ 16} 17 18// constructor 19EntryRef::EntryRef(const entry_ref& ref) 20 : entry_ref(ref) 21{ 22} 23 24// InitCheck 25status_t 26EntryRef::InitCheck() const 27{ 28 if (device < 0 || directory < 0) 29 return B_NO_INIT; 30 return (name ? B_OK : B_NO_MEMORY); 31} 32 33// GetHashCode 34uint32 35EntryRef::GetHashCode() const 36{ 37 uint32 hash = device; 38 hash = 17 * hash + (uint32)(directory >> 32); 39 hash = 17 * hash + (uint32)directory; 40 hash = 17 * hash + string_hash(name); 41 return hash; 42} 43 44 45// #pragma mark - 46 47// constructor 48NoAllocEntryRef::NoAllocEntryRef() 49 : EntryRef() 50{ 51} 52 53// constructor 54NoAllocEntryRef::NoAllocEntryRef(dev_t volumeID, ino_t nodeID, const char* name) 55 : EntryRef() 56{ 57 device = volumeID; 58 directory = nodeID; 59 this->name = const_cast<char*>(name); 60} 61 62// constructor 63NoAllocEntryRef::NoAllocEntryRef(const entry_ref& ref) 64 : EntryRef() 65{ 66 device = ref.device; 67 directory = ref.directory; 68 this->name = ref.name; 69} 70 71// destructor 72NoAllocEntryRef::~NoAllocEntryRef() 73{ 74 name = NULL; 75} 76 77// = 78NoAllocEntryRef& 79NoAllocEntryRef::operator=(const entry_ref& ref) 80{ 81 device = ref.device; 82 directory = ref.directory; 83 this->name = ref.name; 84 return *this; 85} 86 87