Thorin 1.9.0
The Higher ORder 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 THORIN_WHICH "where"
9#else
10# define THORIN_WHICH "which"
11#endif
12
13namespace thorin {
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 thorin
std::string find_cmd(std::string)
Definition sys.cpp:64
std::optional< fs::path > path_to_curr_exe()
Yields std::nullopt if an error occurred.
Definition sys.cpp:27
int system(std::string)
Wraps std::system and makes the return value usable.
Definition sys.cpp:70
std::string exec(std::string cmd)
Executes command cmd.
Definition sys.cpp:55
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
Definition cfg.h:11