6#if defined(DART_HOST_OS_MACOS)
34 int fd()
const {
return fd_; }
35 void set_fd(
int fd) {
fd_ =
fd; }
44 if (!
IsClosed() && handle_->
fd() != STDOUT_FILENO &&
45 handle_->
fd() != STDERR_FILENO) {
53 if (handle_->
fd() == STDOUT_FILENO) {
60 intptr_t err = close(handle_->
fd());
68 handle_->set_fd(kClosedFd);
76 return handle_->
fd() == kClosedFd;
87 int map_flags = MAP_PRIVATE;
91 map_flags |= MAP_RESILIENT_CODESIGN;
96 prot = PROT_READ | PROT_EXEC;
97 if (IsAtLeastOS10_14()) {
98 map_flags |= (MAP_JIT | MAP_ANONYMOUS);
102 prot = PROT_READ | PROT_WRITE;
105 if (start !=
nullptr) {
107 map_flags |= MAP_FIXED;
114 if (
addr ==
nullptr) {
115 addr = mmap(hint,
length, (PROT_READ | PROT_WRITE), map_flags, -1, 0);
116 if (
addr == MAP_FAILED) {
122 const int64_t remaining_length =
Length() - position;
126 if (start ==
nullptr) {
134 if (
length > remaining_length) {
135 memset(
reinterpret_cast<uint8_t*
>(
addr) + remaining_length, 0,
136 length - remaining_length);
141 if (start ==
nullptr) {
147 addr = mmap(hint,
length, prot, map_flags, handle_->
fd(), position);
148 if (
addr == MAP_FAILED) {
153 return new MappedMemory(
addr,
length, start ==
nullptr);
156void MappedMemory::Unmap() {
157 int result = munmap(address_, size_);
176 va_list measure_args;
177 va_copy(measure_args,
args);
185 va_copy(print_args,
args);
196 return lseek(handle_->
fd(), 0, SEEK_CUR);
201 return lseek(handle_->
fd(), position, SEEK_SET) >= 0;
216 ASSERT((end == -1) || (end > start));
233 fl.l_whence = SEEK_SET;
253File* File::FileOpenW(
const wchar_t* system_name, FileOpenMode
mode) {
259 return new File(
new FileHandle(fd));
267 if (!S_ISREG(st.st_mode) && !S_ISCHR(st.st_mode) && !S_ISFIFO(st.st_mode)) {
268 errno = (S_ISDIR(st.st_mode)) ? EISDIR : ENOENT;
272 int flags = O_RDONLY;
275 flags = (O_RDWR | O_CREAT);
279 flags = (O_WRONLY | O_CREAT);
291 int64_t position = lseek(fd, 0, SEEK_END);
296 return new File(
new FileHandle(fd));
301 (strlen(uri) >= 8 && strncmp(uri,
"file:///", 8) == 0) ? uri + 7 : uri;
302 UriDecoder uri_decoder(
path);
303 if (uri_decoder.decoded() ==
nullptr) {
312 if (
path ==
nullptr) {
319 return new File(
new FileHandle(fd));
326 return !S_ISDIR(st.st_mode) && !S_ISLNK(st.st_mode);
334 if (
path ==
nullptr) {
341 int flags = O_RDONLY | O_CREAT;
355 if (S_ISDIR(st.st_mode)) {
358 }
else if (S_ISLNK(st.st_mode)) {
371 return (status == 0);
374bool File::CreatePipe(Namespace* namespc, File** readPipe, File** writePipe) {
380 *readPipe =
OpenFD(pipe_fds[0]);
381 *writePipe =
OpenFD(pipe_fds[1]);
386 const char* pathname,
388 struct stat entry_info;
395 if (stat_success == -1) {
398 if (S_ISDIR(entry_info.st_mode)) {
401 if (S_ISREG(entry_info.st_mode)) {
404 if (S_ISLNK(entry_info.st_mode)) {
407 if (S_ISSOCK(entry_info.st_mode)) {
410 if (S_ISFIFO(entry_info.st_mode)) {
430static bool CheckTypeAndSetErrno(Namespace* namespc,
435 if (actual == expected) {
452 return CheckTypeAndSetErrno(namespc,
name,
kIsLink,
false) &&
457 const char* old_path,
458 const char* new_path) {
468 const char* old_path,
469 const char* new_path) {
470 return CheckTypeAndSetErrno(namespc, old_path,
kIsLink,
false) &&
475 const char* old_path,
476 const char* new_path) {
479 return (copyfile(old_path, new_path,
nullptr, COPYFILE_ALL) == 0);
485static bool StatHelper(Namespace* namespc,
const char*
name,
struct stat* st) {
490 if (S_ISDIR(st->st_mode)) {
500 if (!StatHelper(namespc,
name, &st)) {
506static int64_t TimespecToMilliseconds(
const struct timespec& t) {
507 return static_cast<int64_t
>(t.tv_sec) * 1000L +
508 static_cast<int64_t
>(t.tv_nsec) / 1000000L;
514 if (S_ISREG(st.st_mode)) {
516 }
else if (S_ISDIR(st.st_mode)) {
518 }
else if (S_ISLNK(st.st_mode)) {
520 }
else if (S_ISSOCK(st.st_mode)) {
522 }
else if (S_ISFIFO(st.st_mode)) {
542 if (!StatHelper(namespc,
name, &st)) {
550 if (!StatHelper(namespc,
name, &st)) {
561 if (!StatHelper(namespc,
name, &st)) {
566 struct utimbuf
times;
568 times.modtime = st.st_mtime;
577 if (!StatHelper(namespc,
name, &st)) {
582 struct utimbuf
times;
583 times.actime = st.st_atime;
589 const char* pathname,
592 struct stat link_stats;
593 if (lstat(pathname, &link_stats) != 0) {
596 if (!S_ISLNK(link_stats.st_mode)) {
606 if (target_size <= 0) {
609 if (
dest ==
nullptr) {
613 if (
static_cast<size_t>(dest_size) <= target_size) {
618 dest[target_size] =
'\0';
623 return (pathname !=
nullptr && pathname[0] ==
'/');
627 const char* pathname,
630 char* abs_path =
nullptr;
631 if (pathname !=
nullptr) {
635 if (
dest ==
nullptr) {
641 abs_path = realpath(pathname,
dest);
642 }
while ((abs_path ==
nullptr) && (errno == EINTR));
644 ASSERT((abs_path ==
nullptr) || (abs_path ==
dest));
659 int result = fstat(fd, &buf);
663 if (S_ISCHR(buf.st_mode)) {
666 if (S_ISFIFO(buf.st_mode)) {
669 if (S_ISSOCK(buf.st_mode)) {
672 if (S_ISREG(buf.st_mode)) {
680 Namespace* namespc_2,
681 const char* file_2) {
684 struct stat file_1_info;
685 struct stat file_2_info;
690 return ((file_1_info.st_ino == file_2_info.st_ino) &&
691 (file_1_info.st_dev == file_2_info.st_dev))
static SkISize times(const SkISize &size, float factor)
static bool read(SkStream *stream, void *buffer, size_t amount)
static const size_t kBufferSize
static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
static int static int VSNPrint(char *str, size_t size, const char *format, va_list args)
static T Minimum(T x, T y)
static char * StrError(int err, char *buffer, size_t bufsize)
static char * ScopedCString(intptr_t length)
static bool SetCloseOnExec(intptr_t fd)
static void SaveErrorAndClose(intptr_t fd)
FileHandle(HANDLE handle)
static bool CreatePipe(Namespace *namespc, File **readPipe, File **writePipe)
static bool DeleteLink(Namespace *namespc, const char *path)
static bool IsAbsolutePath(const char *path)
MappedMemory * Map(MapType type, int64_t position, int64_t length, void *start=nullptr)
static const char * GetCanonicalPath(Namespace *namespc, const char *path, char *dest=nullptr, int dest_size=0)
static CStringUniquePtr UriToPath(const char *uri)
int64_t Read(void *buffer, int64_t num_bytes)
static bool SetLastAccessed(Namespace *namespc, const char *path, int64_t millis)
static File * OpenUri(Namespace *namespc, const char *uri, FileOpenMode mode)
static bool SetLastModified(Namespace *namespc, const char *path, int64_t millis)
static time_t LastModified(Namespace *namespc, const char *path)
static void Stat(Namespace *namespc, const char *path, int64_t *data)
static const char * PathSeparator()
static bool Create(Namespace *namespc, const char *path, bool exclusive)
bool VPrint(const char *format, va_list args)
static bool Rename(Namespace *namespc, const char *old_path, const char *new_path)
static bool Delete(Namespace *namespc, const char *path)
static const char * StringEscapedPathSeparator()
bool WriteFully(const void *buffer, int64_t num_bytes)
static int64_t LengthFromPath(Namespace *namespc, const char *path)
bool ReadFully(void *buffer, int64_t num_bytes)
static bool Copy(Namespace *namespc, const char *old_path, const char *new_path)
static time_t LastAccessed(Namespace *namespc, const char *path)
int64_t Write(const void *buffer, int64_t num_bytes)
static bool Exists(Namespace *namespc, const char *path)
static File * Open(Namespace *namespc, const char *path, FileOpenMode mode)
bool Lock(LockType lock, int64_t start, int64_t end)
bool SetPosition(int64_t position)
static Identical AreIdentical(Namespace *namespc_1, const char *file_1, Namespace *namespc_2, const char *file_2)
static File * OpenFD(int fd)
static const char * LinkTarget(Namespace *namespc, const char *pathname, char *dest=nullptr, int dest_size=0)
static bool CreateLink(Namespace *namespc, const char *path, const char *target)
static bool ExistsUri(Namespace *namespc, const char *uri)
static File * OpenStdio(int fd)
static StdioHandleType GetStdioHandleType(int fd)
static Type GetType(Namespace *namespc, const char *path, bool follow_links)
bool Truncate(int64_t length)
static bool RenameLink(Namespace *namespc, const char *old_path, const char *new_path)
FlutterSemanticsFlag flags
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
uint32_t uint32_t * format
CAllocUniquePtr< char > CStringUniquePtr
void * malloc(size_t size)
DART_EXPORT char * Dart_Initialize(Dart_InitializeParams *params)
constexpr intptr_t kMillisecondsPerSecond
constexpr int32_t kMaxInt32
static int8_t data[kExtLength]
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
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 to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
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 mode
char * strdup(const char *str1)
#define NO_RETRY_EXPECTED(expression)
#define VOID_TEMP_FAILURE_RETRY(expression)
#define TEMP_FAILURE_RETRY(expression)
void write(SkWStream *wStream, const T &text)