[ox] Update more C strings to StringViews
This commit is contained in:
		
							
								
								
									
										12
									
								
								deps/ox/src/ox/clargs/clargs.cpp
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										12
									
								
								deps/ox/src/ox/clargs/clargs.cpp
									
									
									
									
										vendored
									
									
								
							| @@ -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<bool> ClArgs::getBool(const char *arg) const noexcept { | ||||
| Result<bool> ClArgs::getBool(ox::CRStringView arg) const noexcept { | ||||
| 	oxRequire(out, m_bools.at(arg)); | ||||
| 	return *out; | ||||
| } | ||||
|  | ||||
| Result<String> ClArgs::getString(const char *argName) const noexcept { | ||||
| Result<String> ClArgs::getString(ox::CRStringView argName) const noexcept { | ||||
| 	oxRequire(out, m_strings.at(argName)); | ||||
| 	return *out; | ||||
| } | ||||
|  | ||||
| Result<int> ClArgs::getInt(const char *arg) const noexcept { | ||||
| Result<int> ClArgs::getInt(ox::CRStringView arg) const noexcept { | ||||
| 	oxRequire(out, m_ints.at(arg)); | ||||
| 	return *out; | ||||
| } | ||||
|   | ||||
							
								
								
									
										15
									
								
								deps/ox/src/ox/clargs/clargs.hpp
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										15
									
								
								deps/ox/src/ox/clargs/clargs.hpp
									
									
									
									
										vendored
									
									
								
							| @@ -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<bool> getBool(const char *arg) const noexcept; | ||||
| 		Result<bool> getBool(ox::CRStringView arg) const noexcept; | ||||
|  | ||||
| 		Result<String> getString(const char *argName) const noexcept; | ||||
| 		Result<String> getString(ox::CRStringView argName) const noexcept; | ||||
|  | ||||
| 		Result<int> getInt(const char *arg) const noexcept; | ||||
| 		Result<int> getInt(ox::CRStringView arg) const noexcept; | ||||
|  | ||||
| }; | ||||
|  | ||||
|   | ||||
							
								
								
									
										24
									
								
								deps/ox/src/ox/fs/filesystem/directory.hpp
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										24
									
								
								deps/ox/src/ox/fs/filesystem/directory.hpp
									
									
									
									
										vendored
									
									
								
							| @@ -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); | ||||
|   | ||||
| @@ -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<const char*>(u8p.c_str())); | ||||
| 	if (recursive) { | ||||
| 		std::error_code ec; | ||||
| 		const auto isDir = std::filesystem::is_directory(p, ec); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user