2023-03-10 21:17:03 +00:00
|
|
|
#pragma once
|
|
|
|
#include <luna/CString.h>
|
|
|
|
#include <luna/Heap.h>
|
2023-03-29 15:28:22 +00:00
|
|
|
#include <luna/String.h>
|
2023-03-10 21:17:03 +00:00
|
|
|
|
|
|
|
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 == '/';
|
|
|
|
}
|
|
|
|
|
2023-03-29 15:28:22 +00:00
|
|
|
Result<String> basename();
|
|
|
|
Result<String> dirname();
|
2023-03-11 00:13:44 +00:00
|
|
|
|
2023-03-10 21:17:03 +00:00
|
|
|
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 };
|
|
|
|
};
|