Flutter Engine
The Flutter Engine
paths.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 "flutter/fml/paths.h"
6
7#include <sstream>
8
9#include "flutter/fml/build_config.h"
10
11namespace fml {
12namespace paths {
13
14std::string JoinPaths(std::initializer_list<std::string> components) {
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}
31
32std::string SanitizeURIEscapedCharacters(const std::string& str) {
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}
54
55std::pair<bool, std::string> GetExecutableDirectoryPath() {
56 auto path = GetExecutablePath();
57 if (!path.first) {
58 return {false, ""};
59 }
60 return {true, fml::paths::GetDirectoryName(path.second)};
61}
62
63} // namespace paths
64} // namespace fml
GAsyncResult * result
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
std::string JoinPaths(std::initializer_list< std::string > components)
Definition: paths.cc:14
std::pair< bool, std::string > GetExecutablePath()
std::pair< bool, std::string > GetExecutableDirectoryPath()
Definition: paths.cc:55
std::string SanitizeURIEscapedCharacters(const std::string &str)
Definition: paths.cc:32
std::string GetDirectoryName(const std::string &path)
Definition: paths_posix.cc:42
Definition: ascii_trie.cc:9
constexpr std::size_t size(T(&array)[N])
Definition: size.h:13