37 lines
678 B
C
37 lines
678 B
C
|
#pragma once
|
||
|
#include <fcntl.h>
|
||
|
#include <luna/StringView.h>
|
||
|
|
||
|
namespace os
|
||
|
{
|
||
|
class Path
|
||
|
{
|
||
|
public:
|
||
|
Path(const char* path);
|
||
|
Path(StringView path);
|
||
|
Path(int fd);
|
||
|
Path(int dirfd, StringView name);
|
||
|
|
||
|
int dirfd() const
|
||
|
{
|
||
|
return m_dirfd.value_or(AT_FDCWD);
|
||
|
}
|
||
|
|
||
|
StringView name() const
|
||
|
{
|
||
|
return m_name.value_or(""_sv);
|
||
|
}
|
||
|
|
||
|
int is_empty_path() const
|
||
|
{
|
||
|
if (m_dirfd.has_value() && !m_name.has_value()) return AT_EMPTY_PATH;
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
private:
|
||
|
Option<int> m_dirfd;
|
||
|
Option<StringView> m_name;
|
||
|
};
|
||
|
}
|