aboutsummaryrefslogtreecommitdiffstats
path: root/util/system/execpath.cpp
diff options
context:
space:
mode:
authoryoda <yoda@yandex-team.ru>2022-02-10 16:50:00 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:50:00 +0300
commit86ac2045bfe9733d3396425a6ecade74c11ac489 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /util/system/execpath.cpp
parentddd64736134d6d92b80a934c8cf8228944ee4236 (diff)
downloadydb-86ac2045bfe9733d3396425a6ecade74c11ac489.tar.gz
Restoring authorship annotation for <yoda@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/system/execpath.cpp')
-rw-r--r--util/system/execpath.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/util/system/execpath.cpp b/util/system/execpath.cpp
index 21ae0f796d..33198af58b 100644
--- a/util/system/execpath.cpp
+++ b/util/system/execpath.cpp
@@ -18,10 +18,10 @@
#include <unistd.h>
#endif
-#include <util/folder/dirut.h>
-#include <util/generic/singleton.h>
+#include <util/folder/dirut.h>
+#include <util/generic/singleton.h>
#include <util/generic/function.h>
-#include <util/generic/yexception.h>
+#include <util/generic/yexception.h>
#include <util/memory/tempbuf.h>
#include <util/stream/file.h>
#include <util/stream/pipe.h>
@@ -102,31 +102,31 @@ static inline bool FreeBSDGuessExecBasePath(const TString& guessBasePath, TStrin
static TString GetExecPathImpl() {
#if defined(_solaris_)
- return execname();
+ return execname();
#elif defined(_darwin_)
TTempBuf execNameBuf;
for (size_t i = 0; i < 2; ++i) {
std::remove_pointer_t<TFunctionArg<decltype(_NSGetExecutablePath), 1>> bufsize = execNameBuf.Size();
- int r = _NSGetExecutablePath(execNameBuf.Data(), &bufsize);
- if (r == 0) {
- return execNameBuf.Data();
+ int r = _NSGetExecutablePath(execNameBuf.Data(), &bufsize);
+ if (r == 0) {
+ return execNameBuf.Data();
} else if (r == -1) {
execNameBuf = TTempBuf(bufsize);
}
- }
+ }
ythrow yexception() << "GetExecPathImpl() failed";
#elif defined(_win_)
TTempBuf execNameBuf;
- for (;;) {
+ for (;;) {
DWORD r = GetModuleFileName(nullptr, execNameBuf.Data(), execNameBuf.Size());
if (r == execNameBuf.Size()) {
execNameBuf = TTempBuf(execNameBuf.Size() * 2);
} else if (r == 0) {
ythrow yexception() << "GetExecPathImpl() failed: " << LastSystemErrorText();
} else {
- return execNameBuf.Data();
+ return execNameBuf.Data();
}
- }
+ }
#elif defined(_linux_) || defined(_cygwin_)
TString path("/proc/self/exe");
return NFs::ReadLink(path);
@@ -135,26 +135,26 @@ static TString GetExecPathImpl() {
TString execPath = FreeBSDGetExecPath();
if (GoodPath(execPath)) {
return execPath;
- }
+ }
if (FreeBSDGuessExecPath(FreeBSDGetArgv0(), execPath)) {
return execPath;
- }
+ }
if (FreeBSDGuessExecPath(getenv("_"), execPath)) {
return execPath;
- }
+ }
if (FreeBSDGuessExecBasePath(getenv("PWD"), execPath)) {
return execPath;
}
if (FreeBSDGuessExecBasePath(NFs::CurrentWorkingDirectory(), execPath)) {
return execPath;
}
-
+
ythrow yexception() << "can not resolve exec path";
#else
#error dont know how to implement GetExecPath on this platform
#endif
-}
-
+}
+
static bool GetPersistentExecPathImpl(TString& to) {
#if defined(_solaris_)
to = TString("/proc/self/object/a.out");