5#include "flutter/fml/file.h"
17#include "flutter/fml/eintr_wrapper.h"
18#include "flutter/fml/logging.h"
19#include "flutter/fml/mapping.h"
20#include "flutter/fml/trace_event.h"
21#include "flutter/fml/unique_fd.h"
26 char directory_name[] =
"/tmp/flutter_XXXXXXXX";
27 auto*
result = ::mkdtemp(directory_name);
60 mode |= S_IRUSR | S_IWUSR;
67 bool create_if_necessary,
75 bool create_if_necessary,
78 if (
path ==
nullptr) {
98 bool create_if_necessary,
106 bool create_if_necessary,
108 if (
path ==
nullptr) {
113 if (::mkdirat(base_directory.
get(),
path,
120 ::openat(base_directory.
get(),
path, O_RDONLY | O_DIRECTORY))};
132 struct stat stat_result = {};
134 if (::fstat(directory.
get(), &stat_result) != 0) {
138 return S_ISDIR(stat_result.st_mode);
148 if (stat(
path.c_str(), &buf) != 0) {
152 return S_ISREG(buf.st_mode);
156 if (!
file.is_valid()) {
160 return ::ftruncate(
file.get(),
size) == 0;
168 return ::unlinkat(base_directory.
get(),
path, AT_REMOVEDIR) == 0;
176 int code = ::unlinkat(base_directory.
get(),
path, 0);
188 return ::faccessat(base_directory.
get(),
path, F_OK, 0) == 0;
192 const char* file_name,
194 if (file_name ==
nullptr ||
data.GetMapping() ==
nullptr) {
199 stream << file_name <<
".temp";
200 const auto temp_file_name =
stream.str();
202 auto temp_file =
OpenFile(base_directory, temp_file_name.c_str(),
true,
204 if (!temp_file.is_valid()) {
212 ssize_t remaining =
data.GetSize();
216 while (remaining > 0) {
228 if (::fsync(temp_file.get()) != 0) {
232 return ::renameat(base_directory.
get(), temp_file_name.c_str(),
233 base_directory.
get(), file_name) == 0;
239 FML_DLOG(
ERROR) <<
"Can't dup the directory fd. Error: " << strerror(errno);
244 if (!
dir.is_valid()) {
245 FML_DLOG(
ERROR) <<
"Can't open the directory. Error: " << strerror(errno);
255 rewinddir(
dir.get());
256 while (dirent* ent = readdir(
dir.get())) {
257 std::string filename = ent->d_name;
258 if (filename !=
"." && filename !=
"..") {
259 if (!visitor(directory, filename)) {
FlutterSemanticsFlag flags
#define FML_HANDLE_EINTR(x)
#define FML_DLOG(severity)
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 Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets dir
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
fml::UniqueFD OpenFileReadOnly(const fml::UniqueFD &base_directory, const char *path)
bool VisitFiles(const fml::UniqueFD &directory, const FileVisitor &visitor)
static int ToPosixCreateModeFlags(FilePermission permission)
constexpr std::size_t size(T(&array)[N])
bool WriteAtomically(const fml::UniqueFD &base_directory, const char *file_name, const Mapping &mapping)
fml::UniqueFD Duplicate(fml::UniqueFD::element_type descriptor)
fml::UniqueFD OpenDirectory(const char *path, bool create_if_necessary, FilePermission permission)
bool IsFile(const std::string &path)
static int ToPosixAccessFlags(FilePermission permission)
std::string CreateTemporaryDirectory()
bool UnlinkDirectory(const char *path)
bool TruncateFile(const fml::UniqueFD &file, size_t size)
bool FileExists(const fml::UniqueFD &base_directory, const char *path)
bool UnlinkFile(const char *path)
fml::UniqueFD OpenFile(const char *path, bool create_if_necessary, FilePermission permission)
This can open a directory on POSIX, but not on Windows.
std::function< bool(const fml::UniqueFD &directory, const std::string &filename)> FileVisitor
bool IsDirectory(const fml::UniqueFD &directory)
void write(SkWStream *wStream, const T &text)
std::shared_ptr< const fml::Mapping > data
#define TRACE_EVENT0(category_group, name)