xref: /haiku/src/kits/debugger/files/LocatableDirectory.cpp (revision ed24eb5ff12640d052171c6a7feba37fab8a75d1)
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 	if (fPath.Length() <= 1)
28 		return fPath;
29 
30 	int32 lastSlash = fPath.FindLast('/');
31 		// return -1, if not found
32 	return fPath.String() + (lastSlash + 1);
33 }
34 
35 
36 const char*
37 LocatableDirectory::Path() const
38 {
39 	return fPath.String();
40 }
41 
42 
43 void
44 LocatableDirectory::GetPath(BString& _path) const
45 {
46 	_path = fPath;
47 }
48 
49 
50 bool
51 LocatableDirectory::GetLocatedPath(BString& _path) const
52 {
53 	if (fLocatedPath.Length() == 0)
54 		return false;
55 	_path = fLocatedPath;
56 	return true;
57 }
58 
59 
60 void
61 LocatableDirectory::SetLocatedPath(const BString& path, bool implicit)
62 {
63 	fLocatedPath = path;
64 	fState = implicit
65 		? LOCATABLE_ENTRY_LOCATED_IMPLICITLY
66 		: LOCATABLE_ENTRY_LOCATED_EXPLICITLY;
67 }
68 
69 
70 void
71 LocatableDirectory::AddEntry(LocatableEntry* entry)
72 {
73 	fEntries.Add(entry);
74 }
75 
76 
77 void
78 LocatableDirectory::RemoveEntry(LocatableEntry* entry)
79 {
80 	fEntries.Remove(entry);
81 }
82