[ox] Change macro names to comply with broader conventions
This commit is contained in:
32
deps/ox/src/ox/fs/filesystem/directory.hpp
vendored
32
deps/ox/src/ox/fs/filesystem/directory.hpp
vendored
@ -141,7 +141,7 @@ template<typename FileStore, typename InodeId_t>
|
||||
Error Directory<FileStore, InodeId_t>::init() noexcept {
|
||||
constexpr auto Size = sizeof(Buffer);
|
||||
oxTracef("ox.fs.Directory.init", "Initializing Directory with Inode ID: {}", m_inodeId);
|
||||
oxReturnError(m_fs.write(m_inodeId, nullptr, Size, static_cast<uint8_t>(FileType::Directory)));
|
||||
OX_RETURN_ERROR(m_fs.write(m_inodeId, nullptr, Size, static_cast<uint8_t>(FileType::Directory)));
|
||||
auto buff = m_fs.read(m_inodeId).template to<Buffer>();
|
||||
if (!buff.valid()) {
|
||||
m_size = 0;
|
||||
@ -158,7 +158,7 @@ Error Directory<FileStore, InodeId_t>::mkdir(PathIterator path, bool parents) {
|
||||
oxTrace("ox.fs.Directory.mkdir", path.fullPath());
|
||||
// determine if already exists
|
||||
ox::StringView name;
|
||||
oxReturnError(path.get(name));
|
||||
OX_RETURN_ERROR(path.get(name));
|
||||
auto childInode = find(PathIterator(name));
|
||||
if (!childInode.ok()) {
|
||||
// if this is not the last item in the path and parents is disabled,
|
||||
@ -169,10 +169,10 @@ Error Directory<FileStore, InodeId_t>::mkdir(PathIterator path, bool parents) {
|
||||
childInode = m_fs.generateInodeId();
|
||||
oxTracef("ox.fs.Directory.mkdir", "Generated Inode ID: {}", childInode.value);
|
||||
oxLogError(childInode.error);
|
||||
oxReturnError(childInode.error);
|
||||
OX_RETURN_ERROR(childInode.error);
|
||||
// initialize the directory
|
||||
Directory<FileStore, InodeId_t> child(m_fs, childInode.value);
|
||||
oxReturnError(child.init());
|
||||
OX_RETURN_ERROR(child.init());
|
||||
auto err = write(PathIterator(name), childInode.value);
|
||||
if (err) {
|
||||
oxLogError(err);
|
||||
@ -183,7 +183,7 @@ Error Directory<FileStore, InodeId_t>::mkdir(PathIterator path, bool parents) {
|
||||
}
|
||||
Directory<FileStore, InodeId_t> child(m_fs, childInode.value);
|
||||
if (path.hasNext()) {
|
||||
oxReturnError(child.mkdir(path.next(), parents));
|
||||
OX_RETURN_ERROR(child.mkdir(path.next(), parents));
|
||||
}
|
||||
}
|
||||
return {};
|
||||
@ -196,8 +196,8 @@ Error Directory<FileStore, InodeId_t>::write(PathIterator path, uint64_t inode64
|
||||
if (path.next().hasNext()) { // not yet at target directory, recurse to next one
|
||||
oxTracef("ox.fs.Directory.write", "Attempting to write to next sub-Directory: {} of {}",
|
||||
name, path.fullPath());
|
||||
oxReturnError(path.get(name));
|
||||
oxRequire(nextChild, findEntry(name));
|
||||
OX_RETURN_ERROR(path.get(name));
|
||||
OX_REQUIRE(nextChild, findEntry(name));
|
||||
oxTracef("ox.fs.Directory.write", "{}: {}", name, nextChild);
|
||||
if (nextChild) {
|
||||
return Directory(m_fs, nextChild).write(path.next(), inode);
|
||||
@ -207,12 +207,12 @@ Error Directory<FileStore, InodeId_t>::write(PathIterator path, uint64_t inode64
|
||||
}
|
||||
} else {
|
||||
oxTrace("ox.fs.Directory.write", path.fullPath());
|
||||
oxReturnError(path.next(name));
|
||||
OX_RETURN_ERROR(path.next(name));
|
||||
// insert the new entry on this directory
|
||||
// get the name
|
||||
// find existing version of directory
|
||||
oxTracef("ox.fs.Directory.write", "Searching for directory inode {}", m_inodeId);
|
||||
oxRequire(oldStat, m_fs.stat(m_inodeId));
|
||||
OX_REQUIRE(oldStat, m_fs.stat(m_inodeId));
|
||||
oxTracef("ox.fs.Directory.write", "Found existing directory of size {}", oldStat.size);
|
||||
auto old = m_fs.read(m_inodeId).template to<Buffer>();
|
||||
if (!old.valid()) {
|
||||
@ -227,14 +227,14 @@ Error Directory<FileStore, InodeId_t>::write(PathIterator path, uint64_t inode64
|
||||
oxTrace("ox.fs.Directory.write.fail", "Could not allocate memory for copy of Directory");
|
||||
return ox::Error(1, "Could not allocate memory for copy of Directory");
|
||||
}
|
||||
oxReturnError(cpy->setSize(newSize));
|
||||
OX_RETURN_ERROR(cpy->setSize(newSize));
|
||||
auto val = cpy->malloc(entryDataSize).value;
|
||||
if (!val.valid()) {
|
||||
oxTrace("ox.fs.Directory.write.fail", "Could not allocate memory for new directory entry");
|
||||
return ox::Error(1, "Could not allocate memory for new directory entry");
|
||||
}
|
||||
oxTracef("ox.fs.Directory.write", "Attempting to write Directory entry: {}", name);
|
||||
oxReturnError(val->init(inode, name, val.size()));
|
||||
OX_RETURN_ERROR(val->init(inode, name, val.size()));
|
||||
return m_fs.write(m_inodeId, cpy.get(), cpy->size(), static_cast<uint8_t>(FileType::Directory));
|
||||
}
|
||||
}
|
||||
@ -242,7 +242,7 @@ Error Directory<FileStore, InodeId_t>::write(PathIterator path, uint64_t inode64
|
||||
template<typename FileStore, typename InodeId_t>
|
||||
Error Directory<FileStore, InodeId_t>::remove(PathIterator path) noexcept {
|
||||
ox::StringView name;
|
||||
oxReturnError(path.get(name));
|
||||
OX_RETURN_ERROR(path.get(name));
|
||||
oxTrace("ox.fs.Directory.remove", name);
|
||||
auto buff = m_fs.read(m_inodeId).template to<Buffer>();
|
||||
if (buff.valid()) {
|
||||
@ -251,7 +251,7 @@ Error Directory<FileStore, InodeId_t>::remove(PathIterator path) noexcept {
|
||||
auto data = i->data();
|
||||
if (data.valid()) {
|
||||
if (name == data->name) {
|
||||
oxReturnError(buff->free(i));
|
||||
OX_RETURN_ERROR(buff->free(i));
|
||||
}
|
||||
} else {
|
||||
oxTrace("ox.fs.Directory.remove", "INVALID DIRECTORY ENTRY");
|
||||
@ -277,7 +277,7 @@ Error Directory<FileStore, InodeId_t>::ls(F cb) noexcept {
|
||||
for (auto i = buff->iterator(); i.valid(); i.next()) {
|
||||
auto data = i->data();
|
||||
if (data.valid()) {
|
||||
oxReturnError(cb(data->name, data->inode));
|
||||
OX_RETURN_ERROR(cb(data->name, data->inode));
|
||||
} else {
|
||||
oxTrace("ox.fs.Directory.ls", "INVALID DIRECTORY ENTRY");
|
||||
}
|
||||
@ -314,8 +314,8 @@ template<typename FileStore, typename InodeId_t>
|
||||
Result<typename FileStore::InodeId_t> Directory<FileStore, InodeId_t>::find(PathIterator path) const noexcept {
|
||||
// determine if already exists
|
||||
ox::StringView name;
|
||||
oxReturnError(path.get(name));
|
||||
oxRequire(v, findEntry(name));
|
||||
OX_RETURN_ERROR(path.get(name));
|
||||
OX_REQUIRE(v, findEntry(name));
|
||||
// recurse if not at end of path
|
||||
if (auto p = path.next(); p.valid()) {
|
||||
Directory dir(m_fs, v);
|
||||
|
Reference in New Issue
Block a user