[ox] Update more C strings to StringViews

This commit is contained in:
2023-01-03 03:31:22 -06:00
parent 5508dc5dc0
commit 3cd638737a
4 changed files with 28 additions and 25 deletions

View File

@ -158,7 +158,7 @@ Error Directory<FileStore, InodeId_t>::mkdir(PathIterator path, bool parents, Fi
// determine if already exists
auto name = nameBuff;
oxReturnError(path.get(name));
auto childInode = find(name->c_str());
auto childInode = find(PathIterator(*name));
if (!childInode.ok()) {
// if this is not the last item in the path and parents is disabled,
// return an error
@ -174,7 +174,7 @@ Error Directory<FileStore, InodeId_t>::mkdir(PathIterator path, bool parents, Fi
Directory<FileStore, InodeId_t> child(m_fs, childInode.value);
oxReturnError(child.init());
auto err = write(name->c_str(), childInode.value);
auto err = write(PathIterator(*name), childInode.value);
if (err) {
oxLogError(err);
// could not index the directory, delete it
@ -202,16 +202,16 @@ Error Directory<FileStore, InodeId_t>::write(PathIterator path, InodeId_t inode,
if (path.next().hasNext()) { // not yet at target directory, recurse to next one
oxReturnError(path.get(name));
oxTracef("ox::fs::Directory::write", "Attempting to write to next sub-Directory: {} of {}",
name->c_str(), path.fullPath());
*name, path.fullPath());
oxRequire(nextChild, findEntry(*name));
oxTracef("ox::fs::Directory::write", "{}: {}", name->c_str(), nextChild);
oxTracef("ox::fs::Directory::write", "{}: {}", *name, nextChild);
if (nextChild) {
// reuse name because it is a rather large variable and will not be used again
// be attentive that this remains true
name = nullptr;
return Directory(m_fs, nextChild).write(path.next(), inode, nameBuff);
} else {
oxTracef("ox::fs::Directory::write", "{} not found and not allowed to create it.", name->c_str());
oxTracef("ox::fs::Directory::write", "{} not found and not allowed to create it.", *name);
return OxError(1, "File not found and not allowed to create it.");
}
} else {
@ -262,14 +262,14 @@ Error Directory<FileStore, InodeId_t>::remove(PathIterator path, FileName *nameB
auto &name = *nameBuff;
oxReturnError(path.get(&name));
oxTrace("ox::fs::Directory::remove", name.c_str());
oxTrace("ox::fs::Directory::remove", name);
auto buff = m_fs.read(m_inodeId).template to<Buffer>();
if (buff.valid()) {
oxTrace("ox::fs::Directory::remove", "Found directory buffer.");
for (auto i = buff->iterator(); i.valid(); i.next()) {
auto data = i->data();
if (data.valid()) {
if (ox_strncmp(data->name, name.c_str(), name.len()) == 0) {
if (data->name == name) {
oxReturnError(buff->free(i));
}
} else {
@ -308,7 +308,7 @@ Error Directory<FileStore, InodeId_t>::ls(F cb) noexcept {
template<typename FileStore, typename InodeId_t>
Result<typename FileStore::InodeId_t> Directory<FileStore, InodeId_t>::findEntry(const FileName &name) const noexcept {
oxTrace("ox::fs::Directory::findEntry", name.c_str());
oxTrace("ox::fs::Directory::findEntry", name);
auto buff = m_fs.read(m_inodeId).template to<Buffer>();
if (!buff.valid()) {
oxTrace("ox::fs::Directory::findEntry::fail", "Could not findEntry directory buffer");
@ -318,9 +318,9 @@ Result<typename FileStore::InodeId_t> Directory<FileStore, InodeId_t>::findEntry
for (auto i = buff->iterator(); i.valid(); i.next()) {
auto data = i->data();
if (data.valid()) {
oxTracef("ox::fs::Directory::findEntry", "Comparing \"{}\" to \"{}\"", name.c_str(), data->name);
if (ox_strncmp(data->name, name.c_str(), MaxFileNameLength) == 0) {
oxTracef("ox::fs::Directory::findEntry", "\"{}\" match found.", name.c_str());
oxTracef("ox::fs::Directory::findEntry", "Comparing \"{}\" to \"{}\"", name, data->name);
if (data->name == name) {
oxTracef("ox::fs::Directory::findEntry", "\"{}\" match found.", name);
return static_cast<InodeId_t>(data->inode);
}
} else {
@ -342,7 +342,7 @@ Result<typename FileStore::InodeId_t> Directory<FileStore, InodeId_t>::find(Path
auto name = nameBuff;
oxReturnError(path.get(name));
oxRequire(v, findEntry(name->c_str()));
oxRequire(v, findEntry(*name));
// recurse if not at end of path
if (auto p = path.next(); p.valid()) {
Directory dir(m_fs, v);