1 Commits

Author SHA1 Message Date
eda08e509e (WIP) Process stream reimplementation. 2025-11-22 12:49:15 +01:00
2 changed files with 17 additions and 6 deletions

View File

@@ -168,12 +168,17 @@ std::string shellEscape(const std::string& arg) MIJIN_NOEXCEPT
return oss.str();
}
std::string makeShellCommand(const std::vector<std::string>& args) MIJIN_NOEXCEPT
std::string makeShellCommand(std::span<std::string_view> args) MIJIN_NOEXCEPT
{
(void) args;
MIJIN_ERROR("TBD");
return {};
#if 0
using namespace mijin::pipe;
return args
| Map(&shellEscape)
| Join(" ");
#endif
}
} // namespace mijin
#endif // MIJIN_TARGET_OS == MIJIN_OS_LINUX || MIJIN_TARGET_OS == MIJIN_OS_OSX

View File

@@ -3,7 +3,7 @@
#if !defined(MIJIN_IO_PROCESS_HPP_INCLUDED)
#define MIJIN_IO_PROCESS_HPP_INCLUDED 1
#include <vector>
#include <span>
#include "./stream.hpp"
#include "../internal/common.hpp"
@@ -22,7 +22,7 @@ public:
inline StreamError open(const std::string& command, FileOpenMode mode_) {
return open(command.c_str(), mode_);
}
inline StreamError open(const std::vector<std::string>& args, FileOpenMode mode_);
inline StreamError open(std::span<std::string_view> args, FileOpenMode mode_);
int close();
[[nodiscard]] inline bool isOpen() const { return handle != nullptr; }
@@ -36,13 +36,19 @@ public:
StreamFeatures getFeatures() override;
};
[[nodiscard]] std::string shellEscape(const std::string& arg) MIJIN_NOEXCEPT;
[[nodiscard]] std::string makeShellCommand(const std::vector<std::string>& args) MIJIN_NOEXCEPT;
[[nodiscard]] std::string shellEscape(std::string_view arg) MIJIN_NOEXCEPT;
[[nodiscard]] std::string makeShellCommand(std::span<std::string_view> args) MIJIN_NOEXCEPT;
StreamError ProcessStream::open(const std::vector<std::string>& args, FileOpenMode mode_)
StreamError ProcessStream::open(std::span<std::string_view> args, FileOpenMode mode_)
{
return open(makeShellCommand(args), mode_);
}
template<typename... TTypes>
std::array<std::string_view, sizeof...(TTypes)> makeSVList(TTypes&&... args)
{
return std::array{std::string_view(std::forward<TTypes>(args))...};
}
}
#endif // MIJIN_IO_PROCESS_HPP_INCLUDED