2 * Copyright 2008 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Axel Dörfler, axeld@pinc-software.de
17 struct PathList::path_entry
{
18 path_entry(const char* _path
)
48 PathList::HasPath(const char* path
, int32
* _index
) const
50 for (int32 i
= fPaths
.CountItems(); i
-- > 0;) {
51 if (!strcmp(fPaths
.ItemAt(i
)->path
, path
)) {
63 PathList::AddPath(const char* path
)
69 if (HasPath(path
, &index
)) {
70 fPaths
.ItemAt(index
)->ref_count
++;
74 path_entry
* entry
= new(std::nothrow
) path_entry(path
);
75 if (entry
== NULL
|| entry
->path
== NULL
|| !fPaths
.AddItem(entry
)) {
85 PathList::RemovePath(const char* path
)
88 if (!HasPath(path
, &index
))
89 return B_ENTRY_NOT_FOUND
;
91 if (--fPaths
.ItemAt(index
)->ref_count
== 0)
92 delete fPaths
.RemoveItemAt(index
);
99 PathList::CountPaths() const
101 return fPaths
.CountItems();
106 PathList::PathAt(int32 index
) const
108 path_entry
* entry
= fPaths
.ItemAt(index
);