[ox/fs] Strip leading slashes in PassThroughFS paths

This commit is contained in:
2019-01-15 22:01:30 -06:00
parent ec6326001d
commit 791c076b51
3 changed files with 42 additions and 15 deletions

View File

@ -24,8 +24,6 @@ class PassThroughFS: public FileSystem {
std::filesystem::path m_path;
public:
PassThroughFS() = default;
PassThroughFS(const char *dirPath);
~PassThroughFS();
@ -67,11 +65,22 @@ class PassThroughFS: public FileSystem {
bool valid() const override;
private:
/**
* Strips the leading slashes from a string.
*/
const char *stripSlash(const char *path);
};
template<typename F>
Error PassThroughFS::ls(const char *dir, F cb) {
return OxError(1);
for (auto &p : std::filesystem::directory_iterator(m_path / stripSlash(dir))) {
if (auto err = cb(p.path().filename().c_str(), 0); err) {
return err;
}
}
return OxError(0);
}
}