liyuqian 358e88cabf Revert "Only allow mappings for ICU initialization. (#8656)" (flutter/engine#8682)
This reverts commit dfaa1c9292238e73c56d36f7264adc63ea53745c.

Reverts flutter/engine#8656

Reason:  https://github.com/flutter/engine/pull/8656 seems to break the framework windows tests and the engine roll (see https://cirrus-ci.com/task/4704667236827136 and https://github.com/flutter/flutter/pull/31330). The failure has been consistent for 7 consecutive engine-to-framework auto-rolls.

TBR: @chinmaygarde
2019-04-22 10:28:54 -07:00

62 lines
1.6 KiB
C++

// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/fml/file.h"
#include "flutter/fml/logging.h"
namespace fml {
static fml::UniqueFD CreateDirectory(const fml::UniqueFD& base_directory,
const std::vector<std::string>& components,
FilePermission permission,
size_t index) {
FML_DCHECK(index <= components.size());
const char* file_path = components[index].c_str();
auto directory = OpenDirectory(base_directory, file_path, true, permission);
if (!directory.is_valid()) {
return {};
}
if (index == components.size() - 1) {
return directory;
}
return CreateDirectory(directory, components, permission, index + 1);
}
fml::UniqueFD CreateDirectory(const fml::UniqueFD& base_directory,
const std::vector<std::string>& components,
FilePermission permission) {
if (!IsDirectory(base_directory)) {
return {};
}
if (components.size() == 0) {
return {};
}
return CreateDirectory(base_directory, components, permission, 0);
}
ScopedTemporaryDirectory::ScopedTemporaryDirectory() {
path_ = CreateTemporaryDirectory();
if (path_ != "") {
dir_fd_ = OpenDirectory(path_.c_str(), false, FilePermission::kRead);
}
}
ScopedTemporaryDirectory::~ScopedTemporaryDirectory() {
if (path_ != "") {
if (!UnlinkDirectory(path_.c_str())) {
FML_LOG(ERROR) << "Could not remove directory: " << path_;
}
}
}
} // namespace fml