MimIR 0.1
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
sys.h
Go to the documentation of this file.
1#pragma once
2
3#include <filesystem>
4#include <optional>
5#include <string>
6
7#ifdef _WIN32
8# define MIM_WHICH "where"
9#else
10# define MIM_WHICH "which"
11#endif
12
13namespace mim {
14
15namespace fs = std::filesystem;
16
17namespace sys {
18
19std::optional<fs::path> path_to_curr_exe(); ///< Yields `std::nullopt` if an error occurred.
20
21/// Executes command @p cmd.
22/// @returns the output as string.
23std::string exec(std::string cmd);
24
25std::string find_cmd(std::string);
26
27/// Wraps `std::system` and makes the return value usable.
28int system(std::string);
29
30/// Wraps sys::system and puts `.exe` at the back (Windows) and `./` at the front (otherwise) of @p cmd.
31int run(std::string cmd, std::string args = {});
32
33} // namespace sys
34} // namespace mim
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.
Definition sys.cpp:76
int system(std::string)
Wraps std::system and makes the return value usable.
Definition sys.cpp:70
std::optional< fs::path > path_to_curr_exe()
Yields std::nullopt if an error occurred.
Definition sys.cpp:27
std::string find_cmd(std::string)
Definition sys.cpp:64
std::string exec(std::string cmd)
Executes command cmd.
Definition sys.cpp:55
Definition cfg.h:11