1 // Entry.cpp 2 3 #include "Entry.h" 4 5 #include "Directory.h" 6 #include "FDManager.h" 7 #include "Path.h" 8 #include "Volume.h" 9 #include "VolumeManager.h" 10 11 // #pragma mark - 12 13 // Entry 14 15 // constructor 16 Entry::Entry(Volume* volume, Directory* directory, const char* name, Node* node) 17 : fVolume(volume), 18 fDirectory(directory), 19 fName(name), 20 fNode(node), 21 fDirEntryLink() 22 { 23 } 24 25 // destructor 26 Entry::~Entry() 27 { 28 } 29 30 // InitCheck 31 status_t 32 Entry::InitCheck() const 33 { 34 return (fName.GetLength() > 0 ? B_OK : B_NO_MEMORY); 35 } 36 37 // GetVolume 38 Volume* 39 Entry::GetVolume() const 40 { 41 return fVolume; 42 } 43 44 // GetDirectory 45 Directory* 46 Entry::GetDirectory() const 47 { 48 return fDirectory; 49 } 50 51 // GetEntryRef 52 NoAllocEntryRef 53 Entry::GetEntryRef() const 54 { 55 return NoAllocEntryRef(fVolume->GetID(), fDirectory->GetID(), 56 fName.GetString()); 57 } 58 59 // GetVolumeID 60 dev_t 61 Entry::GetVolumeID() const 62 { 63 return fVolume->GetID(); 64 } 65 66 // GetDirectoryID 67 ino_t 68 Entry::GetDirectoryID() const 69 { 70 return fDirectory->GetID(); 71 } 72 73 // GetName 74 const char* 75 Entry::GetName() const 76 { 77 return fName.GetString(); 78 } 79 80 // GetNode 81 Node* 82 Entry::GetNode() const 83 { 84 return fNode; 85 } 86 87 // GetPath 88 status_t 89 Entry::GetPath(Path* path) 90 { 91 return VolumeManager::GetDefault()->GetPath(this, path); 92 } 93 94 // Exists 95 bool 96 Entry::Exists() const 97 { 98 NoAllocEntryRef entryRef(GetEntryRef()); 99 BEntry bEntry; 100 return (FDManager::SetEntry(&bEntry, &entryRef) == B_OK && bEntry.Exists()); 101 } 102 103 // IsActualEntry 104 bool 105 Entry::IsActualEntry() const 106 { 107 return (fName.GetLength() > 0 && fName != "." && fName != ".."); 108 } 109