@@ -63,8 +63,9 @@ bool CreateFile(const std::string& content, |
63 | 63 | if (!base::CreateTemporaryFile(file_path)) |
64 | 64 | return false; |
65 | 65 |
|
66 | | - if (base::WriteFile(*file_path, content.data(), content.size()) == -1) |
| 66 | + if (!base::WriteFile(*file_path, content)) { |
67 | 67 | return false; |
| 68 | + } |
68 | 69 |
|
69 | 70 | *file = base::File( |
70 | 71 | *file_path, base::File::Flags::FLAG_OPEN | base::File::Flags::FLAG_READ); |
@@ -350,7 +351,7 @@ class ZipTest : public PlatformTest { |
350 | 351 | base::Time now_time; |
351 | 352 | EXPECT_TRUE(base::Time::FromUTCExploded(now_parts, &now_time)); |
352 | 353 |
|
353 | | - EXPECT_EQ(1, base::WriteFile(src_file, "1", 1)); |
| 354 | + EXPECT_TRUE(base::WriteFile(src_file, "1")); |
354 | 355 | EXPECT_TRUE(base::TouchFile(src_file, base::Time::Now(), test_mtime)); |
355 | 356 |
|
356 | 357 | EXPECT_TRUE(zip::Zip(src_dir, zip_file, true)); |
@@ -748,6 +749,8 @@ TEST_F(ZipTest, UnzipMixedPaths) { |
748 | 749 | "Space→", // |
749 | 750 | #else |
750 | 751 | " ", // |
| 752 | + "...", // Disappears on Windows |
| 753 | + "....", // Disappears on Windows |
751 | 754 | "AUX", // Disappears on Windows |
752 | 755 | "COM1", // Disappears on Windows |
753 | 756 | "COM2", // Disappears on Windows |
@@ -1113,9 +1116,9 @@ TEST_F(ZipTest, UnzipFilesWithIncorrectSize) { |
1113 | 1116 | SCOPED_TRACE(base::StringPrintf("Processing %d.txt", i)); |
1114 | 1117 | base::FilePath file_path = |
1115 | 1118 | temp_dir.AppendASCII(base::StringPrintf("%d.txt", i)); |
1116 | | - int64_t file_size = -1; |
1117 | | - EXPECT_TRUE(base::GetFileSize(file_path, &file_size)); |
1118 | | - EXPECT_EQ(static_cast<int64_t>(i), file_size); |
| 1119 | + std::optional<int64_t> file_size = base::GetFileSize(file_path); |
| 1120 | + EXPECT_TRUE(file_size.has_value()); |
| 1121 | + EXPECT_EQ(static_cast<int64_t>(i), file_size.value()); |
1119 | 1122 | } |
1120 | 1123 | } |
1121 | 1124 |
|
@@ -1306,10 +1309,10 @@ TEST_F(ZipTest, Compressed) { |
1306 | 1309 |
|
1307 | 1310 | // Since the source files compress well, the destination ZIP file should be |
1308 | 1311 | // smaller than the source files. |
1309 | | - int64_t dest_file_size; |
1310 | | - ASSERT_TRUE(base::GetFileSize(dest_file, &dest_file_size)); |
1311 | | - EXPECT_GT(dest_file_size, 300); |
1312 | | - EXPECT_LT(dest_file_size, 1000); |
| 1312 | + std::optional<int64_t> dest_file_size = base::GetFileSize(dest_file); |
| 1313 | + ASSERT_TRUE(dest_file_size.has_value()); |
| 1314 | + EXPECT_GT(dest_file_size.value(), 300); |
| 1315 | + EXPECT_LT(dest_file_size.value(), 1000); |
1313 | 1316 | } |
1314 | 1317 |
|
1315 | 1318 | // Tests that a ZIP put inside a ZIP is simply stored instead of being |
@@ -1338,10 +1341,10 @@ TEST_F(ZipTest, NestedZip) { |
1338 | 1341 | // Since the dummy source (inner) ZIP file should simply be stored in the |
1339 | 1342 | // destination (outer) ZIP file, the destination file should be bigger than |
1340 | 1343 | // the source file, but not much bigger. |
1341 | | - int64_t dest_file_size; |
1342 | | - ASSERT_TRUE(base::GetFileSize(dest_file, &dest_file_size)); |
1343 | | - EXPECT_GT(dest_file_size, src_size + 100); |
1344 | | - EXPECT_LT(dest_file_size, src_size + 300); |
| 1344 | + std::optional<int64_t> dest_file_size = base::GetFileSize(dest_file); |
| 1345 | + ASSERT_TRUE(dest_file_size.has_value()); |
| 1346 | + EXPECT_GT(dest_file_size.value(), src_size + 100); |
| 1347 | + EXPECT_LT(dest_file_size.value(), src_size + 300); |
1345 | 1348 | } |
1346 | 1349 |
|
1347 | 1350 | // Tests that there is no 2GB or 4GB limits. Tests that big files can be zipped |
@@ -1402,10 +1405,10 @@ TEST_F(ZipTest, BigFile) { |
1402 | 1405 | // Since the dummy source (inner) ZIP file should simply be stored in the |
1403 | 1406 | // destination (outer) ZIP file, the destination file should be bigger than |
1404 | 1407 | // the source file, but not much bigger. |
1405 | | - int64_t dest_file_size; |
1406 | | - ASSERT_TRUE(base::GetFileSize(dest_file, &dest_file_size)); |
1407 | | - EXPECT_GT(dest_file_size, src_size + 100); |
1408 | | - EXPECT_LT(dest_file_size, src_size + 300); |
| 1408 | + std::optional<int64_t> dest_file_size = base::GetFileSize(dest_file); |
| 1409 | + ASSERT_TRUE(dest_file_size.has_value()); |
| 1410 | + EXPECT_GT(dest_file_size.value(), src_size + 100); |
| 1411 | + EXPECT_LT(dest_file_size.value(), src_size + 300); |
1409 | 1412 |
|
1410 | 1413 | LOG(INFO) << "Reading big ZIP " << dest_file; |
1411 | 1414 | zip::ZipReader reader; |
|