Flutter Engine
paths_linux.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter 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 <unistd.h>
6 
7 #include "flutter/fml/paths.h"
8 
9 namespace fml {
10 namespace paths {
11 
12 std::pair<bool, std::string> GetExecutableDirectoryPath() {
13  const int path_size = 255;
14  char path[path_size] = {0};
15  auto read_size = ::readlink("/proc/self/exe", path, path_size);
16  if (read_size == -1) {
17  return {false, ""};
18  }
19  return {true, fml::paths::GetDirectoryName(
20  std::string{path, static_cast<size_t>(read_size)})};
21 }
22 
24  // Unsupported on this platform.
25  return {};
26 }
27 
28 } // namespace paths
29 } // namespace fml
DEF_SWITCHES_START snapshot asset path
Definition: switches.h:32
fml::UniqueFD GetCachesDirectory()
Definition: ascii_trie.cc:9
std::string GetDirectoryName(const std::string &path)
Definition: paths_posix.cc:42
std::pair< bool, std::string > GetExecutableDirectoryPath()