1/*
2 * Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef KERNEL_BOOT_PATH_BLOCKLIST_H
6#define KERNEL_BOOT_PATH_BLOCKLIST_H
7
8
9#include <string.h>
10
11#include <util/SinglyLinkedList.h>
12
13
14class BlockedPath : public SinglyLinkedListLinkImpl<BlockedPath> {
15public:
16								BlockedPath();
17								~BlockedPath();
18
19			bool				SetTo(const char* path);
20
21			bool				Append(const char* component);
22
23			const char*			Path() const
24									{ return fPath != NULL ? fPath : ""; }
25
26			size_t				Length() const
27									{ return fLength; }
28
29			bool				operator==(const char* path) const
30									{ return strcmp(Path(), path) == 0; }
31
32private:
33			bool				_Resize(size_t length, bool keepData);
34
35private:
36			char*				fPath;
37			size_t				fLength;
38			size_t				fCapacity;
39};
40
41
42class PathBlocklist {
43public:
44			typedef SinglyLinkedList<BlockedPath>::Iterator Iterator;
45
46public:
47								PathBlocklist();
48								~PathBlocklist();
49
50			bool				Add(const char* path);
51			void				Remove(const char* path);
52			bool				Contains(const char* path) const;
53			void				MakeEmpty();
54
55			bool				IsEmpty() const
56									{ return fPaths.IsEmpty(); }
57
58			Iterator			GetIterator() const
59									{ return fPaths.GetIterator(); }
60
61private:
62			BlockedPath*	_FindPath(const char* path) const;
63
64private:
65			typedef SinglyLinkedList<BlockedPath> PathList;
66
67private:
68			PathList			fPaths;
69};
70
71
72#endif	// KERNEL_BOOT_PATH_BLOCKLIST_H
73