Flutter Engine
 
Loading...
Searching...
No Matches
vmservice_object.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 "vmservice_object.h"
6
7#include <dirent.h>
8#include <fuchsia/io/cpp/fidl.h>
9#include <sys/stat.h>
10#include <zircon/status.h>
11
12#include <cerrno>
13#include <string>
14
15#include "flutter/fml/logging.h"
16
17namespace {
18
19bool ReadDirContents(const std::string& path, std::vector<std::string>* out) {
20 out->clear();
21 DIR* dir = opendir(path.c_str());
22 if (!dir) {
23 return false;
24 }
25 struct dirent* de;
26 errno = 0;
27 while ((de = readdir(dir)) != nullptr) {
28 out->push_back(de->d_name);
29 }
30 closedir(dir);
31 return !errno;
32}
33
34} // namespace
35
36namespace dart_utils {
37
38void VMServiceObject::GetContents(LazyEntryVector* out_vector) const {
39 // List /tmp/dart.services if it exists, and push its contents as
40 // the contents of this directory.
41 std::vector<std::string> files;
42 if (!ReadDirContents(kPortDir, &files)) {
43 FML_LOG(ERROR) << "Failed to read Dart VM service port directory '"
44 << kPortDir << "': " << strerror(errno);
45 return;
46 }
47 for (const auto& file : files) {
48 if ((file == ".") || (file == "..")) {
49 continue;
50 }
51 out_vector->push_back({std::stoul(file) + GetStartingId(), file, S_IFREG});
52 }
53}
54
55zx_status_t VMServiceObject::GetFile(Node** out_node,
56 uint64_t id,
57 std::string name) const {
58 return ZX_ERR_NOT_FOUND;
59}
60
61} // namespace dart_utils
void GetContents(LazyEntryVector *out_vector) const override
zx_status_t GetFile(Node **out_node, uint64_t id, std::string name) const override
static constexpr const char * kPortDir
#define FML_LOG(severity)
Definition logging.h:101
const char * name
Definition fuchsia.cc:49
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 switch_defs.h:52