diff --git a/deps/ox/src/ox/CMakeLists.txt b/deps/ox/src/ox/CMakeLists.txt index c1f436ad..76ce7f7a 100644 --- a/deps/ox/src/ox/CMakeLists.txt +++ b/deps/ox/src/ox/CMakeLists.txt @@ -7,4 +7,5 @@ endif(OX_USE_STDLIB STREQUAL "ON") add_subdirectory(fs) add_subdirectory(trace) add_subdirectory(mc) +add_subdirectory(ptrarith) add_subdirectory(std) diff --git a/deps/ox/src/ox/fs/filestore/filestore.hpp b/deps/ox/src/ox/fs/filestore/filestore.hpp index 44039f42..393c2b7f 100644 --- a/deps/ox/src/ox/fs/filestore/filestore.hpp +++ b/deps/ox/src/ox/fs/filestore/filestore.hpp @@ -8,7 +8,7 @@ #pragma once -#include "nodebuffer.hpp" +#include namespace ox::fs { diff --git a/deps/ox/src/ox/fs/filestore/filestoretemplate.hpp b/deps/ox/src/ox/fs/filestore/filestoretemplate.hpp index a6927e37..561de63f 100644 --- a/deps/ox/src/ox/fs/filestore/filestoretemplate.hpp +++ b/deps/ox/src/ox/fs/filestore/filestoretemplate.hpp @@ -8,20 +8,21 @@ #pragma once +#include + #include "filestore.hpp" -#include "nodebuffer.hpp" namespace ox::fs { template -struct __attribute__((packed)) FileStoreItem: public Item { +struct __attribute__((packed)) FileStoreItem: public ptrarith::Item { ox::LittleEndian id = 0; ox::LittleEndian fileType = 0; ox::LittleEndian links = 0; ox::LittleEndian left = 0; ox::LittleEndian right = 0; - explicit FileStoreItem(size_t size): Item(size) { + explicit FileStoreItem(size_t size): ptrarith::Item(size) { } /** @@ -31,8 +32,8 @@ struct __attribute__((packed)) FileStoreItem: public Item { return sizeof(*this) + this->size(); } - ox::fs::Ptr data() { - return Ptr(this, this->size(), sizeof(*this), this->size() - sizeof(*this)); + ox::ptrarith::Ptr data() { + return ptrarith::Ptr(this, this->size(), sizeof(*this), this->size() - sizeof(*this)); } }; @@ -41,8 +42,8 @@ template class FileStoreTemplate: public FileStore { private: - using ItemPtr = typename ox::fs::NodeBuffer>::ItemPtr; - using Buffer = ox::fs::NodeBuffer>; + using ItemPtr = typename ox::ptrarith::NodeBuffer>::ItemPtr; + using Buffer = ox::ptrarith::NodeBuffer>; struct __attribute__((packed)) FileStoreData { ox::LittleEndian rootNode = 0; @@ -127,7 +128,7 @@ class FileStoreTemplate: public FileStore { template FileStoreTemplate::FileStoreTemplate(void *buff, size_t buffSize) { m_buffSize = buffSize; - m_buffer = reinterpret_cast>*>(buff); + m_buffer = reinterpret_cast>*>(buff); if (!m_buffer->valid(buffSize)) { m_buffSize = 0; m_buffer = nullptr; diff --git a/deps/ox/src/ox/fs/filesystem2/directory.hpp b/deps/ox/src/ox/fs/filesystem2/directory.hpp new file mode 100644 index 00000000..d3dc3bc9 --- /dev/null +++ b/deps/ox/src/ox/fs/filesystem2/directory.hpp @@ -0,0 +1,25 @@ +/* + * Copyright 2015 - 2018 gtalent2@gmail.com + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include +#include + +namespace ox::fs { + +struct DirectoryData { +}; + +class Directory { + + Error add(const PathIterator &it, uint64_t inode); + + Error rm(PathIterator &it); + +}; + +} diff --git a/deps/ox/src/ox/fs/fs.hpp b/deps/ox/src/ox/fs/fs.hpp index 667dbc27..6e4dd813 100644 --- a/deps/ox/src/ox/fs/fs.hpp +++ b/deps/ox/src/ox/fs/fs.hpp @@ -8,4 +8,5 @@ #pragma once -#include "filesystem/filesystemtemplate.hpp" \ No newline at end of file +#include "filesystem/filesystemtemplate.hpp" +#include "filesystem2/directory.hpp" diff --git a/deps/ox/src/ox/fs/test/tests.cpp b/deps/ox/src/ox/fs/test/tests.cpp index 75329409..a501462e 100644 --- a/deps/ox/src/ox/fs/test/tests.cpp +++ b/deps/ox/src/ox/fs/test/tests.cpp @@ -337,7 +337,7 @@ map tests = { [](string) { constexpr auto buffLen = 5000; uint8_t buff[buffLen]; - ox::fs::Ptr p(buff, buffLen, 500, 500); + ox::ptrarith::Ptr p(buff, buffLen, 500, 500); oxAssert(p.valid(), "Ptr::subPtr: Ptr p is invalid."); auto subPtr = p.subPtr(50); @@ -351,7 +351,7 @@ map tests = { int err = 0; constexpr auto buffLen = 5000; uint8_t buff[buffLen]; - auto list = new (buff) ox::fs::NodeBuffer>(buffLen); + auto list = new (buff) ox::ptrarith::NodeBuffer>(buffLen); oxAssert(list->malloc(50).valid(), "NodeBuffer::insert: malloc 1 failed"); oxAssert(list->malloc(50).valid(), "NodeBuffer::insert: malloc 2 failed"); auto first = list->firstItem(); @@ -369,7 +369,7 @@ map tests = { constexpr auto str2 = "Hello, Moon!"; constexpr auto str2Len = ox_strlen(str2) + 1; uint8_t buff[buffLen]; - auto list = new (buff) ox::fs::NodeBuffer>(buffLen); + auto list = new (buff) ox::ptrarith::NodeBuffer>(buffLen); ox::fs::FileStore32 fileStore(list, buffLen); oxAssert(fileStore.format() == 0, "FileStore::format failed."); oxAssert(fileStore.write(4, const_cast(str1), str1Len, 1) == 0, "FileStore::write 1 failed."); diff --git a/deps/ox/src/ox/ptrarith/CMakeLists.txt b/deps/ox/src/ox/ptrarith/CMakeLists.txt new file mode 100644 index 00000000..0ca4d29b --- /dev/null +++ b/deps/ox/src/ox/ptrarith/CMakeLists.txt @@ -0,0 +1,7 @@ +install( + FILES + nodebuffer.hpp + ptr.hpp + DESTINATION + include/ox/ptrarith +) diff --git a/deps/ox/src/ox/fs/filestore/nodebuffer.hpp b/deps/ox/src/ox/ptrarith/nodebuffer.hpp similarity index 98% rename from deps/ox/src/ox/fs/filestore/nodebuffer.hpp rename to deps/ox/src/ox/ptrarith/nodebuffer.hpp index 60165725..5da808b0 100644 --- a/deps/ox/src/ox/fs/filestore/nodebuffer.hpp +++ b/deps/ox/src/ox/ptrarith/nodebuffer.hpp @@ -12,7 +12,7 @@ #include "ptr.hpp" -namespace ox::fs { +namespace ox::ptrarith { template class __attribute__((packed)) NodeBuffer { @@ -24,7 +24,7 @@ class __attribute__((packed)) NodeBuffer { ox::LittleEndian firstItem = 0; }; - using ItemPtr = ox::fs::Ptr; + using ItemPtr = ox::ptrarith::Ptr; Header m_header; diff --git a/deps/ox/src/ox/fs/filestore/ptr.hpp b/deps/ox/src/ox/ptrarith/ptr.hpp similarity index 99% rename from deps/ox/src/ox/fs/filestore/ptr.hpp rename to deps/ox/src/ox/ptrarith/ptr.hpp index 934282d6..7952edfc 100644 --- a/deps/ox/src/ox/fs/filestore/ptr.hpp +++ b/deps/ox/src/ox/ptrarith/ptr.hpp @@ -10,7 +10,7 @@ #include -namespace ox::fs { +namespace ox::ptrarith { template class Ptr { diff --git a/deps/ox/src/ox/std/assert.cpp b/deps/ox/src/ox/std/assert.cpp index 668d2dfc..23574129 100644 --- a/deps/ox/src/ox/std/assert.cpp +++ b/deps/ox/src/ox/std/assert.cpp @@ -6,22 +6,23 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include + +#if defined(OX_USE_STDLIB) + #include -#include +#endif namespace ox { +void _assert([[maybe_unused]]const char *file, [[maybe_unused]]int line, [[maybe_unused]]bool pass, [[maybe_unused]]const char *msg) { #if defined(OX_USE_STDLIB) -void _assert(const char *file, int line, bool pass, const char *msg) { if (!pass) { std::cerr << '(' << file << ':' << line << "): " << msg << std::endl; std::abort(); } -} -#else -void _assert(const char*, int, bool, const char*) { -} #endif +} } diff --git a/deps/ox/src/ox/std/memops.cpp b/deps/ox/src/ox/std/memops.cpp index e7a17edb..581b45be 100644 --- a/deps/ox/src/ox/std/memops.cpp +++ b/deps/ox/src/ox/std/memops.cpp @@ -1,4 +1,3 @@ - /* * Copyright 2015 - 2018 gtalent2@gmail.com *