From 0fc11dfdd86482c640be8344fc5649560ceead3a Mon Sep 17 00:00:00 2001 From: nyoungbq Date: Fri, 22 Dec 2023 14:51:02 -0500 Subject: [PATCH] bug fix 2 --- src/simplnx/Utilities/FilterUtilities.cpp | 42 +++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/simplnx/Utilities/FilterUtilities.cpp diff --git a/src/simplnx/Utilities/FilterUtilities.cpp b/src/simplnx/Utilities/FilterUtilities.cpp new file mode 100644 index 0000000000..f16f810c16 --- /dev/null +++ b/src/simplnx/Utilities/FilterUtilities.cpp @@ -0,0 +1,42 @@ +#include "FilterUtilities.hpp" + +#include + +#include + +namespace nx::core +{ + +// ----------------------------------------------------------------------------- +Result<> CreateOutputDirectories(const fs::path& outputPath) +{ + if(!fs::exists(outputPath)) + { + std::error_code errorCode; + // So this looks weird but this can happen on + // platforms where /tmp is a symlink to /private/tmp. So the original path is + // /tmp/foo but what was created was /private/tmp/foo. This logic should fix that issue. + if(!fs::create_directories(outputPath, errorCode) && !fs::exists(outputPath)) + { + return MakeErrorResult(-4010, fmt::format("Unable to create output directory {}. Error code from operating system is {}", outputPath.string(), errorCode.value())); + } + } + return {}; +} + +// ----------------------------------------------------------------------------- +void AppendDataObjectModifications(const DataStructure& dataStructure, std::vector& modifiedActions, const DataPath& parentPath, const std::vector& ignoredDataPaths) +{ + std::optional> result = nx::core::GetAllChildArrayDataPaths(dataStructure, parentPath, ignoredDataPaths); + if(!result) + { + return; + } + + for(const auto& child : result.value()) + { + modifiedActions.push_back(DataObjectModification{child, DataObjectModification::ModifiedType::Modified, dataStructure.getDataRef(child).getDataObjectType()}); + } +} + +} // namespace nx::core