MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
mim::sys Namespace Reference

Classes

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

Functions

std::optional< fs::path > path_to_libmim ()
 Yields std::nullopt if an error occurred.
std::string exec (std::string cmd)
 Executes command cmd.
std::string find_cmd (std::string)
std::string require_cmd (std::string_view name)
 Locates name on the system or throws CmdNotFound.
int system (std::string)
 Wraps std::system and makes the return value usable.
void require_run (const std::string &cmd)
 Runs cmd via sys::system and throws if it exits with a non-zero status.
int 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 escape (const std::filesystem::path &path)
 Returns the path as std::string and escapes all whitespaces with backslash.

Function Documentation

◆ escape()

std::string mim::sys::escape ( const std::filesystem::path & path)

Returns the path as std::string and escapes all whitespaces with backslash.

Definition at line 126 of file sys.cpp.

◆ exec()

std::string mim::sys::exec ( std::string cmd)

Executes command cmd.

Returns
the output as string.

Definition at line 83 of file sys.cpp.

Referenced by find_cmd().

◆ find_cmd()

std::string mim::sys::find_cmd ( std::string cmd)

Definition at line 95 of file sys.cpp.

References exec(), and MIM_WHICH.

Referenced by main(), and require_cmd().

◆ path_to_libmim()

std::optional< fs::path > mim::sys::path_to_libmim ( )

Yields std::nullopt if an error occurred.

The returned path is adjusted so <parent>/mim resolves to the default in-tree plugin directory when possible.

Definition at line 52 of file sys.cpp.

References mim_lib_anchor().

Referenced by mim::Driver::Driver().

◆ require_cmd()

std::string mim::sys::require_cmd ( std::string_view name)

Locates name on the system or throws CmdNotFound.

Definition at line 101 of file sys.cpp.

References find_cmd().

◆ require_run()

void mim::sys::require_run ( const std::string & cmd)

Runs cmd via sys::system and throws if it exits with a non-zero status.

Definition at line 113 of file sys.cpp.

References system().

◆ run()

int mim::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.

Definition at line 117 of file sys.cpp.

References system().

◆ system()

int mim::sys::system ( std::string cmd)

Wraps std::system and makes the return value usable.

Definition at line 107 of file sys.cpp.

Referenced by require_run(), and run().