xref: /haiku/src/kits/debugger/files/LocatableDirectory.cpp (revision 44b874666af6b25da6311e5a1c506ee3761f4268)
1 /*
2  * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 #include "LocatableDirectory.h"
7 
8 
9 LocatableDirectory::LocatableDirectory(LocatableEntryOwner* owner,
10 	LocatableDirectory* parent, const BString& path)
11 	:
12 	LocatableEntry(owner, parent),
13 	fPath(path),
14 	fLocatedPath()
15 {
16 }
17 
18 
19 LocatableDirectory::~LocatableDirectory()
20 {
21 }
22 
23 
24 const char*
25 LocatableDirectory::Name() const
26 {
27 	int32 lastSlash = fPath.FindLast('/');
28 		// return -1, if not found
29 	return fPath.String() + (lastSlash + 1);
30 }
31 
32 
33 const char*
34 LocatableDirectory::Path() const
35 {
36 	return fPath.String();
37 }
38 
39 
40 void
41 LocatableDirectory::GetPath(BString& _path) const
42 {
43 	_path = fPath;
44 }
45 
46 
47 bool
48 LocatableDirectory::GetLocatedPath(BString& _path) const
49 {
50 	if (fLocatedPath.Length() == 0)
51 		return false;
52 	_path = fLocatedPath;
53 	return true;
54 }
55 
56 
57 void
58 LocatableDirectory::SetLocatedPath(const BString& path, bool implicit)
59 {
60 	fLocatedPath = path;
61 	fState = implicit
62 		? LOCATABLE_ENTRY_LOCATED_IMPLICITLY
63 		: LOCATABLE_ENTRY_LOCATED_EXPLICITLY;
64 }
65 
66 
67 void
68 LocatableDirectory::AddEntry(LocatableEntry* entry)
69 {
70 	fEntries.Add(entry);
71 }
72 
73 
74 void
75 LocatableDirectory::RemoveEntry(LocatableEntry* entry)
76 {
77 	fEntries.Remove(entry);
78 }
79