FE 0.13.1
Header-only C++ frontend library
Loading...
Searching...
No Matches
sys.h File Reference
#include <filesystem>
#include <optional>
#include <stdexcept>
#include <string>
#include <string_view>
Include dependency graph for sys.h:

Go to the source code of this file.

Classes

class  fe::sys::CmdNotFound
 Thrown by sys::require_cmd when a command cannot be located on the system. More...

Namespaces

namespace  fe
namespace  fe::sys

Functions

std::optional< std::filesystem::path > fe::sys::path_to_lib (const void *addr)
 Path of the executable or dynamic library that contains addr.
std::string fe::sys::exec (std::string cmd)
 Executes command cmd.
std::string fe::sys::find_cmd (std::string cmd)
 Locates cmd via sys::which; the resulting path may not exist.
std::string fe::sys::require_cmd (std::string_view name)
 Locates name on the system or throws CmdNotFound.
int fe::sys::system (std::string cmd)
 Wraps std::system and makes the return value usable.
void fe::sys::require_run (const std::string &cmd)
 Runs cmd via sys::system and throws if it exits with a non-zero status.
int fe::sys::run (std::string cmd, std::string args={})
 Wraps sys::system and puts .exe at the back (Windows) and ./ at the front (otherwise) of cmd.
std::string fe::sys::escape (const std::filesystem::path &path)
 Returns the path as std::string and escapes all whitespaces with backslash.

Variables

static constexpr auto fe::sys::which
 Name of the command that locates an executable on this platform.