51 lines
882 B
C++
51 lines
882 B
C++
#pragma once
|
|
#include <dirent.h>
|
|
#include <luna/SharedPtr.h>
|
|
#include <luna/String.h>
|
|
#include <luna/Vector.h>
|
|
#include <os/Path.h>
|
|
|
|
namespace os
|
|
{
|
|
class Directory
|
|
{
|
|
public:
|
|
static Result<SharedPtr<Directory>> open(const Path& path);
|
|
|
|
enum class Filter
|
|
{
|
|
None,
|
|
Hidden,
|
|
ParentAndBase
|
|
};
|
|
|
|
Result<String> next(Filter filter);
|
|
|
|
Result<Vector<String>> list_names(Filter filter);
|
|
|
|
struct Entry
|
|
{
|
|
String name;
|
|
mode_t mode;
|
|
usize size;
|
|
time_t mtime;
|
|
};
|
|
|
|
Result<Vector<Entry>> list(Filter filter);
|
|
|
|
void rewind();
|
|
|
|
int fd()
|
|
{
|
|
return dirfd(m_dirp);
|
|
}
|
|
|
|
~Directory();
|
|
|
|
private:
|
|
Directory(Badge<Directory>);
|
|
|
|
DIR* m_dirp { nullptr };
|
|
};
|
|
}
|