6#if defined(DART_HOST_OS_LINUX) || defined(DART_HOST_OS_ANDROID)
14#include <sys/sendfile.h>
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 int err = close(handle_->
fd());
67 handle_->set_fd(kClosedFd);
75 return handle_->
fd() == kClosedFd;
86 int flags = MAP_PRIVATE;
94 prot = PROT_READ | PROT_EXEC;
97 prot = PROT_READ | PROT_WRITE;
100 if (start !=
nullptr) {
106#if defined(DART_HOST_OS_LINUX)
112 if (
addr == MAP_FAILED && hint !=
nullptr && start ==
nullptr &&
113 Utils::IsWindowsSubsystemForLinux()) {
118 if (
addr == MAP_FAILED) {
122 return new MappedMemory(
addr,
length, start ==
nullptr);
125void MappedMemory::Unmap() {
126 int result = munmap(address_, size_);
144 va_list measure_args;
145 va_copy(measure_args,
args);
153 va_copy(print_args,
args);
184 ASSERT((end == -1) || (end > start));
201 fl.l_whence = SEEK_SET;
221File* File::FileOpenW(
const wchar_t* system_name, FileOpenMode
mode) {
227 return new File(
new FileHandle(fd));
231 NamespaceScope ns(namespc,
name);
236 if (!S_ISREG(st.st_mode) && !S_ISCHR(st.st_mode) && !S_ISFIFO(st.st_mode)) {
237 errno = (S_ISDIR(st.st_mode)) ? EISDIR : ENOENT;
241 int flags = O_RDONLY;
244 flags = (O_RDWR | O_CREAT);
248 flags = (O_WRONLY | O_CREAT);
270 (strlen(uri) >= 8 && strncmp(uri,
"file:///", 8) == 0) ? uri + 7 : uri;
271 UriDecoder uri_decoder(
path);
272 if (uri_decoder.decoded() ==
nullptr) {
281 if (
path ==
nullptr) {
288 return new File(
new FileHandle(fd));
292 NamespaceScope ns(namespc,
name);
296 return !S_ISDIR(st.st_mode) && !S_ISLNK(st.st_mode);
304 if (
path ==
nullptr) {
311 NamespaceScope ns(namespc,
name);
312 int flags = O_RDONLY | O_CREAT | O_CLOEXEC;
326 if (S_ISDIR(st.st_mode)) {
329 }
else if (S_ISLNK(st.st_mode)) {
341 NamespaceScope ns(namespc,
name);
345bool File::CreatePipe(Namespace* namespc, File** readPipe, File** writePipe) {
351 *readPipe =
OpenFD(pipe_fds[0]);
352 *writePipe =
OpenFD(pipe_fds[1]);
359 NamespaceScope ns(namespc,
name);
360 struct stat64 entry_info;
367 fstatat64(ns.fd(), ns.path(), &entry_info, AT_SYMLINK_NOFOLLOW));
369 if (stat_success == -1) {
372 if (S_ISDIR(entry_info.st_mode)) {
375 if (S_ISREG(entry_info.st_mode)) {
378 if (S_ISLNK(entry_info.st_mode)) {
381 if (S_ISSOCK(entry_info.st_mode)) {
384 if (S_ISFIFO(entry_info.st_mode)) {
404static bool CheckTypeAndSetErrno(Namespace* namespc,
409 if (actual == expected) {
419 NamespaceScope ns(namespc,
name);
427 NamespaceScope ns(namespc,
name);
428 return CheckTypeAndSetErrno(namespc,
name,
kIsLink,
false) &&
433 const char* old_path,
434 const char* new_path) {
437 NamespaceScope oldns(namespc, old_path);
438 NamespaceScope newns(namespc, new_path);
440 newns.path())) == 0);
447 const char* old_path,
448 const char* new_path) {
449 NamespaceScope oldns(namespc, old_path);
450 NamespaceScope newns(namespc, new_path);
451 return CheckTypeAndSetErrno(namespc, old_path,
kIsLink,
false) &&
453 newns.path())) == 0);
457 const char* old_path,
458 const char* new_path) {
464 NamespaceScope oldns(namespc, old_path);
470 openat64(oldns.fd(), oldns.path(), O_RDONLY | O_CLOEXEC));
474 NamespaceScope newns(namespc, new_path);
476 openat64(newns.fd(), newns.path(),
477 O_WRONLY | O_TRUNC | O_CREAT | O_CLOEXEC, st.st_mode));
491 if ((
result < 0) && ((errno == EINVAL) || (errno == ENOSYS))) {
515static bool StatHelper(Namespace* namespc,
518 NamespaceScope ns(namespc,
name);
523 if (S_ISDIR(st->st_mode)) {
533 if (!StatHelper(namespc,
name, &st)) {
539static int64_t TimespecToMilliseconds(
const struct timespec& t) {
540 return static_cast<int64_t
>(t.tv_sec) * 1000L +
541 static_cast<int64_t
>(t.tv_nsec) / 1000000L;
544static void MillisecondsToTimespec(int64_t millis,
struct timespec* t) {
551 NamespaceScope ns(namespc,
name);
554 if (S_ISREG(st.st_mode)) {
556 }
else if (S_ISDIR(st.st_mode)) {
558 }
else if (S_ISLNK(st.st_mode)) {
560 }
else if (S_ISSOCK(st.st_mode)) {
562 }
else if (S_ISFIFO(st.st_mode)) {
579 if (!StatHelper(namespc,
name, &st)) {
587 if (!StatHelper(namespc,
name, &st)) {
598 if (!StatHelper(namespc,
name, &st)) {
603 NamespaceScope ns(namespc,
name);
604 struct timespec
times[2];
605 MillisecondsToTimespec(millis, &
times[0]);
606 times[1] = st.st_mtim;
607 return utimensat(ns.fd(), ns.path(),
times, 0) == 0;
615 if (!StatHelper(namespc,
name, &st)) {
620 NamespaceScope ns(namespc,
name);
621 struct timespec
times[2];
622 times[0] = st.st_atim;
623 MillisecondsToTimespec(millis, &
times[1]);
624 return utimensat(ns.fd(), ns.path(),
times, 0) == 0;
631 NamespaceScope ns(namespc,
name);
632 struct stat64 link_stats;
634 fstatat64(ns.fd(), ns.path(), &link_stats, AT_SYMLINK_NOFOLLOW));
638 if (!S_ISLNK(link_stats.st_mode)) {
647 const int target_size =
649 if (target_size <= 0) {
652 if (
dest ==
nullptr) {
656 if (dest_size <= target_size) {
661 dest[target_size] =
'\0';
666 return (pathname !=
nullptr) && (pathname[0] ==
'/');
671 size_t result_size) {
672 ASSERT(pathname !=
nullptr);
674 struct stat64 link_stats;
678 if (!S_ISLNK(link_stats.st_mode)) {
684 if (target_size <= 0) {
688 if (target_size < result_size) {
689 result[target_size] =
'\0';
702 if (target_size <= 0) {
706 ASSERT(target_name !=
nullptr);
707 memmove(target_name,
target, target_size);
715 if (
name ==
nullptr) {
725 if (
dest ==
nullptr) {
733 }
while ((abs_path ==
nullptr) && (errno == EINTR));
735 ASSERT(abs_path ==
nullptr || (abs_path ==
dest));
753 if (S_ISCHR(buf.st_mode)) {
756 if (S_ISFIFO(buf.st_mode)) {
759 if (S_ISSOCK(buf.st_mode)) {
762 if (S_ISREG(buf.st_mode)) {
770 Namespace* namespc_2,
771 const char* file_2) {
772 struct stat64 file_1_info;
773 struct stat64 file_2_info;
776 NamespaceScope ns1(namespc_1, file_1);
778 fstatat64(ns1.fd(), ns1.path(), &file_1_info, AT_SYMLINK_NOFOLLOW));
784 NamespaceScope ns2(namespc_2, file_2);
786 fstatat64(ns2.fd(), ns2.path(), &file_2_info, AT_SYMLINK_NOFOLLOW));
791 return ((file_1_info.st_ino == file_2_info.st_ino) &&
792 (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 char * StrError(int err, char *buffer, size_t bufsize)
static char * ScopedCString(intptr_t length)
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)
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)
static const char * ReadLink(const char *pathname)
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 intptr_t ReadLinkInto(const char *pathname, char *result, size_t result_size)
static bool RenameLink(Namespace *namespc, const char *old_path, const char *new_path)
static bool IsDefault(Namespace *namespc)
FlutterSemanticsFlag flags
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
uint32_t uint32_t * format
CAllocUniquePtr< char > CStringUniquePtr
void * malloc(size_t size)
constexpr uint32_t kMaxUint32
DART_EXPORT char * Dart_Initialize(Dart_InitializeParams *params)
constexpr intptr_t kMillisecondsPerSecond
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 VOID_NO_RETRY_EXPECTED(expression)
#define TEMP_FAILURE_RETRY(expression)
void write(SkWStream *wStream, const T &text)