Flutter Engine
The Flutter Engine
SkGetExecutablePath_linux.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2022 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
9#include <cstddef>
10#include <linux/limits.h>
11#include <sys/types.h>
12#include <unistd.h>
13
14// Note that /proc/self/exe is Linux-specific; this won't work on other UNIX systems.
15
16std::string SkGetExecutablePath() {
17 std::string result(PATH_MAX, '\0');
18 ssize_t len = readlink("/proc/self/exe", result.data(), result.size() - 1);
19 if (len < 0 || static_cast<size_t>(len) >= PATH_MAX - 1) {
20 result.clear();
21 } else {
22 result.resize(len);
23 }
24 return result;
25}
std::string SkGetExecutablePath()
GAsyncResult * result
#define PATH_MAX
Definition: globals.h:708