diff --git a/deps/ox/src/ox/clargs/clargs.cpp b/deps/ox/src/ox/clargs/clargs.cpp index a8c3a03e..0cbb8405 100644 --- a/deps/ox/src/ox/clargs/clargs.cpp +++ b/deps/ox/src/ox/clargs/clargs.cpp @@ -37,32 +37,32 @@ ClArgs::ClArgs(int argc, const char **args) noexcept { } } -bool ClArgs::getBool(const char *arg, bool defaultValue) const noexcept { +bool ClArgs::getBool(ox::CRStringView arg, bool defaultValue) const noexcept { auto [value, err] = m_ints.at(arg); return !err ? *value : defaultValue; } -String ClArgs::getString(const char *arg, const char *defaultValue) const noexcept { +String ClArgs::getString(ox::CRStringView arg, const char *defaultValue) const noexcept { auto [value, err] = m_strings.at(arg); return !err ? *value : defaultValue; } -int ClArgs::getInt(const char *arg, int defaultValue) const noexcept { +int ClArgs::getInt(ox::CRStringView arg, int defaultValue) const noexcept { auto [value, err] = m_ints.at(arg); return !err ? *value : defaultValue; } -Result ClArgs::getBool(const char *arg) const noexcept { +Result ClArgs::getBool(ox::CRStringView arg) const noexcept { oxRequire(out, m_bools.at(arg)); return *out; } -Result ClArgs::getString(const char *argName) const noexcept { +Result ClArgs::getString(ox::CRStringView argName) const noexcept { oxRequire(out, m_strings.at(argName)); return *out; } -Result ClArgs::getInt(const char *arg) const noexcept { +Result ClArgs::getInt(ox::CRStringView arg) const noexcept { oxRequire(out, m_ints.at(arg)); return *out; } diff --git a/deps/ox/src/ox/clargs/clargs.hpp b/deps/ox/src/ox/clargs/clargs.hpp index 56b4ada7..23e43e15 100644 --- a/deps/ox/src/ox/clargs/clargs.hpp +++ b/deps/ox/src/ox/clargs/clargs.hpp @@ -22,17 +22,20 @@ class ClArgs { public: ClArgs(int argc, const char **args) noexcept; - bool getBool(const char *arg, bool defaultValue) const noexcept; + [[nodiscard]] + bool getBool(ox::CRStringView arg, bool defaultValue) const noexcept; - String getString(const char *argName, const char *defaultArg) const noexcept; + [[nodiscard]] + String getString(ox::CRStringView argName, const char *defaultArg) const noexcept; - int getInt(const char *arg, int defaultValue) const noexcept; + [[nodiscard]] + int getInt(ox::CRStringView arg, int defaultValue) const noexcept; - Result getBool(const char *arg) const noexcept; + Result getBool(ox::CRStringView arg) const noexcept; - Result getString(const char *argName) const noexcept; + Result getString(ox::CRStringView argName) const noexcept; - Result getInt(const char *arg) const noexcept; + Result getInt(ox::CRStringView arg) const noexcept; }; diff --git a/deps/ox/src/ox/fs/filesystem/directory.hpp b/deps/ox/src/ox/fs/filesystem/directory.hpp index 427e0f11..e6693c0f 100644 --- a/deps/ox/src/ox/fs/filesystem/directory.hpp +++ b/deps/ox/src/ox/fs/filesystem/directory.hpp @@ -158,7 +158,7 @@ Error Directory::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::mkdir(PathIterator path, bool parents, Fi Directory 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::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::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(); 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::ls(F cb) noexcept { template Result Directory::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(); if (!buff.valid()) { oxTrace("ox::fs::Directory::findEntry::fail", "Could not findEntry directory buffer"); @@ -318,9 +318,9 @@ Result Directory::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(data->inode); } } else { @@ -342,7 +342,7 @@ Result Directory::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); diff --git a/deps/ox/src/ox/fs/filesystem/passthroughfs.cpp b/deps/ox/src/ox/fs/filesystem/passthroughfs.cpp index caa3d515..fa5b7e39 100644 --- a/deps/ox/src/ox/fs/filesystem/passthroughfs.cpp +++ b/deps/ox/src/ox/fs/filesystem/passthroughfs.cpp @@ -31,7 +31,7 @@ Error PassThroughFS::mkdir(CRStringView path, bool recursive) noexcept { bool success = false; const auto p = m_path / stripSlash(path); const auto u8p = p.u8string(); - oxTrace("ox::fs::PassThroughFS::mkdir", u8p.c_str()); + oxTrace("ox::fs::PassThroughFS::mkdir", std::bit_cast(u8p.c_str())); if (recursive) { std::error_code ec; const auto isDir = std::filesystem::is_directory(p, ec);