1 // EntryRef.cpp
2
3 #include "EntryRef.h"
4 #include "HashString.h"
5
6 // constructor
EntryRef()7 EntryRef::EntryRef()
8 : entry_ref()
9 {
10 }
11
12 // constructor
EntryRef(dev_t volumeID,ino_t nodeID,const char * name)13 EntryRef::EntryRef(dev_t volumeID, ino_t nodeID, const char* name)
14 : entry_ref(volumeID, nodeID, name)
15 {
16 }
17
18 // constructor
EntryRef(const entry_ref & ref)19 EntryRef::EntryRef(const entry_ref& ref)
20 : entry_ref(ref)
21 {
22 }
23
24 // InitCheck
25 status_t
InitCheck() const26 EntryRef::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
34 uint32
GetHashCode() const35 EntryRef::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
NoAllocEntryRef()48 NoAllocEntryRef::NoAllocEntryRef()
49 : EntryRef()
50 {
51 }
52
53 // constructor
NoAllocEntryRef(dev_t volumeID,ino_t nodeID,const char * name)54 NoAllocEntryRef::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
NoAllocEntryRef(const entry_ref & ref)63 NoAllocEntryRef::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
~NoAllocEntryRef()72 NoAllocEntryRef::~NoAllocEntryRef()
73 {
74 name = NULL;
75 }
76
77 // =
78 NoAllocEntryRef&
operator =(const entry_ref & ref)79 NoAllocEntryRef::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