Changeset 277231 in webkit
- Timestamp:
- May 8, 2021, 3:35:07 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/Configurations/JavaScriptCore.xcconfig (modified) (1 diff)
-
Source/WTF/ChangeLog (modified) (1 diff)
-
Source/WTF/wtf/FileSystem.cpp (modified) (16 diffs)
-
Source/WTF/wtf/glib/FileSystemGlib.cpp (modified) (1 diff)
-
Source/WTF/wtf/posix/FileSystemPOSIX.cpp (modified) (1 diff)
-
Source/WTF/wtf/win/FileSystemWin.cpp (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r277224 r277231 1 2021-05-08 Chris Dumez <cdumez@apple.com> 2 3 Port Filesystem::pathByAppendingComponent() & Filesystem:: pathByAppendingComponents() to std::filesystem 4 https://bugs.webkit.org/show_bug.cgi?id=225550 5 6 Reviewed by Darin Adler. 7 8 Build fix. 9 10 * Configurations/JavaScriptCore.xcconfig: 11 1 12 2021-05-08 Ross Kirsling <ross.kirsling@sony.com> 2 13 -
trunk/Source/JavaScriptCore/Configurations/JavaScriptCore.xcconfig
r277158 r277231 28 28 29 29 // Prevent C++ standard library operator new, delete and their related exception types from being exported as weak symbols. 30 OTHER_LDFLAGS_HIDE_SYMBOLS = -Wl,-unexported_symbol,__ZTISt9bad_alloc -Wl,-unexported_symbol,__ZTISt9exception -Wl,-unexported_symbol,__ZTSSt9bad_alloc -Wl,-unexported_symbol,__ZTSSt9exception -Wl,-unexported_symbol,__ZdlPvS_ -Wl,-unexported_symbol,__ZnwmPv -Wl,-unexported_symbol,__ZNKSt3__18functionIFvvEEclEv -Wl,-unexported_symbol,__ZNSt3__18functionIFvvEEC1EOS2_ -Wl,-unexported_symbol,__ZNSt3__18functionIFvvEEC2EOS2_ -Wl,-unexported_symbol,__ZNKSt3__18functionIFvRN3JSC17BytecodeGeneratorEPNS1_10RegisterIDEEEclES3_S5_ -Wl,-unexported_symbol,__ZNSt3__18functionIFvRN3JSC17BytecodeGeneratorEPNS1_10RegisterIDEEED1Ev -Wl,-unexported_symbol,__ZNSt3__18functionIFvRN3JSC17BytecodeGeneratorEPNS1_10RegisterIDEEED2Ev -Wl,-unexported_symbol,__ZNSt3__18functionIFvvEED1Ev -Wl,-unexported_symbol,__ZNSt3__18functionIFvvEED2Ev -Wl,-unexported_symbol,__ZTVNSt3__117bad_function_callE -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem24__is_pathable_char_arrayIPKcS4_cLb1EE11__range_endES4_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem24__is_pathable_char_arrayIPKcS4_cLb1EE13__range_beginES4_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem8_PathCVTIcE14__append_rangeIPKcEENS_9enable_ifIXsr27__is_cpp17_forward_iteratorIT_EE5valueEvE4typeERNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEES8_S8_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem8_PathCVTIcE15__append_sourceIPKcEEvRNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEERKT_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem8_PathCVTIcE14__append_rangeIPKcEENS_9enable_ifIXsr21__is_forward_iteratorIT_EE5valueEvE4typeERNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEES8_S8_ -Wl,-unexported_symbol,__ZNKSt3__14__fs10filesystem18directory_iteratordeEv -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem18directory_iteratorppEv -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem24__is_pathable_char_arrayIA10_cPccLb1EE11__range_endEPKc -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem24__is_pathable_char_arrayIA10_cPccLb1EE13__range_beginEPKc -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem4pathdVERKS2_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem8_PathCVTIcE15__append_sourceIA10_cEEvRNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEERKT_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem24__throw_filesystem_errorIJRPKcRKNS1_4pathERKNS_10error_codeEEEEvDpOT_ ;30 OTHER_LDFLAGS_HIDE_SYMBOLS = -Wl,-unexported_symbol,__ZTISt9bad_alloc -Wl,-unexported_symbol,__ZTISt9exception -Wl,-unexported_symbol,__ZTSSt9bad_alloc -Wl,-unexported_symbol,__ZTSSt9exception -Wl,-unexported_symbol,__ZdlPvS_ -Wl,-unexported_symbol,__ZnwmPv -Wl,-unexported_symbol,__ZNKSt3__18functionIFvvEEclEv -Wl,-unexported_symbol,__ZNSt3__18functionIFvvEEC1EOS2_ -Wl,-unexported_symbol,__ZNSt3__18functionIFvvEEC2EOS2_ -Wl,-unexported_symbol,__ZNKSt3__18functionIFvRN3JSC17BytecodeGeneratorEPNS1_10RegisterIDEEEclES3_S5_ -Wl,-unexported_symbol,__ZNSt3__18functionIFvRN3JSC17BytecodeGeneratorEPNS1_10RegisterIDEEED1Ev -Wl,-unexported_symbol,__ZNSt3__18functionIFvRN3JSC17BytecodeGeneratorEPNS1_10RegisterIDEEED2Ev -Wl,-unexported_symbol,__ZNSt3__18functionIFvvEED1Ev -Wl,-unexported_symbol,__ZNSt3__18functionIFvvEED2Ev -Wl,-unexported_symbol,__ZTVNSt3__117bad_function_callE -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem24__is_pathable_char_arrayIPKcS4_cLb1EE11__range_endES4_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem24__is_pathable_char_arrayIPKcS4_cLb1EE13__range_beginES4_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem8_PathCVTIcE14__append_rangeIPKcEENS_9enable_ifIXsr27__is_cpp17_forward_iteratorIT_EE5valueEvE4typeERNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEES8_S8_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem8_PathCVTIcE15__append_sourceIPKcEEvRNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEERKT_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem8_PathCVTIcE14__append_rangeIPKcEENS_9enable_ifIXsr21__is_forward_iteratorIT_EE5valueEvE4typeERNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEES8_S8_ -Wl,-unexported_symbol,__ZNKSt3__14__fs10filesystem18directory_iteratordeEv -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem18directory_iteratorppEv -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem24__is_pathable_char_arrayIA10_cPccLb1EE11__range_endEPKc -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem24__is_pathable_char_arrayIA10_cPccLb1EE13__range_beginEPKc -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem4pathdVERKS2_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem8_PathCVTIcE15__append_sourceIA10_cEEvRNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEERKT_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem24__throw_filesystem_errorIJRPKcRKNS1_4pathERKNS_10error_codeEEEEvDpOT_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem14__is_separatorIcEENS_9enable_ifIXsr18__can_convert_charIT_EE5valueEbE4typeES4_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem24__is_pathable_char_arrayIPKcS4_cLb1EE15__first_or_nullES4_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem4path20__source_is_absoluteIcEEbT_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem4path6appendIPKcEENS_9enable_ifIXsr13__is_pathableIT_EE5valueERS2_E4typeERKS7_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem6u8pathIPKcEENS_9enable_ifIXsr13__is_pathableIT_EE5valueENS1_4pathEE4typeERKS6_; 31 31 32 32 OTHER_LDFLAGS_BASE = $(OTHER_LDFLAGS_HIDE_SYMBOLS) -force_load "$(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/libWTF.a"; -
trunk/Source/WTF/ChangeLog
r277229 r277231 1 2021-05-08 Chris Dumez <cdumez@apple.com> 2 3 Port Filesystem::pathByAppendingComponent() & Filesystem:: pathByAppendingComponents() to std::filesystem 4 https://bugs.webkit.org/show_bug.cgi?id=225550 5 6 Reviewed by Darin Adler. 7 8 Port Filesystem::pathByAppendingComponent() & Filesystem:: pathByAppendingComponents() to std::filesystem 9 and get rid of platform-specific implementations. 10 11 * wtf/FileSystem.cpp: 12 (WTF::FileSystemImpl::pathByAppendingComponent): 13 (WTF::FileSystemImpl::pathByAppendingComponents): 14 * wtf/glib/FileSystemGlib.cpp: 15 * wtf/posix/FileSystemPOSIX.cpp: 16 * wtf/win/FileSystemWin.cpp: 17 1 18 2021-05-08 Diego Pino Garcia <dpino@igalia.com> 2 19 -
trunk/Source/WTF/wtf/FileSystem.cpp
r277229 r277231 51 51 namespace FileSystemImpl { 52 52 53 static std::filesystem::path toStdFileSystemPath(StringView path) 54 { 55 return std::filesystem::u8path(path.utf8().data()); 56 } 57 58 static String fromStdFileSystemPath(const std::filesystem::path& path) 59 { 60 return String::fromUTF8(path.u8string().c_str()); 61 } 62 53 63 // The following lower-ASCII characters need escaping to be used in a filename 54 64 // across all systems, including Windows: … … 526 536 std::error_code ec; 527 537 // exists() returns false on error so no need to check ec. 528 return std::filesystem::exists( fileSystemRepresentation(path).data(), ec);538 return std::filesystem::exists(toStdFileSystemPath(path), ec); 529 539 } 530 540 … … 532 542 { 533 543 std::error_code ec; 534 std::filesystem::path fsPath = fileSystemRepresentation(path).data();544 auto fsPath = toStdFileSystemPath(path); 535 545 536 546 auto fileStatus = std::filesystem::symlink_status(fsPath, ec); … … 545 555 { 546 556 std::error_code ec; 547 std::filesystem::path fsPath = fileSystemRepresentation(path).data();557 auto fsPath = toStdFileSystemPath(path); 548 558 549 559 auto fileStatus = std::filesystem::symlink_status(fsPath, ec); … … 571 581 bool moveFile(const String& oldPath, const String& newPath) 572 582 { 573 std::filesystem::path fsOldPath = fileSystemRepresentation(oldPath).data();574 std::filesystem::path fsNewPath = fileSystemRepresentation(newPath).data();583 auto fsOldPath = toStdFileSystemPath(oldPath); 584 auto fsNewPath = toStdFileSystemPath(newPath); 575 585 576 586 std::error_code ec; … … 590 600 { 591 601 std::error_code ec; 592 auto size = std::filesystem::file_size( fileSystemRepresentation(path).data(), ec);602 auto size = std::filesystem::file_size(toStdFileSystemPath(path), ec); 593 603 if (ec) 594 604 return false; … … 602 612 std::filesystem::file_status fileStatus; 603 613 if (shouldFollowSymbolicLinks == ShouldFollowSymbolicLinks::Yes) 604 fileStatus = std::filesystem::status( fileSystemRepresentation(path).data(), ec);614 fileStatus = std::filesystem::status(toStdFileSystemPath(path), ec); 605 615 else 606 fileStatus = std::filesystem::symlink_status( fileSystemRepresentation(path).data(), ec);616 fileStatus = std::filesystem::symlink_status(toStdFileSystemPath(path), ec); 607 617 return fileStatus.type() == std::filesystem::file_type::directory; 608 618 } … … 611 621 { 612 622 std::error_code ec; 613 std::filesystem::create_directories( fileSystemRepresentation(path).data(), ec);623 std::filesystem::create_directories(toStdFileSystemPath(path), ec); 614 624 return !ec; 615 625 } … … 618 628 { 619 629 std::error_code ec; 620 auto spaceInfo = std::filesystem::space( fileSystemRepresentation(path).data(), ec);630 auto spaceInfo = std::filesystem::space(toStdFileSystemPath(path), ec); 621 631 if (ec) 622 632 return false; … … 628 638 { 629 639 std::error_code ec; 630 std::filesystem::create_symlink( fileSystemRepresentation(targetPath).data(), fileSystemRepresentation(symbolicLinkPath).data(), ec);640 std::filesystem::create_symlink(toStdFileSystemPath(targetPath), toStdFileSystemPath(symbolicLinkPath), ec); 631 641 return !ec; 632 642 } … … 635 645 { 636 646 std::error_code ec; 637 std::filesystem::create_hard_link( fileSystemRepresentation(targetPath).data(), fileSystemRepresentation(linkPath).data(), ec);647 std::filesystem::create_hard_link(toStdFileSystemPath(targetPath), toStdFileSystemPath(linkPath), ec); 638 648 return !ec; 639 649 } … … 641 651 bool hardLinkOrCopyFile(const String& targetPath, const String& linkPath) 642 652 { 643 std::filesystem::path fsTargetPath = fileSystemRepresentation(targetPath).data();644 std::filesystem::path fsLinkPath = fileSystemRepresentation(linkPath).data();653 auto fsTargetPath = toStdFileSystemPath(targetPath); 654 auto fsLinkPath = toStdFileSystemPath(linkPath); 645 655 646 656 std::error_code ec; … … 656 666 { 657 667 std::error_code ec; 658 std::filesystem::remove_all( fileSystemRepresentation(path).data(), ec);668 std::filesystem::remove_all(toStdFileSystemPath(path), ec); 659 669 return !ec; 660 670 } … … 663 673 { 664 674 std::error_code ec; 665 auto modificationTime = std::filesystem::last_write_time( fileSystemRepresentation(path).data(), ec);675 auto modificationTime = std::filesystem::last_write_time(toStdFileSystemPath(path), ec); 666 676 if (ec) 667 677 return WTF::nullopt; … … 674 684 return WTF::nullopt; 675 685 676 std::filesystem::path fsPath = fileSystemRepresentation(path).data();686 auto fsPath = toStdFileSystemPath(path); 677 687 678 688 std::error_code ec; … … 722 732 String pathGetFileName(const String& path) 723 733 { 724 std::filesystem::path fsPath = fileSystemRepresentation(path).data(); 725 return String::fromUTF8(fsPath.filename().u8string().c_str()); 734 return fromStdFileSystemPath(toStdFileSystemPath(path).filename()); 726 735 } 727 736 728 737 String directoryName(const String& path) 729 738 { 730 std::filesystem::path fsPath = fileSystemRepresentation(path).data(); 731 return String::fromUTF8(fsPath.parent_path().u8string().c_str()); 739 return fromStdFileSystemPath(toStdFileSystemPath(path).parent_path()); 740 } 741 742 String pathByAppendingComponent(const String& path, const String& component) 743 { 744 return fromStdFileSystemPath(toStdFileSystemPath(path) / toStdFileSystemPath(component)); 745 } 746 747 String pathByAppendingComponents(StringView path, const Vector<StringView>& components) 748 { 749 auto fsPath = toStdFileSystemPath(path); 750 for (auto& component : components) 751 fsPath /= toStdFileSystemPath(component); 752 return fromStdFileSystemPath(fsPath); 732 753 } 733 754 -
trunk/Source/WTF/wtf/glib/FileSystemGlib.cpp
r277229 r277231 137 137 } 138 138 139 String pathByAppendingComponent(const String& path, const String& component)140 {141 if (path.endsWith(G_DIR_SEPARATOR_S))142 return path + component;143 return path + G_DIR_SEPARATOR_S + component;144 }145 146 String pathByAppendingComponents(StringView path, const Vector<StringView>& components)147 {148 StringBuilder builder;149 builder.append(path);150 for (auto& component : components) {151 builder.append(G_DIR_SEPARATOR_S);152 builder.append(component);153 }154 return builder.toString();155 }156 157 139 String homeDirectoryPath() 158 140 { -
trunk/Source/WTF/wtf/posix/FileSystemPOSIX.cpp
r277219 r277231 187 187 } 188 188 189 String pathByAppendingComponent(const String& path, const String& component)190 {191 if (path.endsWith('/'))192 return path + component;193 return path + "/" + component;194 }195 196 String pathByAppendingComponents(StringView path, const Vector<StringView>& components)197 {198 StringBuilder builder;199 builder.append(path);200 for (auto& component : components)201 builder.append('/', component);202 return builder.toString();203 }204 205 189 Vector<String> listDirectory(const String& path, const String& filter) 206 190 { -
trunk/Source/WTF/wtf/win/FileSystemWin.cpp
r277219 r277231 144 144 } 145 145 146 String pathByAppendingComponent(const String& path, const String& component)147 {148 Vector<UChar> buffer(MAX_PATH);149 if (path.length() + 1 > buffer.size())150 return String();151 152 StringView(path).getCharactersWithUpconvert(buffer.data());153 buffer[path.length()] = '\0';154 155 if (!PathAppendW(wcharFrom(buffer.data()), component.wideCharacters().data()))156 return String();157 158 buffer.shrink(wcslen(wcharFrom(buffer.data())));159 return String::adopt(WTFMove(buffer));160 }161 162 String pathByAppendingComponents(StringView path, const Vector<StringView>& components)163 {164 String result = path.toString();165 for (auto& component : components)166 result = pathByAppendingComponent(result, component.toString());167 return result;168 }169 170 146 #if !USE(CF) 171 147 -
trunk/Tools/ChangeLog
r277219 r277231 1 2021-05-08 Chris Dumez <cdumez@apple.com> 2 3 Port Filesystem::pathByAppendingComponent() & Filesystem:: pathByAppendingComponents() to std::filesystem 4 https://bugs.webkit.org/show_bug.cgi?id=225550 5 6 Reviewed by Darin Adler. 7 8 Add API test coverage. 9 10 * TestWebKitAPI/Tests/WTF/FileSystem.cpp: 11 (TestWebKitAPI::TEST_F): 12 1 13 2021-05-07 Chris Dumez <cdumez@apple.com> 2 14 -
trunk/Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp
r277219 r277231 745 745 } 746 746 747 TEST_F(FileSystemTest, pathByAppendingComponent) 748 { 749 #if OS(UNIX) 750 EXPECT_STREQ("/var", FileSystem::pathByAppendingComponent("/", "var").utf8().data()); 751 EXPECT_STREQ("/var/tmp", FileSystem::pathByAppendingComponent("/var/", "tmp").utf8().data()); 752 EXPECT_STREQ("/var/tmp", FileSystem::pathByAppendingComponent("/var", "tmp").utf8().data()); 753 EXPECT_STREQ("/var/tmp/file.txt", FileSystem::pathByAppendingComponent("/var/tmp", "file.txt").utf8().data()); 754 EXPECT_STREQ("/var/", FileSystem::pathByAppendingComponent("/var", "").utf8().data()); 755 EXPECT_STREQ("/var/", FileSystem::pathByAppendingComponent("/var/", "").utf8().data()); 756 #endif 757 #if OS(WINDOWS) 758 EXPECT_STREQ("C:\\Foo", FileSystem::pathByAppendingComponent("C:\\", "Foo").utf8().data()); 759 EXPECT_STREQ("C:\\Foo\\Bar", FileSystem::pathByAppendingComponent("C:\\Foo", "Bar").utf8().data()); 760 EXPECT_STREQ("C:\\Foo\\Bar\\File.txt", FileSystem::pathByAppendingComponent("C:\\Foo\\Bar", "File.txt").utf8().data()); 761 #endif 762 } 763 764 TEST_F(FileSystemTest, pathByAppendingComponents) 765 { 766 EXPECT_STREQ(tempEmptyFolderPath().utf8().data(), FileSystem::pathByAppendingComponents(tempEmptyFolderPath(), { }).utf8().data()); 767 EXPECT_STREQ(FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "file.txt").utf8().data(), FileSystem::pathByAppendingComponents(tempEmptyFolderPath(), { "file.txt" }).utf8().data()); 768 #if OS(UNIX) 769 EXPECT_STREQ("/var/tmp/file.txt", FileSystem::pathByAppendingComponents("/", { "var", "tmp", "file.txt" }).utf8().data()); 770 EXPECT_STREQ("/var/tmp/file.txt", FileSystem::pathByAppendingComponents("/var", { "tmp", "file.txt" }).utf8().data()); 771 EXPECT_STREQ("/var/tmp/file.txt", FileSystem::pathByAppendingComponents("/var/", { "tmp", "file.txt" }).utf8().data()); 772 EXPECT_STREQ("/var/tmp/file.txt", FileSystem::pathByAppendingComponents("/var/tmp", { "file.txt" }).utf8().data()); 773 #endif 774 #if OS(WINDOWS) 775 EXPECT_STREQ("C:\\Foo\\Bar\\File.txt", FileSystem::pathByAppendingComponents("C:\\", { "Foo", "Bar", "File.txt" }).utf8().data()); 776 EXPECT_STREQ("C:\\Foo\\Bar\\File.txt", FileSystem::pathByAppendingComponents("C:\\Foo", { "Bar", "File.txt" }).utf8().data()); 777 EXPECT_STREQ("C:\\Foo\\Bar\\File.txt", FileSystem::pathByAppendingComponents("C:\\Foo\\", { "Bar", "File.txt" }).utf8().data()); 778 EXPECT_STREQ("C:\\Foo\\Bar\\File.txt", FileSystem::pathByAppendingComponents("C:\\Foo\\Bar", { "File.txt" }).utf8().data()); 779 EXPECT_STREQ("C:\\Foo\\Bar\\File.txt", FileSystem::pathByAppendingComponents("C:\\Foo\\Bar\\", { "File.txt" }).utf8().data()); 780 #endif 781 } 782 747 783 } // namespace TestWebKitAPI
Note:
See TracChangeset
for help on using the changeset viewer.