fix impellerc on windows (flutter/engine#33003)
This commit is contained in:
@@ -228,11 +228,6 @@ TEST(FileTest, CanStopVisitEarly) {
|
||||
ASSERT_TRUE(fml::UnlinkDirectory(dir.fd(), "a"));
|
||||
}
|
||||
|
||||
#if FML_OS_WIN
|
||||
#define AtomicWriteTest DISABLED_AtomicWriteTest
|
||||
#else
|
||||
#define AtomicWriteTest AtomicWriteTest
|
||||
#endif
|
||||
TEST(FileTest, AtomicWriteTest) {
|
||||
fml::ScopedTemporaryDirectory dir;
|
||||
|
||||
|
||||
@@ -375,6 +375,8 @@ bool FileExists(const fml::UniqueFD& base_directory, const char* path) {
|
||||
INVALID_FILE_ATTRIBUTES;
|
||||
}
|
||||
|
||||
// TODO(jonahwilliams): https://github.com/flutter/flutter/issues/102838 this is
|
||||
// not atomic on Windows.
|
||||
bool WriteAtomically(const fml::UniqueFD& base_directory,
|
||||
const char* file_name,
|
||||
const Mapping& mapping) {
|
||||
@@ -383,12 +385,8 @@ bool WriteAtomically(const fml::UniqueFD& base_directory,
|
||||
}
|
||||
|
||||
auto file_path = GetAbsolutePath(base_directory, file_name);
|
||||
std::stringstream stream;
|
||||
stream << file_path << ".temp";
|
||||
auto temp_file_path = stream.str();
|
||||
|
||||
auto temp_file =
|
||||
OpenFile(temp_file_path.c_str(), true, FilePermission::kReadWrite);
|
||||
OpenFile(file_path.c_str(), true, FilePermission::kReadWrite);
|
||||
|
||||
if (!temp_file.is_valid()) {
|
||||
FML_DLOG(ERROR) << "Could not create temporary file.";
|
||||
@@ -436,15 +434,6 @@ bool WriteAtomically(const fml::UniqueFD& base_directory,
|
||||
|
||||
temp_file.reset();
|
||||
|
||||
if (!::MoveFile(Utf8ToWideString(temp_file_path).c_str(),
|
||||
Utf8ToWideString(file_path).c_str())) {
|
||||
FML_DLOG(ERROR)
|
||||
<< "Could not replace temp file at correct path. File path: "
|
||||
<< file_path << ". Temp file path: " << temp_file_path << " "
|
||||
<< GetLastErrorMessage();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ bool Main(const fml::CommandLine& command_line) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto source_file_mapping = fml::FileMapping::CreateReadOnly(
|
||||
*switches.working_directory, switches.source_file_name);
|
||||
auto source_file_mapping =
|
||||
fml::FileMapping::CreateReadOnly(switches.source_file_name);
|
||||
if (!source_file_mapping) {
|
||||
std::cerr << "Could not open input file." << std::endl;
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user