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
9LocatableDirectory::LocatableDirectory(LocatableEntryOwner* owner,
10	LocatableDirectory* parent, const BString& path)
11	:
12	LocatableEntry(owner, parent),
13	fPath(path),
14	fLocatedPath()
15{
16}
17
18
19LocatableDirectory::~LocatableDirectory()
20{
21}
22
23
24const char*
25LocatableDirectory::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
36const char*
37LocatableDirectory::Path() const
38{
39	return fPath.String();
40}
41
42
43void
44LocatableDirectory::GetPath(BString& _path) const
45{
46	_path = fPath;
47}
48
49
50bool
51LocatableDirectory::GetLocatedPath(BString& _path) const
52{
53	if (fLocatedPath.Length() == 0)
54		return false;
55	_path = fLocatedPath;
56	return true;
57}
58
59
60void
61LocatableDirectory::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
70void
71LocatableDirectory::AddEntry(LocatableEntry* entry)
72{
73	fEntries.Add(entry);
74}
75
76
77void
78LocatableDirectory::RemoveEntry(LocatableEntry* entry)
79{
80	fEntries.Remove(entry);
81}
82