Flutter Engine
The Flutter Engine
Functions | Variables
fml::paths Namespace Reference

Functions

std::string JoinPaths (std::initializer_list< std::string > components)
 
std::string SanitizeURIEscapedCharacters (const std::string &str)
 
std::pair< bool, std::string > GetExecutableDirectoryPath ()
 
std::pair< bool, std::string > GetExecutablePath ()
 
fml::UniqueFD GetCachesDirectory ()
 
std::string AbsolutePath (const std::string &path)
 
std::string GetDirectoryName (const std::string &path)
 
std::string FromURI (const std::string &uri)
 
void InitializeAndroidCachesPath (std::string caches_path)
 

Variables

static std::string gCachesPath
 

Function Documentation

◆ AbsolutePath()

std::string fml::paths::AbsolutePath ( const std::string &  path)

Definition at line 29 of file paths_posix.cc.

29 {
30 if (!path.empty()) {
31 if (path[0] == '/') {
32 // Path is already absolute.
33 return path;
34 }
35 return GetCurrentDirectory() + "/" + path;
36 } else {
37 // Path is empty.
38 return GetCurrentDirectory();
39 }
40}
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57
#define GetCurrentDirectory

◆ FromURI()

std::string fml::paths::FromURI ( const std::string &  uri)

Definition at line 53 of file paths_posix.cc.

53 {
54 if (uri.substr(0, kFileURLPrefixLength) != kFileURLPrefix) {
55 return uri;
56 }
57
58 std::string file_path = uri.substr(kFileURLPrefixLength);
59 return SanitizeURIEscapedCharacters(file_path);
60}
std::string SanitizeURIEscapedCharacters(const std::string &str)
Definition: paths.cc:32

◆ GetCachesDirectory()

fml::UniqueFD fml::paths::GetCachesDirectory ( )

Definition at line 22 of file paths_android.cc.

22 {
23 // If the caches path is not initialized, the FD will be invalid and caching
24 // will be disabled throughout the system.
26}
static std::string gCachesPath
fml::UniqueFD OpenDirectory(const char *path, bool create_if_necessary, FilePermission permission)
Definition: file_posix.cc:97

◆ GetDirectoryName()

std::string fml::paths::GetDirectoryName ( const std::string &  path)

Definition at line 42 of file paths_posix.cc.

42 {
43 size_t separator = path.rfind('/');
44 if (separator == 0u) {
45 return "/";
46 }
47 if (separator == std::string::npos) {
48 return std::string();
49 }
50 return path.substr(0, separator);
51}

◆ GetExecutableDirectoryPath()

std::pair< bool, std::string > fml::paths::GetExecutableDirectoryPath ( )

Definition at line 55 of file paths.cc.

55 {
56 auto path = GetExecutablePath();
57 if (!path.first) {
58 return {false, ""};
59 }
60 return {true, fml::paths::GetDirectoryName(path.second)};
61}
std::pair< bool, std::string > GetExecutablePath()
std::string GetDirectoryName(const std::string &path)
Definition: paths_posix.cc:42

◆ GetExecutablePath()

std::pair< bool, std::string > fml::paths::GetExecutablePath ( )

Definition at line 12 of file paths_android.cc.

12 {
13 return {false, ""};
14}

◆ InitializeAndroidCachesPath()

void fml::paths::InitializeAndroidCachesPath ( std::string  caches_path)

Definition at line 18 of file paths_android.cc.

18 {
19 gCachesPath = std::move(caches_path);
20}

◆ JoinPaths()

std::string fml::paths::JoinPaths ( std::initializer_list< std::string >  components)

Definition at line 14 of file paths.cc.

14 {
15 std::stringstream stream;
16 size_t i = 0;
17 const size_t size = components.size();
18 for (const auto& component : components) {
19 i++;
20 stream << component;
21 if (i != size) {
22#if FML_OS_WIN
23 stream << "\\";
24#else // FML_OS_WIN
25 stream << "/";
26#endif // FML_OS_WIN
27 }
28 }
29 return stream.str();
30}
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259

◆ SanitizeURIEscapedCharacters()

std::string fml::paths::SanitizeURIEscapedCharacters ( const std::string &  str)

Definition at line 32 of file paths.cc.

32 {
33 std::string result;
34 result.reserve(str.size());
35 for (std::string::size_type i = 0; i < str.size(); ++i) {
36 if (str[i] == '%') {
37 if (i > str.size() - 3 || !isxdigit(str[i + 1]) ||
38 !isxdigit(str[i + 2])) {
39 return "";
40 }
41 const std::string hex = str.substr(i + 1, 2);
42 const unsigned char c = strtoul(hex.c_str(), nullptr, 16);
43 if (!c) {
44 return "";
45 }
46 result += c;
47 i += 2;
48 } else {
49 result += str[i];
50 }
51 }
52 return result;
53}
GAsyncResult * result

Variable Documentation

◆ gCachesPath

std::string fml::paths::gCachesPath
static

Definition at line 16 of file paths_android.cc.