Luna/libos/include/os/Directory.h
apio ac4bbd135b
All checks were successful
continuous-integration/drone/push Build is passing
libos: Add Directory::list()
2023-04-28 22:41:44 +02:00

42 lines
740 B
C++

#pragma once
#include <dirent.h>
#include <luna/SharedPtr.h>
#include <luna/String.h>
#include <luna/Vector.h>
namespace os
{
class Directory
{
public:
static Result<SharedPtr<Directory>> open(StringView path);
static Result<SharedPtr<Directory>> openat(int dirfd, StringView path);
enum class Filter
{
None,
Hidden,
ParentAndBase
};
Result<String> next(Filter filter);
Result<Vector<String>> list(Filter filter);
void rewind();
int fd()
{
return dirfd(m_dirp);
}
~Directory();
private:
Directory(Badge<Directory>);
DIR* m_dirp { nullptr };
};
}