5#include "flutter/fml/icu_util.h"
10#include "flutter/fml/build_config.h"
11#include "flutter/fml/logging.h"
12#include "flutter/fml/mapping.h"
13#include "flutter/fml/native_library.h"
14#include "flutter/fml/paths.h"
15#include "third_party/icu/source/common/unicode/udata.h"
27 : mapping_(
std::move(mapping)) {
42 if (!directory.first) {
46 std::string path_relative_to_executable =
49 fd =
fml::OpenFile(path_relative_to_executable.c_str(),
false,
57 std::initializer_list<FileMapping::Protection> protection = {
60 auto file_mapping = std::make_unique<FileMapping>(fd, protection);
62 if (file_mapping->GetSize() != 0) {
63 mapping_ = std::move(file_mapping);
75 UErrorCode err_code = U_ZERO_ERROR;
77 return (err_code == U_ZERO_ERROR);
81 return mapping_ ? mapping_->GetMapping() :
nullptr;
84 size_t GetSize()
const {
return mapping_ ? mapping_->GetSize() : 0; }
90 std::unique_ptr<Mapping> mapping_;
98 <<
"Must be able to initialize the ICU context. Tried: " << icu_data_path;
110 <<
"Unable to initialize the ICU context from a mapping.";
114 std::call_once(
g_icu_init_flag, [mapping = std::move(mapping)]()
mutable {
ICUContext(std::unique_ptr< Mapping > mapping)
bool SetupMapping(const std::string &icu_data_path)
ICUContext(const std::string &icu_data_path)
const uint8_t * GetMapping() const
#define FML_CHECK(condition)
void InitializeICU(const std::string &icu_data_path)
void InitializeICUFromMapping(std::unique_ptr< Mapping > mapping)
void InitializeICUFromMappingOnce(std::unique_ptr< Mapping > mapping)
void InitializeICUOnce(const std::string &icu_data_path)
std::once_flag g_icu_init_flag
std::string JoinPaths(std::initializer_list< std::string > components)
std::pair< bool, std::string > GetExecutableDirectoryPath()
fml::UniqueFD OpenFile(const char *path, bool create_if_necessary, FilePermission permission)
This can open a directory on POSIX, but not on Windows.