From 6d7e9444f17f2b50b752f12c07fa997dff58f391 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roger=20D=C3=ADaz=20Vi=C3=B1olas?= Date: Sun, 2 Jan 2022 18:21:04 +0100 Subject: [PATCH] Fix templates not being found --- configure.py | 2 +- src/main.cc | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/configure.py b/configure.py index 625c743..89076d5 100755 --- a/configure.py +++ b/configure.py @@ -8,7 +8,7 @@ from ninja_syntax import Writer COMPILER = "g++" -APP_VERSION = "2.0" +APP_VERSION = "2.1" INCLUDES_REGEX = re.compile('#include\s+"(.*)"') diff --git a/src/main.cc b/src/main.cc index 575da10..5d73252 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,6 +1,7 @@ #include #include +#include #include "colors.h" #include "problem.h" @@ -15,13 +16,19 @@ using namespace std; -int main(int argc, char** argv) { +const int BUFFSIZE = 1024; + +int main() { cout << "Advocat v" << APP_VERSION << " by Roger Díaz Viñolas (rdvdev2@gmail.com)" << endl; - if (argc < 1) { + char buf[BUFFSIZE]; + auto len = readlink("/proc/self/exe", buf, BUFFSIZE); + if (len != -1) buf[len] = '\0'; + else { show_error("Can't find the templates"); + return 1; } - filesystem::path binary_dir = filesystem::path(argv[0]).parent_path(); + filesystem::path binary_dir = filesystem::path(buf).parent_path(); Problem p; filesystem::path cwd = filesystem::current_path();