2013-11-20 18:59:46 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2020-08-12 06:04:20 +03:00
|
|
|
#ifndef KERNEL_BOOT_PATH_BLOCKLIST_H
|
|
|
|
#define KERNEL_BOOT_PATH_BLOCKLIST_H
|
2013-11-20 18:59:46 +04:00
|
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <util/SinglyLinkedList.h>
|
|
|
|
|
|
|
|
|
2020-08-12 06:04:20 +03:00
|
|
|
class BlockedPath : public SinglyLinkedListLinkImpl<BlockedPath> {
|
2013-11-20 18:59:46 +04:00
|
|
|
public:
|
2020-08-12 06:04:20 +03:00
|
|
|
BlockedPath();
|
|
|
|
~BlockedPath();
|
2013-11-20 18:59:46 +04:00
|
|
|
|
|
|
|
bool SetTo(const char* path);
|
|
|
|
|
|
|
|
bool Append(const char* component);
|
|
|
|
|
|
|
|
const char* Path() const
|
|
|
|
{ return fPath != NULL ? fPath : ""; }
|
|
|
|
|
|
|
|
size_t Length() const
|
|
|
|
{ return fLength; }
|
|
|
|
|
|
|
|
bool operator==(const char* path) const
|
|
|
|
{ return strcmp(Path(), path) == 0; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool _Resize(size_t length, bool keepData);
|
|
|
|
|
|
|
|
private:
|
|
|
|
char* fPath;
|
|
|
|
size_t fLength;
|
|
|
|
size_t fCapacity;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-08-12 06:04:20 +03:00
|
|
|
class PathBlocklist {
|
2013-11-20 18:59:46 +04:00
|
|
|
public:
|
2020-08-12 06:04:20 +03:00
|
|
|
typedef SinglyLinkedList<BlockedPath>::Iterator Iterator;
|
2013-11-20 18:59:46 +04:00
|
|
|
|
|
|
|
public:
|
2020-08-12 06:04:20 +03:00
|
|
|
PathBlocklist();
|
|
|
|
~PathBlocklist();
|
2013-11-20 18:59:46 +04:00
|
|
|
|
|
|
|
bool Add(const char* path);
|
|
|
|
void Remove(const char* path);
|
|
|
|
bool Contains(const char* path) const;
|
|
|
|
void MakeEmpty();
|
|
|
|
|
|
|
|
bool IsEmpty() const
|
|
|
|
{ return fPaths.IsEmpty(); }
|
|
|
|
|
|
|
|
Iterator GetIterator() const
|
|
|
|
{ return fPaths.GetIterator(); }
|
|
|
|
|
|
|
|
private:
|
2020-08-12 06:04:20 +03:00
|
|
|
BlockedPath* _FindPath(const char* path) const;
|
2013-11-20 18:59:46 +04:00
|
|
|
|
|
|
|
private:
|
2020-08-12 06:04:20 +03:00
|
|
|
typedef SinglyLinkedList<BlockedPath> PathList;
|
2013-11-20 18:59:46 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
PathList fPaths;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-08-12 06:04:20 +03:00
|
|
|
#endif // KERNEL_BOOT_PATH_BLOCKLIST_H
|