Add GetExecutablePath to utils/file

Reviewers: mferencevic

Reviewed By: mferencevic

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D2713
This commit is contained in:
Teon Banek 2020-03-09 10:26:20 +01:00
parent fbdcad1106
commit d0411510fa
2 changed files with 10 additions and 0 deletions

View File

@ -13,6 +13,10 @@
namespace utils {
std::filesystem::path GetExecutablePath() {
return std::filesystem::read_symlink("/proc/self/exe");
}
std::vector<std::string> ReadLines(const std::filesystem::path &path) noexcept {
std::vector<std::string> lines;

View File

@ -14,6 +14,12 @@
namespace utils {
/// Get the path of the current executable.
///
/// @throw std::filesystem::filesystem_error
/// @throw std::bad_alloc
std::filesystem::path GetExecutablePath();
/// Reads all lines from the file specified by path. If the file doesn't exist
/// or there is an access error the function returns an empty list.
std::vector<std::string> ReadLines(const std::filesystem::path &path) noexcept;