10#include <fuchsia/io/cpp/fidl.h>
11#include <fuchsia/mem/cpp/fidl.h>
12#include <lib/fdio/directory.h>
13#include <lib/fdio/io.h>
14#include <zircon/status.h>
18#include "flutter/fml/logging.h"
22bool VmoFromFd(
int fd,
bool executable, fuchsia::mem::Buffer*
buffer) {
27 struct stat stat_struct;
28 if (fstat(fd, &stat_struct) == -1) {
33 zx_handle_t
result = ZX_HANDLE_INVALID;
36 status = fdio_get_vmo_exec(fd, &
result);
38 status = fdio_get_vmo_copy(fd, &
result);
41 if (status != ZX_OK) {
42 FML_LOG(
ERROR) << (executable ?
"fdio_get_vmo_exec" :
"fdio_get_vmo_copy")
43 <<
" failed: " << zx_status_get_string(status);
48 buffer->size = stat_struct.st_size;
59 fuchsia::mem::Buffer*
buffer) {
63 auto flags = fuchsia::io::OpenFlags::RIGHT_READABLE;
65 flags |= fuchsia::io::OpenFlags::RIGHT_EXECUTABLE;
69 const zx_status_t status =
70 fdio_open_fd(filename.c_str(),
static_cast<uint32_t
>(
flags), &fd);
71 if (status != ZX_OK) {
72 FML_LOG(
ERROR) <<
"fdio_open_fd(\"" << filename <<
"\", " << std::hex
73 <<
static_cast<uint32_t
>(
flags)
74 <<
") failed: " << zx_status_get_string(status);
83 const std::string& filename,
85 fuchsia::mem::Buffer*
buffer) {
86 auto flags = fuchsia::io::OpenFlags::RIGHT_READABLE;
88 flags |= fuchsia::io::OpenFlags::RIGHT_EXECUTABLE;
92 const zx_status_t status = fdio_open_fd_at(dirfd, filename.c_str(),
93 static_cast<uint32_t
>(
flags), &fd);
94 if (status != ZX_OK) {
95 FML_LOG(
ERROR) <<
"fdio_open_fd_at(" << dirfd <<
", \"" << filename
96 <<
"\", " << std::hex << static_cast<uint32_t>(
flags)
97 <<
") failed: " << zx_status_get_string(status);
107 zx_status_t status =
buffer.vmo.get_size(&vmo_size);
108 if (status == ZX_OK) {
static bool is_valid(SkISize dim)
FlutterSemanticsFlag flags
static const uint8_t buffer[]
#define FML_LOG(severity)
bool VmoFromFilenameAt(int dirfd, const std::string &filename, bool executable, fuchsia::mem::Buffer *buffer)
bool VmoFromFilename(const std::string &filename, bool executable, fuchsia::mem::Buffer *buffer)
zx_status_t IsSizeValid(const fuchsia::mem::Buffer &buffer, bool *is_valid)