From 77c2cff1cac2e85bcd5afdd3845f9cbdad17b795 Mon Sep 17 00:00:00 2001 From: OmniaX-Dev Date: Fri, 20 Mar 2026 23:21:32 +0100 Subject: [PATCH] Renamed data_types sub-folder to data --- CMakeLists.txt | 6 +-- other/build.nr | 2 +- other/create_release.sh | 4 +- src/ogfx/Animation.hpp | 2 +- src/ogfx/Image.hpp | 2 +- src/ogfx/PixelRenderer.hpp | 2 +- src/ostd/{data_types => data}/BaseObject.cpp | 0 src/ostd/{data_types => data}/BaseObject.hpp | 0 src/ostd/{data_types => data}/Bitfields.hpp | 0 src/ostd/{data_types => data}/Color.cpp | 0 src/ostd/{data_types => data}/Color.hpp | 4 +- src/ostd/{data_types => data}/Types.hpp | 0 src/ostd/io/Errors.hpp | 4 +- src/ostd/io/File.hpp | 4 +- src/ostd/io/FileSystem.cpp | 45 ++++++++++++++++++-- src/ostd/io/FileSystem.hpp | 5 ++- src/ostd/io/IOHandlers.hpp | 2 +- src/ostd/io/Json.hpp | 2 +- src/ostd/io/Memory.hpp | 2 +- src/ostd/io/OutputHandlers.cpp | 2 +- src/ostd/io/Serial.hpp | 6 +-- src/ostd/ostd.hpp | 11 ++--- src/ostd/string/String.hpp | 2 +- src/ostd/string/TextStyleParser.hpp | 2 +- src/ostd/utils/QuadTree.hpp | 2 +- src/ostd/utils/Signals.cpp | 2 +- src/ostd/utils/Signals.hpp | 4 +- src/ostd/utils/Time.hpp | 2 +- 28 files changed, 80 insertions(+), 39 deletions(-) rename src/ostd/{data_types => data}/BaseObject.cpp (100%) rename src/ostd/{data_types => data}/BaseObject.hpp (100%) rename src/ostd/{data_types => data}/Bitfields.hpp (100%) rename src/ostd/{data_types => data}/Color.cpp (100%) rename src/ostd/{data_types => data}/Color.hpp (97%) rename src/ostd/{data_types => data}/Types.hpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8bbcb8d..d1bfa6c 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,9 +42,9 @@ list(APPEND OSTD_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/src/ostd/vendor/midifile/MidiMessage.cpp ${CMAKE_CURRENT_LIST_DIR}/src/ostd/vendor/midifile/Options.cpp - # data_types - ${CMAKE_CURRENT_LIST_DIR}/src/ostd/data_types/BaseObject.cpp - ${CMAKE_CURRENT_LIST_DIR}/src/ostd/data_types/Color.cpp + # data + ${CMAKE_CURRENT_LIST_DIR}/src/ostd/data/BaseObject.cpp + ${CMAKE_CURRENT_LIST_DIR}/src/ostd/data/Color.cpp # io ${CMAKE_CURRENT_LIST_DIR}/src/ostd/io/Console.cpp diff --git a/other/build.nr b/other/build.nr index 661b0f2..b91e780 100644 --- a/other/build.nr +++ b/other/build.nr @@ -1 +1 @@ -2025 +2027 diff --git a/other/create_release.sh b/other/create_release.sh index 71e7c6b..5364366 100755 --- a/other/create_release.sh +++ b/other/create_release.sh @@ -37,14 +37,14 @@ fi mkdir -p $RELEASE_DIR/include/ostd/vendor mkdir -p $RELEASE_DIR/include/ostd/vendor/midifile -mkdir -p $RELEASE_DIR/include/ostd/data_types +mkdir -p $RELEASE_DIR/include/ostd/data mkdir -p $RELEASE_DIR/include/ostd/io mkdir -p $RELEASE_DIR/include/ostd/math mkdir -p $RELEASE_DIR/include/ostd/string mkdir -p $RELEASE_DIR/include/ostd/utils mkdir -p $RELEASE_DIR/include/ogfx/ find ../src/ostd -maxdepth 1 -name "*.h*" -exec cp {} $RELEASE_DIR/include/ostd \; -find ../src/ostd/data_types -maxdepth 1 -name "*.h*" -exec cp {} $RELEASE_DIR/include/ostd/data_types \; +find ../src/ostd/data -maxdepth 1 -name "*.h*" -exec cp {} $RELEASE_DIR/include/ostd/data \; find ../src/ostd/io -maxdepth 1 -name "*.h*" -exec cp {} $RELEASE_DIR/include/ostd/io \; find ../src/ostd/math -maxdepth 1 -name "*.h*" -exec cp {} $RELEASE_DIR/include/ostd/math \; find ../src/ostd/string -maxdepth 1 -name "*.h*" -exec cp {} $RELEASE_DIR/include/ostd/string \; diff --git a/src/ogfx/Animation.hpp b/src/ogfx/Animation.hpp index 04fe7e9..46a7e2e 100644 --- a/src/ogfx/Animation.hpp +++ b/src/ogfx/Animation.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include diff --git a/src/ogfx/Image.hpp b/src/ogfx/Image.hpp index 8bd26cc..ff95d87 100644 --- a/src/ogfx/Image.hpp +++ b/src/ogfx/Image.hpp @@ -20,7 +20,7 @@ #pragma once -#include +#include #include #include diff --git a/src/ogfx/PixelRenderer.hpp b/src/ogfx/PixelRenderer.hpp index e399c5b..23c6473 100644 --- a/src/ogfx/PixelRenderer.hpp +++ b/src/ogfx/PixelRenderer.hpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include diff --git a/src/ostd/data_types/BaseObject.cpp b/src/ostd/data/BaseObject.cpp similarity index 100% rename from src/ostd/data_types/BaseObject.cpp rename to src/ostd/data/BaseObject.cpp diff --git a/src/ostd/data_types/BaseObject.hpp b/src/ostd/data/BaseObject.hpp similarity index 100% rename from src/ostd/data_types/BaseObject.hpp rename to src/ostd/data/BaseObject.hpp diff --git a/src/ostd/data_types/Bitfields.hpp b/src/ostd/data/Bitfields.hpp similarity index 100% rename from src/ostd/data_types/Bitfields.hpp rename to src/ostd/data/Bitfields.hpp diff --git a/src/ostd/data_types/Color.cpp b/src/ostd/data/Color.cpp similarity index 100% rename from src/ostd/data_types/Color.cpp rename to src/ostd/data/Color.cpp diff --git a/src/ostd/data_types/Color.hpp b/src/ostd/data/Color.hpp similarity index 97% rename from src/ostd/data_types/Color.hpp rename to src/ostd/data/Color.hpp index 537ebd9..218f767 100755 --- a/src/ostd/data_types/Color.hpp +++ b/src/ostd/data/Color.hpp @@ -21,8 +21,8 @@ #pragma once #include -#include -#include +#include +#include #include namespace ostd diff --git a/src/ostd/data_types/Types.hpp b/src/ostd/data/Types.hpp similarity index 100% rename from src/ostd/data_types/Types.hpp rename to src/ostd/data/Types.hpp diff --git a/src/ostd/io/Errors.hpp b/src/ostd/io/Errors.hpp index c0c05d8..90a6e06 100755 --- a/src/ostd/io/Errors.hpp +++ b/src/ostd/io/Errors.hpp @@ -20,8 +20,8 @@ #pragma once -#include -#include +#include +#include #define ERROR_DATA() String(CPP_STR(__LINE__)), String(__FILE__) diff --git a/src/ostd/io/File.hpp b/src/ostd/io/File.hpp index 44643ec..ca6c347 100755 --- a/src/ostd/io/File.hpp +++ b/src/ostd/io/File.hpp @@ -22,8 +22,8 @@ #include #include -#include -#include +#include +#include namespace ostd { diff --git a/src/ostd/io/FileSystem.cpp b/src/ostd/io/FileSystem.cpp index 51c8ab5..9a1043e 100644 --- a/src/ostd/io/FileSystem.cpp +++ b/src/ostd/io/FileSystem.cpp @@ -295,10 +295,8 @@ namespace ostd return ePathStatus::ExistingDirectory; if (fileExists(path)) return ePathStatus::ExistingFile; - if (isValidDirectoryCreationPath(path)) - return ePathStatus::ValidNewDirectory; - if (isValidFileCreationPath(path)) - return ePathStatus::ValidNewFile; + if (isValidDirectoryCreationPath(path) && isValidFileCreationPath(path)) + return ePathStatus::ValidNewPath; return ePathStatus::Invalid; } @@ -325,6 +323,45 @@ namespace ostd return true; } + bool FileSystem::writeTextFile(const ostd::String& filePath, const std::vector& lines, bool truncate) + { + namespace fs = std::filesystem; + ePathStatus status = getPathStatus(filePath); + if (status == ePathStatus::Invalid || status == ePathStatus::ExistingDirectory) + { + OX_ERROR("Invalid file path for writing: '%s'", filePath.c_str()); + return false; + } + if (!ensureFile(filePath, truncate)) + return false; + + try + { + std::ofstream ofs(filePath.cpp_str(), std::ios::app); + if (!ofs) + { + OX_ERROR("Failed to open file for writing: '%s'", filePath.c_str()); + return false; + } + for (const auto& line : lines) + ofs << line.cpp_str() << '\n'; + return true; + } + catch (const fs::filesystem_error& e) + { + OX_ERROR("Filesystem error writing file '%s': %s", filePath.c_str(), e.what()); + return false; + } + } + + + bool FileSystem::writeTextFileRaw(const ostd::String& filePath, const ostd::String& lines, bool truncate) + { + auto _lines = lines.tokenize("\n", false, true).getRawData(); + return writeTextFile(filePath, _lines, truncate); + } + + bool FileSystem::loadFileFromHppResource(String output_file_path, const char* resource_buffer, unsigned int size) { unsigned char ext_len = resource_buffer[0]; diff --git a/src/ostd/io/FileSystem.hpp b/src/ostd/io/FileSystem.hpp index 92c4142..df7dd0b 100644 --- a/src/ostd/io/FileSystem.hpp +++ b/src/ostd/io/FileSystem.hpp @@ -28,7 +28,7 @@ namespace ostd { class FileSystem { - public: enum class ePathStatus { Invalid = 0, ExistingDirectory, ValidNewDirectory, ExistingFile, ValidNewFile }; + public: enum class ePathStatus { Invalid = 0, ExistingDirectory, ExistingFile, ValidNewPath }; public: static std::vector listFilesInDirectory(const String& directoryPath); @@ -55,6 +55,9 @@ namespace ostd static bool readTextFile(String fileName, std::vector& outLines); static bool readTextFileRaw(String fileName, String& outString); + static bool writeTextFile(const ostd::String& filePath, const std::vector& lines, bool truncate = true); + static bool writeTextFileRaw(const ostd::String& filePath, const ostd::String& lines, bool truncate = true); + static bool loadFileFromHppResource(String output_file_path, const char* resource_buffer, unsigned int size); }; } diff --git a/src/ostd/io/IOHandlers.hpp b/src/ostd/io/IOHandlers.hpp index bb5cb4e..f43aa15 100644 --- a/src/ostd/io/IOHandlers.hpp +++ b/src/ostd/io/IOHandlers.hpp @@ -20,7 +20,7 @@ #pragma once -#include +#include #include #include #include diff --git a/src/ostd/io/Json.hpp b/src/ostd/io/Json.hpp index 0ca8926..1bf2fea 100644 --- a/src/ostd/io/Json.hpp +++ b/src/ostd/io/Json.hpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include // IWYU pragma: keep namespace ostd diff --git a/src/ostd/io/Memory.hpp b/src/ostd/io/Memory.hpp index 535f684..58d9203 100644 --- a/src/ostd/io/Memory.hpp +++ b/src/ostd/io/Memory.hpp @@ -20,7 +20,7 @@ #pragma once -#include +#include #include #include diff --git a/src/ostd/io/OutputHandlers.cpp b/src/ostd/io/OutputHandlers.cpp index 944af72..49d2b48 100755 --- a/src/ostd/io/OutputHandlers.cpp +++ b/src/ostd/io/OutputHandlers.cpp @@ -3,7 +3,7 @@ #include "Logger.hpp" #include "IOHandlers.hpp" #include "../vendor/TermColor.hpp" -#include "../data_types/BaseObject.hpp" +#include "../data/BaseObject.hpp" #include "../string/TextStyleParser.hpp" #include "../string/String.hpp" #include "io/Console.hpp" diff --git a/src/ostd/io/Serial.hpp b/src/ostd/io/Serial.hpp index e380f29..57aebb2 100755 --- a/src/ostd/io/Serial.hpp +++ b/src/ostd/io/Serial.hpp @@ -20,9 +20,9 @@ #pragma once -#include -#include -#include +#include +#include +#include namespace ostd { diff --git a/src/ostd/ostd.hpp b/src/ostd/ostd.hpp index b2a93c9..345fe5c 100644 --- a/src/ostd/ostd.hpp +++ b/src/ostd/ostd.hpp @@ -22,10 +22,10 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include @@ -33,9 +33,11 @@ #include #include #include +#include #include #include +#include #include #include @@ -43,4 +45,3 @@ #include #include -#include diff --git a/src/ostd/string/String.hpp b/src/ostd/string/String.hpp index d00b20e..04c733d 100644 --- a/src/ostd/string/String.hpp +++ b/src/ostd/string/String.hpp @@ -22,7 +22,7 @@ #include #include -#include +#include #define STR_BOOL(b) (b ? "true" : "false") diff --git a/src/ostd/string/TextStyleParser.hpp b/src/ostd/string/TextStyleParser.hpp index 99a9ef4..04e1c7b 100644 --- a/src/ostd/string/TextStyleParser.hpp +++ b/src/ostd/string/TextStyleParser.hpp @@ -20,7 +20,7 @@ #pragma once -#include +#include namespace ostd { diff --git a/src/ostd/utils/QuadTree.hpp b/src/ostd/utils/QuadTree.hpp index fbdb85f..e8e58d8 100755 --- a/src/ostd/utils/QuadTree.hpp +++ b/src/ostd/utils/QuadTree.hpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include namespace ostd diff --git a/src/ostd/utils/Signals.cpp b/src/ostd/utils/Signals.cpp index f932a56..c2ef328 100755 --- a/src/ostd/utils/Signals.cpp +++ b/src/ostd/utils/Signals.cpp @@ -1,5 +1,5 @@ #include "Signals.hpp" -#include "../data_types/BaseObject.hpp" +#include "../data/BaseObject.hpp" #include "../io/Logger.hpp" namespace ostd diff --git a/src/ostd/utils/Signals.hpp b/src/ostd/utils/Signals.hpp index 2f6163f..575843e 100755 --- a/src/ostd/utils/Signals.hpp +++ b/src/ostd/utils/Signals.hpp @@ -20,8 +20,8 @@ #pragma once -#include -#include +#include +#include #include namespace ostd diff --git a/src/ostd/utils/Time.hpp b/src/ostd/utils/Time.hpp index 627d923..640ab1c 100644 --- a/src/ostd/utils/Time.hpp +++ b/src/ostd/utils/Time.hpp @@ -20,7 +20,7 @@ #pragma once -#include +#include #include #include