1 // Copyright 2020 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include <limits.h>
6 #include <unistd.h>
7 
8 #include "platform/test/paths_internal.h"
9 #include "util/std_util.h"
10 
11 namespace openscreen {
12 
GetExePath()13 std::string GetExePath() {
14   std::string path(_POSIX_PATH_MAX, 0);
15   int ret = readlink("/proc/self/exe", data(path), path.size());
16   if (ret < 0) {
17     path.resize(0);
18   } else {
19     path.resize(ret);
20   }
21   return path;
22 }
23 
24 }  // namespace openscreen
25