From b9a8b87cf141b669cc956c8149dc185e715dfb39 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Tue, 19 Aug 2014 22:20:59 -0400 Subject: [PATCH] Added directory location code for Linux --- src/openalpr/support/platform.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/openalpr/support/platform.cpp b/src/openalpr/support/platform.cpp index a14cd26..72a26c5 100644 --- a/src/openalpr/support/platform.cpp +++ b/src/openalpr/support/platform.cpp @@ -26,6 +26,20 @@ std::string getExeDir() } return directory; #else - return ""; + char buffer[2048]; + + readlink("/proc/self/exe", buffer, 2048); + + std::stringstream ss; + ss << buffer; + std::string exeFile = ss.str(); + std::string directory; + + const size_t last_slash_idx = exeFile.rfind('/'); + if (std::string::npos != last_slash_idx) + { + directory = exeFile.substr(0, last_slash_idx); + } + return directory; #endif } \ No newline at end of file