Compare commits
No commits in common. "cee4f65d4a0fdbfcbfe3d46c3ffb5a9df9a2ec9e" and "287d42f2b9690eb90116fd40312f6f98ae943141" have entirely different histories.
cee4f65d4a
...
287d42f2b9
4
deps/ox/src/ox/fs/CMakeLists.txt
vendored
4
deps/ox/src/ox/fs/CMakeLists.txt
vendored
@ -1,7 +1,3 @@
|
|||||||
if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
|
|
||||||
# enable warnings
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunsafe-buffer-usage")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_library(
|
add_library(
|
||||||
OxFS
|
OxFS
|
||||||
|
@ -10,8 +10,6 @@
|
|||||||
|
|
||||||
#include <ox/fs/ptrarith/nodebuffer.hpp>
|
#include <ox/fs/ptrarith/nodebuffer.hpp>
|
||||||
|
|
||||||
OX_CLANG_NOWARN_BEGIN(-Wunsafe-buffer-usage)
|
|
||||||
|
|
||||||
namespace ox {
|
namespace ox {
|
||||||
|
|
||||||
using InodeId_t = uint64_t;
|
using InodeId_t = uint64_t;
|
||||||
@ -773,5 +771,3 @@ using FileStore16 = FileStoreTemplate<uint16_t>;
|
|||||||
using FileStore32 = FileStoreTemplate<uint32_t>;
|
using FileStore32 = FileStoreTemplate<uint32_t>;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OX_CLANG_NOWARN_END
|
|
||||||
|
4
deps/ox/src/ox/fs/filesystem/directory.hpp
vendored
4
deps/ox/src/ox/fs/filesystem/directory.hpp
vendored
@ -15,8 +15,6 @@
|
|||||||
|
|
||||||
#include "types.hpp"
|
#include "types.hpp"
|
||||||
|
|
||||||
OX_CLANG_NOWARN_BEGIN(-Wunsafe-buffer-usage)
|
|
||||||
|
|
||||||
namespace ox {
|
namespace ox {
|
||||||
|
|
||||||
template<typename InodeId_t>
|
template<typename InodeId_t>
|
||||||
@ -335,5 +333,3 @@ using Directory16 = Directory<FileStore16, uint16_t>;
|
|||||||
using Directory32 = Directory<FileStore32, uint32_t>;
|
using Directory32 = Directory<FileStore32, uint32_t>;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OX_CLANG_NOWARN_END
|
|
||||||
|
@ -32,9 +32,7 @@ FileAddress::FileAddress(ox::StringViewCR path) noexcept {
|
|||||||
auto pathSize = path.bytes();
|
auto pathSize = path.bytes();
|
||||||
m_data.path = new char[pathSize + 1];
|
m_data.path = new char[pathSize + 1];
|
||||||
memcpy(m_data.path, path.data(), pathSize);
|
memcpy(m_data.path, path.data(), pathSize);
|
||||||
OX_CLANG_NOWARN_BEGIN(-Wunsafe-buffer-usage)
|
|
||||||
m_data.path[pathSize] = 0;
|
m_data.path[pathSize] = 0;
|
||||||
OX_CLANG_NOWARN_END
|
|
||||||
m_type = FileAddressType::Path;
|
m_type = FileAddressType::Path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,8 +13,6 @@
|
|||||||
#include <ox/model/typenamecatcher.hpp>
|
#include <ox/model/typenamecatcher.hpp>
|
||||||
#include <ox/model/types.hpp>
|
#include <ox/model/types.hpp>
|
||||||
|
|
||||||
OX_CLANG_NOWARN_BEGIN(-Wunsafe-buffer-usage)
|
|
||||||
|
|
||||||
namespace ox {
|
namespace ox {
|
||||||
|
|
||||||
enum class FileAddressType: int8_t {
|
enum class FileAddressType: int8_t {
|
||||||
@ -182,5 +180,3 @@ constexpr Error model(T *h, CommonPtrWith<FileAddress> auto *fa) noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OX_CLANG_NOWARN_END
|
|
||||||
|
@ -11,8 +11,6 @@
|
|||||||
#include <ox/std/trace.hpp>
|
#include <ox/std/trace.hpp>
|
||||||
#include "pathiterator.hpp"
|
#include "pathiterator.hpp"
|
||||||
|
|
||||||
OX_CLANG_NOWARN_BEGIN(-Wunsafe-buffer-usage)
|
|
||||||
|
|
||||||
namespace ox {
|
namespace ox {
|
||||||
|
|
||||||
PathIterator::PathIterator(const char *path, std::size_t maxSize, std::size_t iterator) {
|
PathIterator::PathIterator(const char *path, std::size_t maxSize, std::size_t iterator) {
|
||||||
@ -32,7 +30,7 @@ PathIterator::PathIterator(StringViewCR path): PathIterator(path.data(), path.by
|
|||||||
*/
|
*/
|
||||||
Error PathIterator::dirPath(char *out, std::size_t outSize) {
|
Error PathIterator::dirPath(char *out, std::size_t outSize) {
|
||||||
const auto idx = ox::lastIndexOf(m_path, '/', m_maxSize);
|
const auto idx = ox::lastIndexOf(m_path, '/', m_maxSize);
|
||||||
const auto size = static_cast<std::size_t>(idx) + 1;
|
const auto size = static_cast<std::size_t>(idx + 1);
|
||||||
if (idx >= 0 && size < outSize) {
|
if (idx >= 0 && size < outSize) {
|
||||||
ox::memcpy(out, m_path, size);
|
ox::memcpy(out, m_path, size);
|
||||||
out[size] = 0;
|
out[size] = 0;
|
||||||
@ -185,5 +183,3 @@ const char *PathIterator::fullPath() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OX_CLANG_NOWARN_END
|
|
||||||
|
4
deps/ox/src/ox/fs/ptrarith/nodebuffer.hpp
vendored
4
deps/ox/src/ox/fs/ptrarith/nodebuffer.hpp
vendored
@ -13,8 +13,6 @@
|
|||||||
|
|
||||||
#include "ptr.hpp"
|
#include "ptr.hpp"
|
||||||
|
|
||||||
OX_CLANG_NOWARN_BEGIN(-Wunsafe-buffer-usage)
|
|
||||||
|
|
||||||
namespace ox::ptrarith {
|
namespace ox::ptrarith {
|
||||||
|
|
||||||
template<typename size_t, typename Item>
|
template<typename size_t, typename Item>
|
||||||
@ -451,5 +449,3 @@ struct OX_PACKED Item {
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OX_CLANG_NOWARN_END
|
|
||||||
|
4
deps/ox/src/ox/fs/ptrarith/ptr.hpp
vendored
4
deps/ox/src/ox/fs/ptrarith/ptr.hpp
vendored
@ -10,8 +10,6 @@
|
|||||||
|
|
||||||
#include <ox/std/std.hpp>
|
#include <ox/std/std.hpp>
|
||||||
|
|
||||||
OX_CLANG_NOWARN_BEGIN(-Wunsafe-buffer-usage)
|
|
||||||
|
|
||||||
namespace ox::ptrarith {
|
namespace ox::ptrarith {
|
||||||
|
|
||||||
template<typename T, typename size_t, size_t minOffset = 1>
|
template<typename T, typename size_t, size_t minOffset = 1>
|
||||||
@ -258,5 +256,3 @@ constexpr Result<Ptr<T, size_t, minOffset>> Ptr<T, size_t, minOffset>::validate(
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OX_CLANG_NOWARN_END
|
|
||||||
|
5
deps/ox/src/ox/fs/test/tests.cpp
vendored
5
deps/ox/src/ox/fs/test/tests.cpp
vendored
@ -226,14 +226,13 @@ const std::map<ox::StringView, std::function<ox::Error(ox::StringView)>> tests =
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(int argc, const char **argv) {
|
int main(int argc, const char **args) {
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
oxError("Must specify test to run");
|
oxError("Must specify test to run");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
auto const args = ox::SpanView{argv, static_cast<size_t>(argc)};
|
|
||||||
ox::StringView const testName = args[1];
|
ox::StringView const testName = args[1];
|
||||||
ox::StringView const testArg = argc >= 3 ? args[2] : nullptr;
|
ox::StringView const testArg = args[2] ? args[2] : nullptr;
|
||||||
auto const func = tests.find(testName);
|
auto const func = tests.find(testName);
|
||||||
if (func != tests.end()) {
|
if (func != tests.end()) {
|
||||||
oxAssert(func->second(testArg), "Test returned Error");
|
oxAssert(func->second(testArg), "Test returned Error");
|
||||||
|
23
deps/ox/src/ox/fs/tool.cpp
vendored
23
deps/ox/src/ox/fs/tool.cpp
vendored
@ -39,25 +39,25 @@ static ox::Result<ox::UniquePtr<ox::FileSystem>> loadFs(const char *path) noexce
|
|||||||
return {ox::make_unique<ox::FileSystem32>(buff.data, buff.size)};
|
return {ox::make_unique<ox::FileSystem32>(buff.data, buff.size)};
|
||||||
}
|
}
|
||||||
|
|
||||||
static ox::Error runLs(ox::FileSystem *fs, ox::SpanView<const char*> args) noexcept {
|
static ox::Error runLs(ox::FileSystem *fs, int argc, const char **argv) noexcept {
|
||||||
if (args.size() < 2) {
|
if (argc < 2) {
|
||||||
oxErr("Must provide a directory to ls\n");
|
oxErr("Must provide a directory to ls\n");
|
||||||
return OxError(1);
|
return OxError(1);
|
||||||
}
|
}
|
||||||
oxRequire(files, fs->ls(args[1]));
|
oxRequire(files, fs->ls(argv[1]));
|
||||||
for (const auto &file : files) {
|
for (const auto &file : files) {
|
||||||
oxOutf("{}\n", file);
|
oxOutf("{}\n", file);
|
||||||
}
|
}
|
||||||
return OxError(0);
|
return OxError(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ox::Error runRead(ox::FileSystem *fs, ox::SpanView<const char*> args) noexcept {
|
static ox::Error runRead(ox::FileSystem *fs, int argc, const char **argv) noexcept {
|
||||||
if (args.size() < 2) {
|
if (argc < 2) {
|
||||||
oxErr("Must provide a path to a file to read\n");
|
oxErr("Must provide a path to a file to read\n");
|
||||||
return OxError(1);
|
return OxError(1);
|
||||||
}
|
}
|
||||||
oxRequire(buff, fs->read(ox::StringView(args[1])));
|
oxRequire(buff, fs->read(ox::StringView(argv[1])));
|
||||||
std::ignore = fwrite(buff.data(), sizeof(decltype(buff)::value_type), buff.size(), stdout);
|
fwrite(buff.data(), sizeof(decltype(buff)::value_type), buff.size(), stdout);
|
||||||
return OxError(0);
|
return OxError(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,14 +66,13 @@ static ox::Error run(int argc, const char **argv) noexcept {
|
|||||||
oxErr("OxFS file and subcommand arguments are required\n");
|
oxErr("OxFS file and subcommand arguments are required\n");
|
||||||
return OxError(1);
|
return OxError(1);
|
||||||
}
|
}
|
||||||
auto const args = ox::SpanView{argv, static_cast<size_t>(argc)};
|
const auto fsPath = argv[1];
|
||||||
auto const fsPath = args[1];
|
ox::String subCmd(argv[2]);
|
||||||
ox::String subCmd(args[2]);
|
|
||||||
oxRequire(fs, loadFs(fsPath));
|
oxRequire(fs, loadFs(fsPath));
|
||||||
if (subCmd == "ls") {
|
if (subCmd == "ls") {
|
||||||
return runLs(fs.get(), args + 2);
|
return runLs(fs.get(), argc - 2, argv + 2);
|
||||||
} else if (subCmd == "read") {
|
} else if (subCmd == "read") {
|
||||||
return runRead(fs.get(), args + 2);
|
return runRead(fs.get(), argc - 2, argv + 2);
|
||||||
}
|
}
|
||||||
return OxError(1);
|
return OxError(1);
|
||||||
}
|
}
|
||||||
|
6
deps/ox/src/ox/std/test/tests.cpp
vendored
6
deps/ox/src/ox/std/test/tests.cpp
vendored
@ -472,13 +472,13 @@ OX_CLANG_NOWARN_END
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(int argc, const char **argv) {
|
int main(int argc, const char **args) {
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
oxError("Must specify test to run");
|
oxError("Must specify test to run");
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
auto const args = ox::SpanView{argv, static_cast<size_t>(argc)};
|
OX_CLANG_NOWARN_BEGIN(-Wunsafe-buffer-usage)
|
||||||
auto const testName = args[1];
|
auto const testName = args[1];
|
||||||
|
OX_CLANG_NOWARN_END
|
||||||
auto const func = tests.find(testName);
|
auto const func = tests.find(testName);
|
||||||
if (func != tests.end()) {
|
if (func != tests.end()) {
|
||||||
oxAssert(func->second(), "Test returned Error");
|
oxAssert(func->second(), "Test returned Error");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user