33 lines
651 B
C++
33 lines
651 B
C++
#pragma once
|
|
#include <luna/CString.h>
|
|
#include <luna/Heap.h>
|
|
#include <luna/OwnedStringView.h>
|
|
|
|
class PathParser
|
|
{
|
|
public:
|
|
static Result<PathParser> create(const char* path);
|
|
|
|
PathParser(PathParser&& other);
|
|
PathParser(const PathParser&) = delete;
|
|
|
|
~PathParser();
|
|
|
|
bool is_absolute() const
|
|
{
|
|
return *m_original == '/';
|
|
}
|
|
|
|
Result<OwnedStringView> basename();
|
|
Result<OwnedStringView> dirname();
|
|
|
|
Option<const char*> next();
|
|
|
|
private:
|
|
PathParser(const char* original, char* copy);
|
|
|
|
const char* m_original { nullptr };
|
|
char* m_copy { nullptr };
|
|
bool m_already_called_next { false };
|
|
};
|