[ox] Change log channel delimiter from :: to .
This commit is contained in:
58
deps/ox/src/ox/fs/filesystem/directory.hpp
vendored
58
deps/ox/src/ox/fs/filesystem/directory.hpp
vendored
@@ -55,7 +55,7 @@ struct OX_PACKED DirectoryEntry {
|
||||
}
|
||||
|
||||
ptrarith::Ptr<DirectoryEntryData, InodeId_t> data() noexcept {
|
||||
oxTracef("ox::fs::DirectoryEntry::data", "{} {} {}", this->fullSize(), sizeof(*this), this->size());
|
||||
oxTracef("ox.fs.DirectoryEntry.data", "{} {} {}", this->fullSize(), sizeof(*this), this->size());
|
||||
return ptrarith::Ptr<DirectoryEntryData, InodeId_t>(this, this->fullSize(), sizeof(*this), this->size(), this->size());
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ Directory<FileStore, InodeId_t>::Directory(FileStore fs, uint64_t inodeId) noexc
|
||||
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);
|
||||
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)));
|
||||
auto buff = m_fs.read(m_inodeId).template to<Buffer>();
|
||||
if (!buff.valid()) {
|
||||
@@ -151,7 +151,7 @@ Error Directory<FileStore, InodeId_t>::init() noexcept {
|
||||
template<typename FileStore, typename InodeId_t>
|
||||
Error Directory<FileStore, InodeId_t>::mkdir(PathIterator path, bool parents, FileName *nameBuff) {
|
||||
if (path.valid()) {
|
||||
oxTrace("ox::fs::Directory::mkdir", path.fullPath());
|
||||
oxTrace("ox.fs.Directory.mkdir", path.fullPath());
|
||||
// reuse nameBuff if it has already been allocated, as it is a rather large variable
|
||||
if (nameBuff == nullptr) {
|
||||
nameBuff = new (ox_alloca(sizeof(FileName))) FileName;
|
||||
@@ -168,7 +168,7 @@ Error Directory<FileStore, InodeId_t>::mkdir(PathIterator path, bool parents, Fi
|
||||
return OxError(1);
|
||||
}
|
||||
childInode = m_fs.generateInodeId();
|
||||
oxTracef("ox::fs::Directory::mkdir", "Generated Inode ID: {}", childInode.value);
|
||||
oxTracef("ox.fs.Directory.mkdir", "Generated Inode ID: {}", childInode.value);
|
||||
oxLogError(childInode.error);
|
||||
oxReturnError(childInode.error);
|
||||
|
||||
@@ -204,33 +204,33 @@ Error Directory<FileStore, InodeId_t>::write(PathIterator path, uint64_t inode64
|
||||
|
||||
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 {}",
|
||||
oxTracef("ox.fs.Directory.write", "Attempting to write to next sub-Directory: {} of {}",
|
||||
*name, path.fullPath());
|
||||
oxRequire(nextChild, findEntry(*name));
|
||||
oxTracef("ox::fs::Directory::write", "{}: {}", *name, 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);
|
||||
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 {
|
||||
oxTrace("ox::fs::Directory::write", path.fullPath());
|
||||
oxTrace("ox.fs.Directory.write", path.fullPath());
|
||||
// insert the new entry on this directory
|
||||
|
||||
// get the name
|
||||
oxReturnError(path.next(name));
|
||||
|
||||
// find existing version of directory
|
||||
oxTracef("ox::fs::Directory::write", "Searching for directory inode {}", m_inodeId);
|
||||
oxTracef("ox.fs.Directory.write", "Searching for directory inode {}", m_inodeId);
|
||||
oxRequire(oldStat, m_fs.stat(m_inodeId));
|
||||
oxTracef("ox::fs::Directory::write", "Found existing directory of size {}", oldStat.size);
|
||||
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()) {
|
||||
oxTrace("ox::fs::Directory::write::fail", "Could not read existing version of Directory");
|
||||
oxTrace("ox.fs.Directory.write.fail", "Could not read existing version of Directory");
|
||||
return OxError(1, "Could not read existing version of Directory");
|
||||
}
|
||||
|
||||
@@ -239,18 +239,18 @@ Error Directory<FileStore, InodeId_t>::write(PathIterator path, uint64_t inode64
|
||||
const auto newSize = oldStat.size + Buffer::spaceNeeded(entryDataSize);
|
||||
auto cpy = ox_malloca(newSize, Buffer, *old, oldStat.size);
|
||||
if (cpy == nullptr) {
|
||||
oxTrace("ox::fs::Directory::write::fail", "Could not allocate memory for copy of Directory");
|
||||
oxTrace("ox.fs.Directory.write.fail", "Could not allocate memory for copy of Directory");
|
||||
return OxError(1, "Could not allocate memory for copy of Directory");
|
||||
}
|
||||
|
||||
oxReturnError(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");
|
||||
oxTrace("ox.fs.Directory.write.fail", "Could not allocate memory for new directory entry");
|
||||
return OxError(1, "Could not allocate memory for new directory entry");
|
||||
}
|
||||
|
||||
oxTracef("ox::fs::Directory::write", "Attempting to write Directory entry: {}", name->data());
|
||||
oxTracef("ox.fs.Directory.write", "Attempting to write Directory entry: {}", name->data());
|
||||
oxReturnError(val->init(inode, name->data(), val.size()));
|
||||
return m_fs.write(m_inodeId, cpy.get(), cpy->size(), static_cast<uint8_t>(FileType::Directory));
|
||||
}
|
||||
@@ -265,10 +265,10 @@ Error Directory<FileStore, InodeId_t>::remove(PathIterator path, FileName *nameB
|
||||
auto &name = *nameBuff;
|
||||
oxReturnError(path.get(&name));
|
||||
|
||||
oxTrace("ox::fs::Directory::remove", name);
|
||||
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.");
|
||||
oxTrace("ox.fs.Directory.remove", "Found directory buffer.");
|
||||
for (auto i = buff->iterator(); i.valid(); i.next()) {
|
||||
auto data = i->data();
|
||||
if (data.valid()) {
|
||||
@@ -276,11 +276,11 @@ Error Directory<FileStore, InodeId_t>::remove(PathIterator path, FileName *nameB
|
||||
oxReturnError(buff->free(i));
|
||||
}
|
||||
} else {
|
||||
oxTrace("ox::fs::Directory::remove", "INVALID DIRECTORY ENTRY");
|
||||
oxTrace("ox.fs.Directory.remove", "INVALID DIRECTORY ENTRY");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
oxTrace("ox::fs::Directory::remove::fail", "Could not find directory buffer");
|
||||
oxTrace("ox.fs.Directory.remove.fail", "Could not find directory buffer");
|
||||
return OxError(1, "Could not find directory buffer");
|
||||
}
|
||||
return OxError(0);
|
||||
@@ -289,20 +289,20 @@ Error Directory<FileStore, InodeId_t>::remove(PathIterator path, FileName *nameB
|
||||
template<typename FileStore, typename InodeId_t>
|
||||
template<typename F>
|
||||
Error Directory<FileStore, InodeId_t>::ls(F cb) noexcept {
|
||||
oxTrace("ox::fs::Directory::ls");
|
||||
oxTrace("ox.fs.Directory.ls");
|
||||
auto buff = m_fs.read(m_inodeId).template to<Buffer>();
|
||||
if (!buff.valid()) {
|
||||
oxTrace("ox::fs::Directory::ls::fail", "Could not directory buffer");
|
||||
oxTrace("ox.fs.Directory.ls.fail", "Could not directory buffer");
|
||||
return OxError(1, "Could not directory buffer");
|
||||
}
|
||||
|
||||
oxTrace("ox::fs::Directory::ls", "Found directory buffer.");
|
||||
oxTrace("ox.fs.Directory.ls", "Found directory buffer.");
|
||||
for (auto i = buff->iterator(); i.valid(); i.next()) {
|
||||
auto data = i->data();
|
||||
if (data.valid()) {
|
||||
oxReturnError(cb(data->name, data->inode));
|
||||
} else {
|
||||
oxTrace("ox::fs::Directory::ls", "INVALID DIRECTORY ENTRY");
|
||||
oxTrace("ox.fs.Directory.ls", "INVALID DIRECTORY ENTRY");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -311,26 +311,26 @@ 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);
|
||||
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");
|
||||
oxTrace("ox.fs.Directory.findEntry.fail", "Could not findEntry directory buffer");
|
||||
return OxError(2, "Could not findEntry directory buffer");
|
||||
}
|
||||
oxTracef("ox::fs::Directory::findEntry", "Found directory buffer, size: {}", buff.size());
|
||||
oxTracef("ox.fs.Directory.findEntry", "Found directory buffer, size: {}", buff.size());
|
||||
for (auto i = buff->iterator(); i.valid(); i.next()) {
|
||||
auto data = i->data();
|
||||
if (data.valid()) {
|
||||
oxTracef("ox::fs::Directory::findEntry", "Comparing \"{}\" to \"{}\"", name, data->name);
|
||||
oxTracef("ox.fs.Directory.findEntry", "Comparing \"{}\" to \"{}\"", name, data->name);
|
||||
if (name == data->name) {
|
||||
oxTracef("ox::fs::Directory::findEntry", "\"{}\" match found.", name);
|
||||
oxTracef("ox.fs.Directory.findEntry", "\"{}\" match found.", name);
|
||||
return static_cast<InodeId_t>(data->inode);
|
||||
}
|
||||
} else {
|
||||
oxTrace("ox::fs::Directory::findEntry") << "INVALID DIRECTORY ENTRY";
|
||||
oxTrace("ox.fs.Directory.findEntry") << "INVALID DIRECTORY ENTRY";
|
||||
}
|
||||
}
|
||||
oxTrace("ox::fs::Directory::findEntry::fail", "Entry not present");
|
||||
oxTrace("ox.fs.Directory.findEntry.fail", "Entry not present");
|
||||
return OxError(1, "Entry not present");
|
||||
}
|
||||
|
||||
|
||||
10
deps/ox/src/ox/fs/filesystem/filesystem.hpp
vendored
10
deps/ox/src/ox/fs/filesystem/filesystem.hpp
vendored
@@ -269,11 +269,11 @@ Error FileSystemTemplate<FileStore, Directory>::format(void *buff, uint64_t buff
|
||||
|
||||
FileSystemData fd;
|
||||
fd.rootDirInode = rootDirInode;
|
||||
oxTracef("ox::fs::FileSystemTemplate::format", "rootDirInode: {}", fd.rootDirInode.get());
|
||||
oxTracef("ox.fs.FileSystemTemplate.format", "rootDirInode: {}", fd.rootDirInode.get());
|
||||
oxReturnError(fs.write(InodeFsData, &fd, sizeof(fd)));
|
||||
|
||||
if (!fs.read(fd.rootDirInode).valid()) {
|
||||
oxTrace("ox::fs::FileSystemTemplate::format::error", "FileSystemTemplate::format did not correctly create root directory");
|
||||
oxTrace("ox.fs.FileSystemTemplate.format.error", "FileSystemTemplate::format did not correctly create root directory");
|
||||
return OxError(1);
|
||||
}
|
||||
|
||||
@@ -282,7 +282,7 @@ Error FileSystemTemplate<FileStore, Directory>::format(void *buff, uint64_t buff
|
||||
|
||||
template<typename FileStore, typename Directory>
|
||||
Error FileSystemTemplate<FileStore, Directory>::mkdir(CRStringView path, bool recursive) noexcept {
|
||||
oxTracef("ox::fs::FileSystemTemplate::mkdir", "path: {}, recursive: {}", path, recursive);
|
||||
oxTracef("ox.fs.FileSystemTemplate.mkdir", "path: {}, recursive: {}", path, recursive);
|
||||
oxRequireM(rootDir, this->rootDir());
|
||||
return rootDir.mkdir(path, recursive);
|
||||
}
|
||||
@@ -352,7 +352,7 @@ Result<Vector<String>> FileSystemTemplate<FileStore, Directory>::ls(CRStringView
|
||||
template<typename FileStore, typename Directory>
|
||||
template<typename F>
|
||||
Error FileSystemTemplate<FileStore, Directory>::ls(CRStringView path, F cb) const {
|
||||
oxTracef("ox::fs::FileSystemTemplate::ls", "path: {}", path);
|
||||
oxTracef("ox.fs.FileSystemTemplate.ls", "path: {}", path);
|
||||
oxRequire(s, stat(path));
|
||||
Directory dir(m_fs, s.inode);
|
||||
return dir.ls(cb);
|
||||
@@ -371,7 +371,7 @@ Error FileSystemTemplate<FileStore, Directory>::remove(CRStringView path, bool r
|
||||
return err;
|
||||
}
|
||||
} else {
|
||||
oxTrace("FileSystemTemplate::remove::fail", "Tried to remove directory without recursive setting.");
|
||||
oxTrace("FileSystemTemplate.remove.fail", "Tried to remove directory without recursive setting.");
|
||||
return OxError(1);
|
||||
}
|
||||
return OxError(0);
|
||||
|
||||
14
deps/ox/src/ox/fs/filesystem/passthroughfs.cpp
vendored
14
deps/ox/src/ox/fs/filesystem/passthroughfs.cpp
vendored
@@ -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", std::bit_cast<const char*>(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);
|
||||
@@ -98,10 +98,10 @@ Result<FileStat> PassThroughFS::statPath(CRStringView path) const noexcept {
|
||||
const auto p = m_path / stripSlash(path);
|
||||
const FileType type = std::filesystem::is_directory(p, ec) ?
|
||||
FileType::Directory : FileType::NormalFile;
|
||||
oxTracef("ox::fs::PassThroughFS::statInode", "{} {}", ec.message(), path);
|
||||
oxTracef("ox.fs.PassThroughFS.statInode", "{} {}", ec.message(), path);
|
||||
const uint64_t size = type == FileType::Directory ? 0 : std::filesystem::file_size(p, ec);
|
||||
oxTracef("ox::fs::PassThroughFS::statInode", "{} {}", ec.message(), path);
|
||||
oxTracef("ox::fs::PassThroughFS::statInode::size", "{} {}", path, size);
|
||||
oxTracef("ox.fs.PassThroughFS.statInode", "{} {}", ec.message(), path);
|
||||
oxTracef("ox.fs.PassThroughFS.statInode::size", "{} {}", path, size);
|
||||
oxReturnError(OxError(static_cast<ox::ErrorCode>(ec.value()), "PassThroughFS: stat failed"));
|
||||
return FileStat{0, 0, size, type};
|
||||
}
|
||||
@@ -147,12 +147,12 @@ Error PassThroughFS::readFilePath(CRStringView path, void *buffer, std::size_t b
|
||||
const std::size_t size = static_cast<std::size_t>(file.tellg());
|
||||
file.seekg(0, std::ios::beg);
|
||||
if (size > buffSize) {
|
||||
oxTracef("ox::fs::PassThroughFS::read::error", "Read failed: Buffer too small: {}", path);
|
||||
oxTracef("ox.fs.PassThroughFS.read.error", "Read failed: Buffer too small: {}", path);
|
||||
return OxError(1);
|
||||
}
|
||||
file.read(static_cast<char*>(buffer), static_cast<std::streamsize>(buffSize));
|
||||
} catch (const std::fstream::failure &f) {
|
||||
oxTracef("ox::fs::PassThroughFS::read::error", "Read of {} failed: {}", path, f.what());
|
||||
oxTracef("ox.fs.PassThroughFS.read.error", "Read of {} failed: {}", path, f.what());
|
||||
return OxError(2);
|
||||
}
|
||||
return OxError(0);
|
||||
@@ -174,7 +174,7 @@ Error PassThroughFS::writeFilePath(CRStringView path, const void *buffer, uint64
|
||||
std::ofstream f(p, std::ios::binary);
|
||||
f.write(static_cast<const char*>(buffer), static_cast<std::streamsize>(size));
|
||||
} catch (const std::fstream::failure &f) {
|
||||
oxTracef("ox::fs::PassThroughFS::read::error", "Write of {} failed: {}", path, f.what());
|
||||
oxTracef("ox.fs.PassThroughFS.read.error", "Write of {} failed: {}", path, f.what());
|
||||
return OxError(1);
|
||||
}
|
||||
return OxError(0);
|
||||
|
||||
@@ -64,11 +64,11 @@ Error PathIterator::fileName(char *out, std::size_t outSize) {
|
||||
Error PathIterator::get(char *pathOut, std::size_t pathOutSize) {
|
||||
std::size_t size = 0;
|
||||
if (m_iterator >= m_maxSize) {
|
||||
oxTracef("ox::fs::PathIterator::get", "m_iterator ({}) >= m_maxSize ({})", m_iterator, m_maxSize);
|
||||
oxTracef("ox.fs.PathIterator.get", "m_iterator ({}) >= m_maxSize ({})", m_iterator, m_maxSize);
|
||||
return OxError(1);
|
||||
}
|
||||
if (!ox_strlen(&m_path[m_iterator])) {
|
||||
oxTrace("ox::fs::PathIterator::get", "!ox_strlen(&m_path[m_iterator])");
|
||||
oxTrace("ox.fs.PathIterator.get", "!ox_strlen(&m_path[m_iterator])");
|
||||
return OxError(1);
|
||||
}
|
||||
auto start = m_iterator;
|
||||
|
||||
Reference in New Issue
Block a user