Changeset 277357 in webkit
- Timestamp:
- May 11, 2021, 10:55:23 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 32 edited
-
Source/JavaScriptCore/Configurations/JavaScriptCore.xcconfig (modified) (1 diff)
-
Source/WTF/ChangeLog (modified) (1 diff)
-
Source/WTF/wtf/FileSystem.cpp (modified) (2 diffs)
-
Source/WTF/wtf/FileSystem.h (modified) (1 diff)
-
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)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp (modified) (1 diff)
-
Source/WebCore/Modules/indexeddb/server/IDBServer.cpp (modified) (8 diffs)
-
Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp (modified) (2 diffs)
-
Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp (modified) (2 diffs)
-
Source/WebCore/html/DirectoryFileListCreator.cpp (modified) (2 diffs)
-
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp (modified) (2 diffs)
-
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h (modified) (1 diff)
-
Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp (modified) (1 diff)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabaseTracker.cpp (modified) (1 diff)
-
Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp (modified) (3 diffs)
-
Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.cpp (modified) (1 diff)
-
Source/WebKit/UIProcess/API/APIContentRuleListStore.cpp (modified) (3 diffs)
-
Source/WebKit/UIProcess/DeviceIdHashSaltStorage.cpp (modified) (1 diff)
-
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (modified) (2 diffs)
-
Source/WebKit/WebProcess/InjectedBundle/API/glib/WebKitExtensionManager.cpp (modified) (1 diff)
-
Source/WebKit/WebProcess/MediaCache/WebMediaKeyStorageManager.cpp (modified) (4 diffs)
-
Source/WebKitLegacy/ChangeLog (modified) (1 diff)
-
Source/WebKitLegacy/Storage/StorageTracker.cpp (modified) (2 diffs)
-
Source/WebKitLegacy/win/ChangeLog (modified) (1 diff)
-
Source/WebKitLegacy/win/Plugins/PluginDatabase.cpp (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp (modified) (4 diffs)
-
Tools/TestWebKitAPI/Tests/WebCore/cocoa/DatabaseTrackerTest.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/Configurations/JavaScriptCore.xcconfig
r277231 r277357 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_ -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_ ;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_ -Wl,-unexported_symbol,__ZNKSt3__14__fs10filesystem18directory_iteratorptEv -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem18directory_iterator9incrementERNS_10error_codeE; 31 31 32 32 OTHER_LDFLAGS_BASE = $(OTHER_LDFLAGS_HIDE_SYMBOLS) -force_load "$(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/libWTF.a"; -
trunk/Source/WTF/ChangeLog
r277355 r277357 1 2021-05-11 Chris Dumez <cdumez@apple.com> 2 3 Port WTF::FileSystem::listDirectory to std::filesystem 4 https://bugs.webkit.org/show_bug.cgi?id=225633 5 6 Reviewed by Darin Adler. 7 8 Port WTF::FileSystem::listDirectory to std::filesystem with the following 2 changes: 9 - The function no longer takes a (blob-style) filter parameter 10 - The function now returns file names instead of file paths, allowing the call sites 11 to more easily filter based on prefixes. 12 13 * wtf/FileSystem.cpp: 14 (WTF::FileSystemImpl::listDirectory): 15 * wtf/FileSystem.h: 16 * wtf/glib/FileSystemGlib.cpp: 17 * wtf/posix/FileSystemPOSIX.cpp: 18 * wtf/win/FileSystemWin.cpp: 19 1 20 2021-05-11 Darin Adler <darin@apple.com> 2 21 -
trunk/Source/WTF/wtf/FileSystem.cpp
r277315 r277357 563 563 #if PLATFORM(MAC) 564 564 bool containsSingleDSStoreFile = false; 565 for (auto& entry : std::filesystem::directory_iterator(fsPath, ec)) { 566 if (entry.path().filename() == ".DS_Store") 565 auto entries = std::filesystem::directory_iterator(fsPath, ec); 566 for (auto it = std::filesystem::begin(entries), end = std::filesystem::end(entries); !ec && it != end; it.increment(ec)) { 567 if (it->path().filename() == ".DS_Store") 567 568 containsSingleDSStoreFile = true; 568 569 else { … … 753 754 } 754 755 756 Vector<String> listDirectory(const String& path) 757 { 758 Vector<String> fileNames; 759 std::error_code ec; 760 auto entries = std::filesystem::directory_iterator(toStdFileSystemPath(path), ec); 761 for (auto it = std::filesystem::begin(entries), end = std::filesystem::end(entries); !ec && it != end; it.increment(ec)) { 762 auto fileName = fromStdFileSystemPath(it->path().filename()); 763 if (!fileName.isNull()) 764 fileNames.append(WTFMove(fileName)); 765 } 766 return fileNames; 767 } 768 755 769 } // namespace FileSystemImpl 756 770 } // namespace WTF -
trunk/Source/WTF/wtf/FileSystem.h
r276879 r277357 138 138 bool excludeFromBackup(const String&); // Returns true if successful. 139 139 140 WTF_EXPORT_PRIVATE Vector<String> listDirectory(const String& path , const String& filter);140 WTF_EXPORT_PRIVATE Vector<String> listDirectory(const String& path); // Returns file names, not full paths. 141 141 142 142 WTF_EXPORT_PRIVATE CString fileSystemRepresentation(const String&); -
trunk/Source/WTF/wtf/glib/FileSystemGlib.cpp
r277231 r277357 142 142 } 143 143 144 Vector<String> listDirectory(const String& path, const String& filter)145 {146 Vector<String> entries;147 148 auto filename = fileSystemRepresentation(path);149 if (!validRepresentation(filename))150 return entries;151 152 GUniquePtr<GDir> dir(g_dir_open(filename.data(), 0, nullptr));153 if (!dir)154 return entries;155 156 GUniquePtr<GPatternSpec> pspec(g_pattern_spec_new((filter.utf8()).data()));157 while (const char* name = g_dir_read_name(dir.get())) {158 if (!g_pattern_match_string(pspec.get(), name))159 continue;160 161 GUniquePtr<gchar> entry(g_build_filename(filename.data(), name, nullptr));162 entries.append(stringFromFileSystemRepresentation(entry.get()));163 }164 165 return entries;166 }167 168 144 String openTemporaryFile(const String& prefix, PlatformFileHandle& handle, const String& suffix) 169 145 { -
trunk/Source/WTF/wtf/posix/FileSystemPOSIX.cpp
r277231 r277357 187 187 } 188 188 189 Vector<String> listDirectory(const String& path, const String& filter)190 {191 Vector<String> entries;192 CString cpath = fileSystemRepresentation(path);193 CString cfilter = fileSystemRepresentation(filter);194 DIR* dir = opendir(cpath.data());195 if (dir) {196 struct dirent* dp;197 while ((dp = readdir(dir))) {198 const char* name = dp->d_name;199 if (!strcmp(name, ".") || !strcmp(name, ".."))200 continue;201 if (fnmatch(cfilter.data(), name, 0))202 continue;203 char filePath[PATH_MAX];204 if (static_cast<int>(sizeof(filePath) - 1) < snprintf(filePath, sizeof(filePath), "%s/%s", cpath.data(), name))205 continue; // buffer overflow206 207 auto string = stringFromFileSystemRepresentation(filePath);208 209 // Some file system representations cannot be represented as a UTF-16 string,210 // so this string might be null.211 if (!string.isNull())212 entries.append(WTFMove(string));213 }214 closedir(dir);215 }216 return entries;217 }218 219 189 #if !USE(CF) 220 190 String stringFromFileSystemRepresentation(const char* path) -
trunk/Source/WTF/wtf/win/FileSystemWin.cpp
r277231 r277357 365 365 } 366 366 367 Vector<String> listDirectory(const String& directory, const String& filter)368 {369 Vector<String> entries;370 371 PathWalker walker(directory, filter);372 if (!walker.isValid())373 return entries;374 375 do {376 if (walker.data().dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY377 && (!wcscmp(walker.data().cFileName, L".") || !wcscmp(walker.data().cFileName, L"..")))378 continue;379 380 entries.append(directory + "\\" + reinterpret_cast<const UChar*>(walker.data().cFileName));381 } while (walker.step());382 383 return entries;384 }385 386 367 Optional<int32_t> getFileDeviceId(const CString& fsFile) 387 368 { -
trunk/Source/WebCore/ChangeLog
r277356 r277357 1 2021-05-11 Chris Dumez <cdumez@apple.com> 2 3 Port WTF::FileSystem::listDirectory to std::filesystem 4 https://bugs.webkit.org/show_bug.cgi?id=225633 5 6 Reviewed by Darin Adler. 7 8 Update FileSystem::listDirectory() call sites to deal with the fact that: 9 - The function now returns file names instead of full file paths 10 - The callers now have to do filtering by themselves if they need it 11 12 * Modules/entriesapi/DOMFileSystem.cpp: 13 (WebCore::listDirectoryWithMetadata): 14 * Modules/indexeddb/server/IDBServer.cpp: 15 (WebCore::IDBServer::IDBServer::getAllDatabaseNamesAndVersions): 16 (WebCore::IDBServer::collectOriginsForVersion): 17 (WebCore::IDBServer::removeAllDatabasesForFullOriginPath): 18 (WebCore::IDBServer::removeAllDatabasesForOriginPath): 19 (WebCore::IDBServer::IDBServer::removeDatabasesModifiedSinceForVersion): 20 (WebCore::IDBServer::IDBServer::removeDatabasesWithOriginsForVersion): 21 * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp: 22 (WebCore::IDBServer::SQLiteIDBBackingStore::fullDatabaseDirectoryWithUpgrade): 23 (WebCore::IDBServer::SQLiteIDBBackingStore::databasesSizeForDirectory): 24 * Modules/webdatabase/DatabaseTracker.cpp: 25 (WebCore::DatabaseTracker::usage): 26 (WebCore::DatabaseTracker::deleteOrigin): 27 * html/DirectoryFileListCreator.cpp: 28 (WebCore::appendDirectoryFiles): 29 * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: 30 (WebCore::MediaPlayerPrivateGStreamer::uriDecodeBinElementAddedCallback): 31 (WebCore::MediaPlayerPrivateGStreamer::purgeOldDownloadFiles): 32 * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h: 33 * platform/text/hyphen/HyphenationLibHyphen.cpp: 34 (WebCore::extractLocaleFromDictionaryFileName): 35 (WebCore::scanDirectoryForDictionaries): 36 1 37 2021-05-11 Chris Dumez <cdumez@apple.com> 2 38 -
trunk/Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp
r274482 r277357 55 55 return Exception { NotFoundError, "Path no longer exists or is no longer a directory" }; 56 56 57 auto child Paths = FileSystem::listDirectory(fullPath, "*");57 auto childNames = FileSystem::listDirectory(fullPath); 58 58 Vector<ListedChild> listedChildren; 59 listedChildren.reserveInitialCapacity(child Paths.size());60 for (auto& child Path : childPaths) {61 auto metadata = FileSystem::fileMetadata( childPath);59 listedChildren.reserveInitialCapacity(childNames.size()); 60 for (auto& childName : childNames) { 61 auto metadata = FileSystem::fileMetadata(FileSystem::pathByAppendingComponent(fullPath, childName)); 62 62 if (!metadata || metadata.value().isHidden) 63 63 continue; 64 listedChildren.uncheckedAppend(ListedChild { FileSystem::pathGetFileName(childPath), metadata.value().type });64 listedChildren.uncheckedAppend(ListedChild { childName, metadata.value().type }); 65 65 } 66 66 return listedChildren; -
trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp
r275891 r277357 515 515 516 516 String oldDirectory = IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(origin.topOrigin, origin.clientOrigin, m_databaseDirectoryPath, "v0"); 517 Vector<String> file s = FileSystem::listDirectory(oldDirectory, "*"_s);517 Vector<String> fileNames = FileSystem::listDirectory(oldDirectory); 518 518 Vector<IDBDatabaseNameAndVersion> databases; 519 for (auto& file : files) {520 auto databaseTuple = SQLiteIDBBackingStore::databaseNameAndVersionFromFile(SQLiteIDBBackingStore::fullDatabasePathForDirectory( file));519 for (auto& fileName : fileNames) { 520 auto databaseTuple = SQLiteIDBBackingStore::databaseNameAndVersionFromFile(SQLiteIDBBackingStore::fullDatabasePathForDirectory(FileSystem::pathByAppendingComponent(oldDirectory, fileName))); 521 521 if (databaseTuple) 522 522 databases.append(WTFMove(*databaseTuple)); … … 524 524 525 525 String directory = IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(origin.topOrigin, origin.clientOrigin, m_databaseDirectoryPath, "v1"); 526 file s = FileSystem::listDirectory(directory, "*"_s);527 for (auto& file : files) {528 auto databaseTuple = SQLiteIDBBackingStore::databaseNameAndVersionFromFile(SQLiteIDBBackingStore::fullDatabasePathForDirectory( file));526 fileNames = FileSystem::listDirectory(directory); 527 for (auto& fileName : fileNames) { 528 auto databaseTuple = SQLiteIDBBackingStore::databaseNameAndVersionFromFile(SQLiteIDBBackingStore::fullDatabasePathForDirectory(FileSystem::pathByAppendingComponent(directory, fileName))); 529 529 if (databaseTuple) 530 530 databases.append(WTFMove(*databaseTuple)); … … 540 540 static void collectOriginsForVersion(const String& versionPath, HashSet<WebCore::SecurityOriginData>& securityOrigins) 541 541 { 542 for (auto& topOriginPath : FileSystem::listDirectory(versionPath, "*")) { 543 auto databaseIdentifier = FileSystem::pathGetFileName(topOriginPath); 542 for (auto& databaseIdentifier : FileSystem::listDirectory(versionPath)) { 544 543 if (auto securityOrigin = SecurityOriginData::fromDatabaseIdentifier(databaseIdentifier)) { 545 544 securityOrigins.add(WTFMove(*securityOrigin)); 546 545 547 for (auto& originPath : FileSystem::listDirectory(topOriginPath, "*")) { 548 databaseIdentifier = FileSystem::pathGetFileName(originPath); 546 for (auto& databaseIdentifier : FileSystem::listDirectory(FileSystem::pathByAppendingComponent(versionPath, databaseIdentifier))) { 549 547 if (auto securityOrigin = SecurityOriginData::fromDatabaseIdentifier(databaseIdentifier)) 550 548 securityOrigins.add(WTFMove(*securityOrigin)); … … 629 627 { 630 628 LOG(IndexedDB, "removeAllDatabasesForOriginPath with originPath %s", originPath.utf8().data()); 631 Vector<String> databasePaths = FileSystem::listDirectory(originPath, "*"); 632 633 for (auto& databasePath : databasePaths) { 629 Vector<String> databaseNames = FileSystem::listDirectory(originPath); 630 631 for (auto& databaseName : databaseNames) { 632 auto databasePath = FileSystem::pathByAppendingComponent(originPath, databaseName); 634 633 String databaseFile = FileSystem::pathByAppendingComponent(databasePath, "IndexedDB.sqlite3"); 635 634 if (modifiedSince > -WallTime::infinity() && FileSystem::fileExists(databaseFile)) { … … 650 649 // To be conservative, we should *not* try to delete files that are unexpected; 651 650 // We should only delete files we think we put there. 652 // 653 // IndexedDB blob files are named "N.blob" where N is a decimal integer, 654 // so those are the only blob files we should be trying to delete. 655 for (auto& blobPath : FileSystem::listDirectory(databasePath, "[0-9]*.blob")) { 656 // Globbing can't give us only filenames starting with 1-or-more digits. 657 // The above globbing gives us files that start with a digit and ends with ".blob", but there might be non-digits in between. 658 // We need to validate that each filename contains only digits before deleting it, as any other files are not ones we put there. 659 String filename = FileSystem::pathGetFileName(blobPath); 660 auto filenameLength = filename.length(); 661 662 ASSERT(filenameLength >= 6); 663 ASSERT(filename.endsWith(".blob")); 664 665 if (filename.length() < 6) 651 for (auto& fileName : FileSystem::listDirectory(databasePath)) { 652 // IndexedDB blob files are named "N.blob" where N is a decimal integer, 653 // so those are the only blob files we should be trying to delete. 654 auto fileNameLength = fileName.length(); 655 if (fileNameLength < 6) 666 656 continue; 667 if (!file name.endsWith(".blob"))657 if (!fileName.endsWith(".blob")) 668 658 continue; 669 659 670 bool validFile name = true;671 for (unsigned i = 0; i < file nameLength - 5; ++i) {672 if (!isASCIIDigit(file name[i])) {673 validFile name = false;660 bool validFileName = true; 661 for (unsigned i = 0; i < fileNameLength - 5; ++i) { 662 if (!isASCIIDigit(fileName[i])) { 663 validFileName = false; 674 664 break; 675 665 } 676 666 } 677 667 678 if (validFile name)679 FileSystem::deleteFile( blobPath);668 if (validFileName) 669 FileSystem::deleteFile(FileSystem::pathByAppendingComponent(databasePath, fileName)); 680 670 } 681 671 … … 697 687 return; 698 688 699 auto directories = FileSystem::listDirectory(originPath, "*"_s); 700 for (auto& directory : directories) { 701 String databaseIdentifier = FileSystem::lastComponentOfPathIgnoringTrailingSlash(directory); 689 auto directoryNames = FileSystem::listDirectory(originPath); 690 for (auto& databaseIdentifier : directoryNames) { 702 691 if (auto securityOrigin = SecurityOriginData::fromDatabaseIdentifier(databaseIdentifier)) 703 removeAllDatabasesForFullOriginPath( directory, modifiedSince);692 removeAllDatabasesForFullOriginPath(FileSystem::pathByAppendingComponent(originPath, databaseIdentifier), modifiedSince); 704 693 } 705 694 … … 710 699 { 711 700 String versionPath = FileSystem::pathByAppendingComponent(m_databaseDirectoryPath, version); 712 for (auto& originPath : FileSystem::listDirectory(versionPath, "*")) { 713 String databaseIdentifier = FileSystem::lastComponentOfPathIgnoringTrailingSlash(originPath); 701 for (auto& databaseIdentifier : FileSystem::listDirectory(versionPath)) { 714 702 if (auto securityOrigin = SecurityOriginData::fromDatabaseIdentifier(databaseIdentifier)) 715 removeAllDatabasesForOriginPath( originPath, modifiedSince);703 removeAllDatabasesForOriginPath(FileSystem::pathByAppendingComponent(versionPath, databaseIdentifier), modifiedSince); 716 704 } 717 705 } … … 724 712 removeAllDatabasesForOriginPath(originPath, -WallTime::infinity()); 725 713 726 for (auto& topOriginPath : FileSystem::listDirectory(versionPath, "*")) { 714 for (auto& topOrigin : FileSystem::listDirectory(versionPath)) { 715 auto topOriginPath = FileSystem::pathByAppendingComponent(versionPath, topOrigin); 727 716 originPath = FileSystem::pathByAppendingComponent(topOriginPath, origin.databaseIdentifier()); 728 717 removeAllDatabasesForOriginPath(originPath, -WallTime::infinity()); -
trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp
r277343 r277357 1183 1183 String newOriginDirectory = m_identifier.databaseDirectoryRelativeToRoot(m_databaseRootDirectory, "v1"); 1184 1184 String fileNameHash = SQLiteFileSystem::computeHashForFileName(m_identifier.databaseName()); 1185 Vector<String> directoriesWithSameHash = FileSystem::listDirectory(newOriginDirectory, fileNameHash + "*");1186 1185 String newDatabaseDirectory = FileSystem::pathByAppendingComponent(newOriginDirectory, fileNameHash); 1187 1186 FileSystem::makeAllDirectories(newDatabaseDirectory); … … 1282 1281 { 1283 1282 uint64_t diskUsage = 0; 1284 for (auto& dbDirectory : FileSystem::listDirectory(directory, "*")) { 1285 for (auto& file : FileSystem::listDirectory(dbDirectory, "*.sqlite3"_s)) { 1286 auto fileSize = SQLiteFileSystem::getDatabaseFileSize(file); 1287 diskUsage += fileSize; 1283 for (auto& dbDirectoryName : FileSystem::listDirectory(directory)) { 1284 auto dbDirectoryPath = FileSystem::pathByAppendingComponent(directory, dbDirectoryName); 1285 for (auto& fileName : FileSystem::listDirectory(dbDirectoryPath)) { 1286 if (fileName.endsWith(".sqlite3")) 1287 diskUsage += SQLiteFileSystem::getDatabaseFileSize(FileSystem::pathByAppendingComponent(dbDirectoryPath, fileName)); 1288 1288 } 1289 1289 } -
trunk/Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp
r249313 r277357 656 656 String originPath = this->originPath(origin); 657 657 unsigned long long diskUsage = 0; 658 for (auto& fileName : FileSystem::listDirectory(originPath, "*.db"_s)) 659 diskUsage += SQLiteFileSystem::getDatabaseFileSize(fileName); 658 for (auto& fileName : FileSystem::listDirectory(originPath)) { 659 if (fileName.endsWith(".db")) 660 diskUsage += SQLiteFileSystem::getDatabaseFileSize(FileSystem::pathByAppendingComponent(originPath, fileName)); 661 } 660 662 return diskUsage; 661 663 } … … 856 858 RELEASE_LOG_ERROR(DatabaseTracker, "Unable to retrieve list of database names for origin"); 857 859 #endif 858 for (const auto& file : FileSystem::listDirectory(originPath(origin), "*")) { 859 if (!FileSystem::deleteFile(file)) 860 auto originPath = this->originPath(origin); 861 for (const auto& fileName : FileSystem::listDirectory(originPath)) { 862 if (!FileSystem::deleteFile(FileSystem::pathByAppendingComponent(originPath, fileName))) 860 863 failedToDeleteAnyDatabaseFile = true; 861 864 } -
trunk/Source/WebCore/html/DirectoryFileListCreator.cpp
r266168 r277357 55 55 { 56 56 ASSERT(!isMainThread()); 57 for (auto& childPath : FileSystem::listDirectory(directory, "*")) { 57 for (auto& childName : FileSystem::listDirectory(directory)) { 58 auto childPath = FileSystem::pathByAppendingComponent(directory, childName); 58 59 auto metadata = FileSystem::fileMetadata(childPath); 59 60 if (!metadata) … … 63 64 continue; 64 65 65 String childRelativePath = relativePath + "/" + FileSystem::pathGetFileName(childPath);66 String childRelativePath = relativePath + "/" + childName; 66 67 if (metadata.value().type == FileMetadata::Type::Directory) 67 68 appendDirectoryFiles(childPath, childRelativePath, files); -
trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
r277088 r277357 2182 2182 GST_DEBUG_OBJECT(player->pipeline(), "Reconfigured file download template from '%s' to '%s'", oldDownloadTemplate.get(), newDownloadTemplate.get()); 2183 2183 2184 player->purgeOldDownloadFiles(oldDownloadTemplate.get()); 2184 String newDownloadPrefixPath = newDownloadTemplate.get(); 2185 player->purgeOldDownloadFiles(newDownloadPrefixPath.replace("XXXXXX", "")); 2185 2186 } 2186 2187 … … 2203 2204 } 2204 2205 2205 void MediaPlayerPrivateGStreamer::purgeOldDownloadFiles(const char* downloadFileTemplate) 2206 { 2207 if (!downloadFileTemplate) 2208 return; 2209 2210 GUniquePtr<char> templatePath(g_path_get_dirname(downloadFileTemplate)); 2211 GUniquePtr<char> templateFile(g_path_get_basename(downloadFileTemplate)); 2212 String templatePattern = String(templateFile.get()).replace("X", "?"); 2213 2214 for (auto& filePath : FileSystem::listDirectory(templatePath.get(), templatePattern)) { 2206 void MediaPlayerPrivateGStreamer::purgeOldDownloadFiles(const String& downloadFilePrefixPath) 2207 { 2208 if (downloadFilePrefixPath.isEmpty()) 2209 return; 2210 2211 auto templateDirectory = FileSystem::directoryName(downloadFilePrefixPath); 2212 auto templatePrefix = FileSystem::pathGetFileName(downloadFilePrefixPath); 2213 for (auto& fileName : FileSystem::listDirectory(templateDirectory)) { 2214 if (!fileName.startsWith(templatePrefix)) 2215 continue; 2216 2217 auto filePath = FileSystem::pathByAppendingComponent(templateDirectory, fileName); 2215 2218 if (UNLIKELY(!FileSystem::deleteFile(filePath))) { 2216 2219 GST_WARNING("Couldn't unlink legacy media temporary file: %s", filePath.utf8().data()); -
trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h
r277031 r277357 438 438 bool canSaveMediaData() const override; 439 439 440 void purgeOldDownloadFiles(const char*);440 void purgeOldDownloadFiles(const String& downloadFilePrefixPath); 441 441 static void uriDecodeBinElementAddedCallback(GstBin*, GstElement*, MediaPlayerPrivateGStreamer*); 442 442 static void downloadBufferFileCreatedCallback(MediaPlayerPrivateGStreamer*); -
trunk/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp
r271533 r277357 53 53 }; 54 54 55 static String extractLocaleFromDictionaryFilePath(const String& filePath) 56 { 55 static String extractLocaleFromDictionaryFileName(const String& fileName) 56 { 57 if (!fileName.startsWith("hyph_") || !fileName.endsWith(".dic")) 58 return { }; 59 57 60 // Dictionary files always have the form "hyph_<locale name>.dic" 58 61 // so we strip everything except the locale. 59 String fileName = FileSystem::pathGetFileName(filePath); 60 static const int prefixLength = 5; 61 static const int suffixLength = 4; 62 return fileName.substring(prefixLength, fileName.length() - prefixLength - suffixLength); 62 constexpr int prefixLength = 5; 63 constexpr int suffixLength = 4; 64 return fileName.substring(prefixLength, fileName.length() - prefixLength - suffixLength).convertToASCIILowercase(); 63 65 } 64 66 65 67 static void scanDirectoryForDictionaries(const char* directoryPath, HashMap<AtomString, Vector<String>>& availableLocales) 66 68 { 67 for (auto& filePath : FileSystem::listDirectory(directoryPath, "hyph_*.dic")) { 68 String locale = extractLocaleFromDictionaryFilePath(filePath).convertToASCIILowercase(); 69 69 for (auto& fileName : FileSystem::listDirectory(directoryPath)) { 70 String locale = extractLocaleFromDictionaryFileName(fileName); 71 if (locale.isEmpty()) 72 continue; 73 74 auto filePath = FileSystem::pathByAppendingComponent(directoryPath, fileName); 70 75 char normalizedPath[PATH_MAX]; 71 76 if (!realpath(FileSystem::fileSystemRepresentation(filePath).data(), normalizedPath)) -
trunk/Source/WebKit/ChangeLog
r277356 r277357 1 2021-05-11 Chris Dumez <cdumez@apple.com> 2 3 Port WTF::FileSystem::listDirectory to std::filesystem 4 https://bugs.webkit.org/show_bug.cgi?id=225633 5 6 Reviewed by Darin Adler. 7 8 Update FileSystem::listDirectory() call sites to deal with the fact that: 9 - The function now returns file names instead of full file paths 10 - The callers now have to do filtering by themselves if they need it 11 12 * NetworkProcess/WebStorage/LocalStorageDatabaseTracker.cpp: 13 (WebKit::LocalStorageDatabaseTracker::origins const): 14 * NetworkProcess/cache/CacheStorageEngine.cpp: 15 (WebKit::CacheStorage::getDirectorySize): 16 (WebKit::CacheStorage::Engine::getDirectories): 17 (WebKit::CacheStorage::Engine::clearAllCachesFromDisk): 18 * NetworkProcess/cache/NetworkCacheFileSystem.cpp: 19 (WebKit::NetworkCache::traverseDirectory): 20 * UIProcess/API/APIContentRuleListStore.cpp: 21 (API::ContentRuleListStore::getAvailableContentRuleListIdentifiers): 22 (API::ContentRuleListStore::synchronousRemoveAllContentRuleLists): 23 * UIProcess/DeviceIdHashSaltStorage.cpp: 24 (WebKit::DeviceIdHashSaltStorage::loadStorageFromDisk): 25 * UIProcess/WebsiteData/WebsiteDataStore.cpp: 26 (WebKit::WebsiteDataStore::mediaKeyOrigins): 27 (WebKit::WebsiteDataStore::removeMediaKeys): 28 * WebProcess/InjectedBundle/API/glib/WebKitExtensionManager.cpp: 29 (WebKit::WebKitExtensionManager::scanModules): 30 * WebProcess/MediaCache/WebMediaKeyStorageManager.cpp: 31 (WebKit::WebMediaKeyStorageManager::getMediaKeyOrigins): 32 (WebKit::removeAllMediaKeyStorageForOriginPath): 33 (WebKit::WebMediaKeyStorageManager::deleteMediaKeyEntriesModifiedBetweenDates): 34 (WebKit::WebMediaKeyStorageManager::deleteAllMediaKeyEntries): 35 1 36 2021-05-11 Chris Dumez <cdumez@apple.com> 2 37 -
trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabaseTracker.cpp
r272754 r277357 105 105 { 106 106 Vector<SecurityOriginData> databaseOrigins; 107 auto paths = FileSystem::listDirectory(localStorageDirectory(), "*.localstorage"); 108 109 for (const auto& path : paths) { 107 for (auto& path : FileSystem::listDirectory(localStorageDirectory())) { 110 108 auto filename = FileSystem::pathGetFileName(path); 111 109 auto originIdentifier = filename.substring(0, filename.length() - strlen(".localstorage")); -
trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp
r277239 r277357 209 209 auto path = paths.takeFirst(); 210 210 if (FileSystem::fileIsDirectory(path, FileSystem::ShouldFollowSymbolicLinks::No)) { 211 auto newPaths = FileSystem::listDirectory(path, "*"_s);212 for (auto& newPath : newPaths) {211 auto fileNames = FileSystem::listDirectory(path); 212 for (auto& fileName : fileNames) { 213 213 // Files in /Blobs directory are hard link. 214 auto fileName = FileSystem::lastComponentOfPathIgnoringTrailingSlash(newPath);215 214 if (fileName == "Blobs") 216 215 continue; 217 paths.append( newPath);216 paths.append(FileSystem::pathByAppendingComponent(path, fileName)); 218 217 } 219 218 continue; … … 616 615 m_ioQueue->dispatch([path = m_rootPath.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable { 617 616 Vector<String> folderPaths; 618 for (auto& filename : FileSystem::listDirectory(path, "*")) { 619 if (FileSystem::fileIsDirectory(filename, FileSystem::ShouldFollowSymbolicLinks::No)) 620 folderPaths.append(filename.isolatedCopy()); 617 for (auto& fileName : FileSystem::listDirectory(path)) { 618 auto filePath = FileSystem::pathByAppendingComponent(path, fileName); 619 if (FileSystem::fileIsDirectory(filePath, FileSystem::ShouldFollowSymbolicLinks::No)) 620 folderPaths.append(filePath.isolatedCopy()); 621 621 } 622 622 … … 703 703 m_ioQueue->dispatch([path = m_rootPath.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable { 704 704 LockHolder locker(globalSizeFileLock); 705 for (auto& filename : FileSystem::listDirectory(path, "*")) { 706 if (FileSystem::fileIsDirectory(filename, FileSystem::ShouldFollowSymbolicLinks::No)) 707 FileSystem::deleteNonEmptyDirectory(filename); 705 for (auto& fileName : FileSystem::listDirectory(path)) { 706 auto filePath = FileSystem::pathByAppendingComponent(path, fileName); 707 if (FileSystem::fileIsDirectory(filePath, FileSystem::ShouldFollowSymbolicLinks::No)) 708 FileSystem::deleteNonEmptyDirectory(filePath); 708 709 } 709 710 RunLoop::main().dispatch(WTFMove(completionHandler)); -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.cpp
r275267 r277357 56 56 void traverseDirectory(const String& path, const Function<void (const String&, DirectoryEntryType)>& function) 57 57 { 58 auto entries = FileSystem::listDirectory(path , "*"_s);58 auto entries = FileSystem::listDirectory(path); 59 59 for (auto& entry : entries) { 60 auto type = FileSystem::fileIsDirectory(entry, FileSystem::ShouldFollowSymbolicLinks::No) ? DirectoryEntryType::Directory : DirectoryEntryType::File; 61 function(FileSystem::pathGetFileName(entry), type); 60 auto entryPath = FileSystem::pathByAppendingComponent(path, entry); 61 auto type = FileSystem::fileIsDirectory(entryPath, FileSystem::ShouldFollowSymbolicLinks::No) ? DirectoryEntryType::Directory : DirectoryEntryType::File; 62 function(entry, type); 62 63 } 63 64 } -
trunk/Source/WebKit/UIProcess/API/APIContentRuleListStore.cpp
r275166 r277357 90 90 } 91 91 92 static const WTF::String constructedPathFilter(bool legacyFilename)93 {94 return makeString(constructedPathPrefix(legacyFilename), '*');95 }96 97 92 static WTF::String constructedPath(const WTF::String& base, const WTF::String& identifier, bool legacyFilename) 98 93 { … … 501 496 ASSERT(RunLoop::isMain()); 502 497 m_readQueue->dispatch([protectedThis = makeRef(*this), storePath = m_storePath.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable { 503 504 Vector<WTF::String> fullPaths = listDirectory(storePath, constructedPathFilter(false)); 505 Vector<WTF::String> legacyFullPaths = listDirectory(storePath, constructedPathFilter(true)); 498 auto prefix = constructedPathPrefix(false /*legacy*/); 499 auto prefixLength = prefix.length(); 500 auto legacyPrefix = constructedPathPrefix(true /*legacy*/); 501 auto legacyPrefixLength = legacyPrefix.length(); 502 506 503 Vector<WTF::String> identifiers; 507 identifiers.reserveInitialCapacity(fullPaths.size() + legacyFullPaths.size()); 508 const auto prefixLength = constructedPathPrefix(false).length(); 509 const auto legacyPrefixLength = constructedPathPrefix(true).length(); 510 for (const auto& path : fullPaths) 511 identifiers.uncheckedAppend(decodeFromFilename(path.substring(path.reverseFind('/') + 1 + prefixLength))); 512 for (const auto& path : legacyFullPaths) 513 identifiers.uncheckedAppend(decodeFromFilename(path.substring(path.reverseFind('/') + 1 + legacyPrefixLength))); 504 for (auto& fileName : listDirectory(storePath)) { 505 if (fileName.startsWith(prefix)) 506 identifiers.append(decodeFromFilename(fileName.substring(prefixLength))); 507 else if (fileName.startsWith(legacyPrefix)) 508 identifiers.append(decodeFromFilename(fileName.substring(legacyPrefixLength))); 509 } 514 510 515 511 RunLoop::main().dispatch([protectedThis = WTFMove(protectedThis), completionHandler = WTFMove(completionHandler), identifiers = WTFMove(identifiers)]() mutable { … … 569 565 void ContentRuleListStore::synchronousRemoveAllContentRuleLists() 570 566 { 571 for (const auto& path : listDirectory(m_storePath, "*"))572 deleteFile( path);567 for (const auto& fileName : listDirectory(m_storePath)) 568 deleteFile(FileSystem::pathByAppendingComponent(m_storePath, fileName)); 573 569 } 574 570 -
trunk/Source/WebKit/UIProcess/DeviceIdHashSaltStorage.cpp
r260707 r277357 116 116 117 117 HashMap<String, std::unique_ptr<HashSaltForOrigin>> deviceIdHashSaltForOrigins; 118 for (auto& originPath : FileSystem::listDirectory(m_deviceIdHashSaltStorageDirectory, "*")) { 118 for (auto& origin : FileSystem::listDirectory(m_deviceIdHashSaltStorageDirectory)) { 119 auto originPath = FileSystem::pathByAppendingComponent(m_deviceIdHashSaltStorageDirectory, origin); 119 120 auto deviceIdHashSalt = URL::fileURLWithFileSystemPath(originPath).lastPathComponent().toString(); 120 121 -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
r277114 r277357 1673 1673 Vector<WebCore::SecurityOriginData> origins; 1674 1674 1675 for (const auto& originPath : FileSystem::listDirectory(mediaKeysStorageDirectory, "*")) { 1675 for (const auto& mediaKeyIdentifier : FileSystem::listDirectory(mediaKeysStorageDirectory)) { 1676 auto originPath = FileSystem::pathByAppendingComponent(mediaKeysStorageDirectory, mediaKeyIdentifier); 1676 1677 auto mediaKeyFile = computeMediaKeyFile(originPath); 1677 1678 if (!FileSystem::fileExists(mediaKeyFile)) 1678 1679 continue; 1679 1680 1680 auto mediaKeyIdentifier = FileSystem::pathGetFileName(originPath);1681 1682 1681 if (auto securityOrigin = WebCore::SecurityOriginData::fromDatabaseIdentifier(mediaKeyIdentifier)) 1683 1682 origins.append(*securityOrigin); … … 1691 1690 ASSERT(!mediaKeysStorageDirectory.isEmpty()); 1692 1691 1693 for (const auto& mediaKeyDirectory : FileSystem::listDirectory(mediaKeysStorageDirectory, "*")) { 1692 for (const auto& directoryName : FileSystem::listDirectory(mediaKeysStorageDirectory)) { 1693 auto mediaKeyDirectory = FileSystem::pathByAppendingComponent(mediaKeysStorageDirectory, directoryName); 1694 1694 auto mediaKeyFile = computeMediaKeyFile(mediaKeyDirectory); 1695 1695 -
trunk/Source/WebKit/WebProcess/InjectedBundle/API/glib/WebKitExtensionManager.cpp
r248846 r277357 42 42 void WebKitExtensionManager::scanModules(const String& webExtensionsDirectory, Vector<String>& modules) 43 43 { 44 Vector<String> modulePaths = FileSystem::listDirectory(webExtensionsDirectory, String("*.so")); 45 for (size_t i = 0; i < modulePaths.size(); ++i) { 46 if (FileSystem::fileExists(modulePaths[i])) 47 modules.append(modulePaths[i]); 44 auto moduleNames = FileSystem::listDirectory(webExtensionsDirectory); 45 for (auto& moduleName : moduleNames) { 46 if (!moduleName.endsWith(".so")) 47 continue; 48 49 auto modulePath = FileSystem::pathByAppendingComponent(webExtensionsDirectory, moduleName); 50 if (FileSystem::fileExists(modulePath)) 51 modules.append(modulePath); 48 52 } 49 53 } -
trunk/Source/WebKit/WebProcess/MediaCache/WebMediaKeyStorageManager.cpp
r260707 r277357 61 61 return results; 62 62 63 for (auto& originPath : FileSystem::listDirectory(m_mediaKeyStorageDirectory, "*")) { 64 auto identifier = URL::fileURLWithFileSystemPath(originPath).lastPathComponent().toString(); 63 for (auto& identifier : FileSystem::listDirectory(m_mediaKeyStorageDirectory)) { 65 64 if (auto securityOrigin = SecurityOriginData::fromDatabaseIdentifier(identifier)) 66 65 results.append(*securityOrigin); … … 72 71 static void removeAllMediaKeyStorageForOriginPath(const String& originPath, WallTime startDate, WallTime endDate) 73 72 { 74 Vector<String> mediaKey Paths = FileSystem::listDirectory(originPath, "*");73 Vector<String> mediaKeyNames = FileSystem::listDirectory(originPath); 75 74 76 for (const auto& mediaKeyPath : mediaKeyPaths) { 75 for (const auto& mediaKeyName : mediaKeyNames) { 76 auto mediaKeyPath = FileSystem::pathByAppendingComponent(originPath, mediaKeyName); 77 77 String mediaKeyFile = FileSystem::pathByAppendingComponent(mediaKeyPath, "SecureStop.plist"); 78 78 … … 107 107 return; 108 108 109 Vector<String> origin Paths = FileSystem::listDirectory(m_mediaKeyStorageDirectory, "*");110 for (auto& origin Path : originPaths)111 removeAllMediaKeyStorageForOriginPath( originPath, startDate, endDate);109 Vector<String> originNames = FileSystem::listDirectory(m_mediaKeyStorageDirectory); 110 for (auto& originName : originNames) 111 removeAllMediaKeyStorageForOriginPath(FileSystem::pathByAppendingComponent(m_mediaKeyStorageDirectory, originName), startDate, endDate); 112 112 } 113 113 … … 117 117 return; 118 118 119 Vector<String> origin Paths = FileSystem::listDirectory(m_mediaKeyStorageDirectory, "*");120 for (auto& origin Path : originPaths)121 removeAllMediaKeyStorageForOriginPath( originPath, -WallTime::infinity(), WallTime::infinity());119 Vector<String> originNames = FileSystem::listDirectory(m_mediaKeyStorageDirectory); 120 for (auto& originName : originNames) 121 removeAllMediaKeyStorageForOriginPath(FileSystem::pathByAppendingComponent(m_mediaKeyStorageDirectory, originName), -WallTime::infinity(), WallTime::infinity()); 122 122 } 123 123 -
trunk/Source/WebKitLegacy/ChangeLog
r276982 r277357 1 2021-05-11 Chris Dumez <cdumez@apple.com> 2 3 Port WTF::FileSystem::listDirectory to std::filesystem 4 https://bugs.webkit.org/show_bug.cgi?id=225633 5 6 Reviewed by Darin Adler. 7 8 Update FileSystem::listDirectory() call sites to deal with the fact that: 9 - The function now returns file names instead of full file paths 10 - The callers now have to do filtering by themselves if they need it 11 12 * Storage/StorageTracker.cpp: 13 (WebKit::StorageTracker::syncFileSystemAndTrackerDatabase): 14 1 15 2021-05-04 Alex Christensen <achristensen@webkit.org> 2 16 -
trunk/Source/WebKitLegacy/Storage/StorageTracker.cpp
r276982 r277357 237 237 ASSERT(m_isActive); 238 238 239 Vector<String> paths;239 Vector<String> fileNames; 240 240 { 241 241 LockHolder locker(m_databaseMutex); 242 paths = FileSystem::listDirectory(m_storageDirectoryPath, "*.localstorage");242 fileNames = FileSystem::listDirectory(m_storageDirectoryPath); 243 243 } 244 244 … … 256 256 String fileExtension = ".localstorage"_s; 257 257 258 for (Vector<String>::const_iterator it = paths.begin(), end = paths.end(); it != end; ++it) { 259 const String& path = *it; 260 261 if (path.length() > fileExtension.length() && path.endsWith(fileExtension)) { 262 String file = FileSystem::pathGetFileName(path); 263 String originIdentifier = file.substring(0, file.length() - fileExtension.length()); 264 if (!originSetCopy.contains(originIdentifier)) 265 syncSetOriginDetails(originIdentifier, path); 266 267 foundOrigins.add(originIdentifier); 268 } 258 for (auto& fileName : fileNames) { 259 if (fileName.length() <= fileExtension.length() || !fileName.endsWith(fileExtension)) 260 continue; 261 262 auto filePath = FileSystem::pathByAppendingComponent(m_storageDirectoryPath, fileName); 263 String originIdentifier = fileName.substring(0, fileName.length() - fileExtension.length()); 264 if (!originSetCopy.contains(originIdentifier)) 265 syncSetOriginDetails(originIdentifier, filePath); 266 267 foundOrigins.add(originIdentifier); 269 268 } 270 269 -
trunk/Source/WebKitLegacy/win/ChangeLog
r277295 r277357 1 2021-05-11 Chris Dumez <cdumez@apple.com> 2 3 Port WTF::FileSystem::listDirectory to std::filesystem 4 https://bugs.webkit.org/show_bug.cgi?id=225633 5 6 Reviewed by Darin Adler. 7 8 Update FileSystem::listDirectory() call sites to deal with the fact that: 9 - The function now returns file names instead of full file paths 10 - The callers now have to do filtering by themselves if they need it 11 12 * Plugins/PluginDatabase.cpp: 13 (WebCore::PluginDatabase::getPluginPathsInDirectories const): 14 1 15 2021-05-10 Wenson Hsieh <wenson_hsieh@apple.com> 2 16 -
trunk/Source/WebKitLegacy/win/Plugins/PluginDatabase.cpp
r260707 r277357 400 400 { 401 401 // FIXME: This should be a case insensitive set. 402 HashSet<String> uniqueFilenames; 403 404 String fileNameFilter(""); 405 406 auto dirsEnd = m_pluginDirectories.end(); 407 for (auto dIt = m_pluginDirectories.begin(); dIt != dirsEnd; ++dIt) { 408 Vector<String> pluginPaths = FileSystem::listDirectory(*dIt, fileNameFilter); 409 auto pluginsEnd = pluginPaths.end(); 410 for (auto pIt = pluginPaths.begin(); pIt != pluginsEnd; ++pIt) { 411 if (!fileExistsAndIsNotDisabled(*pIt)) 402 for (auto& pluginDirectory : m_pluginDirectories) { 403 for (auto& pluginName : FileSystem::listDirectory(pluginDirectory)) { 404 auto pluginPath = FileSystem::pathByAppendingComponent(pluginDirectory, pluginName); 405 if (!fileExistsAndIsNotDisabled(pluginPath)) 412 406 continue; 413 407 414 paths.add( *pIt);408 paths.add(pluginPath); 415 409 } 416 410 } -
trunk/Tools/ChangeLog
r277356 r277357 1 2021-05-11 Chris Dumez <cdumez@apple.com> 2 3 Port WTF::FileSystem::listDirectory to std::filesystem 4 https://bugs.webkit.org/show_bug.cgi?id=225633 5 6 Reviewed by Darin Adler. 7 8 Add API test coverage. 9 10 * TestWebKitAPI/Tests/WTF/FileSystem.cpp: 11 (TestWebKitAPI::createTestFile): 12 (TestWebKitAPI::TEST_F): 13 * TestWebKitAPI/Tests/WebCore/cocoa/DatabaseTrackerTest.mm: 14 (TestWebKitAPI::removeDirectoryAndAllContents): 15 1 16 2021-05-11 Chris Dumez <cdumez@apple.com> 2 17 -
trunk/Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp
r277231 r277357 38 38 const char* FileSystemTestData = "This is a test"; 39 39 40 static void createTestFile(const String& path) 41 { 42 auto fileHandle = FileSystem::openFile(path, FileSystem::FileOpenMode::Write); 43 EXPECT_TRUE(FileSystem::isHandleValid(fileHandle)); 44 FileSystem::writeToFile(fileHandle, FileSystemTestData, strlen(FileSystemTestData)); 45 FileSystem::closeFile(fileHandle); 46 }; 47 40 48 // FIXME: Refactor FileSystemTest and SharedBufferTest as a single class. 41 49 class FileSystemTest : public testing::Test { … … 250 258 TEST_F(FileSystemTest, deleteNonEmptyDirectory) 251 259 { 252 auto createTestTile = [](const String& path) {253 auto fileHandle = FileSystem::openFile(path, FileSystem::FileOpenMode::Write);254 EXPECT_TRUE(FileSystem::isHandleValid(fileHandle));255 FileSystem::writeToFile(fileHandle, FileSystemTestData, strlen(FileSystemTestData));256 FileSystem::closeFile(fileHandle);257 };258 259 260 FileSystem::PlatformFileHandle temporaryFile; 260 261 auto temporaryTestFolder = FileSystem::openTemporaryFile("deleteNonEmptyDirectoryTest", temporaryFile); … … 263 264 EXPECT_TRUE(FileSystem::deleteFile(temporaryTestFolder)); 264 265 EXPECT_TRUE(FileSystem::makeAllDirectories(FileSystem::pathByAppendingComponents(temporaryTestFolder, { "subfolder" }))); 265 createTest Tile(FileSystem::pathByAppendingComponent(temporaryTestFolder, "file1.txt"));266 createTest Tile(FileSystem::pathByAppendingComponent(temporaryTestFolder, "file2.txt"));267 createTest Tile(FileSystem::pathByAppendingComponents(temporaryTestFolder, { "subfolder", "file3.txt" }));268 createTest Tile(FileSystem::pathByAppendingComponents(temporaryTestFolder, { "subfolder", "file4.txt" }));266 createTestFile(FileSystem::pathByAppendingComponent(temporaryTestFolder, "file1.txt")); 267 createTestFile(FileSystem::pathByAppendingComponent(temporaryTestFolder, "file2.txt")); 268 createTestFile(FileSystem::pathByAppendingComponents(temporaryTestFolder, { "subfolder", "file3.txt" })); 269 createTestFile(FileSystem::pathByAppendingComponents(temporaryTestFolder, { "subfolder", "file4.txt" })); 269 270 EXPECT_FALSE(FileSystem::deleteEmptyDirectory(temporaryTestFolder)); 270 271 EXPECT_TRUE(FileSystem::fileExists(temporaryTestFolder)); … … 781 782 } 782 783 784 TEST_F(FileSystemTest, listDirectory) 785 { 786 createTestFile(FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "a.txt")); 787 createTestFile(FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "b.txt")); 788 createTestFile(FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "bar.png")); 789 createTestFile(FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "foo.png")); 790 FileSystem::makeAllDirectories(FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "subfolder")); 791 createTestFile(FileSystem::pathByAppendingComponents(tempEmptyFolderPath(), { "subfolder", "c.txt" })); 792 createTestFile(FileSystem::pathByAppendingComponents(tempEmptyFolderPath(), { "subfolder", "d.txt" })); 793 794 auto matches = FileSystem::listDirectory(tempEmptyFolderPath()); 795 ASSERT_EQ(matches.size(), 5U); 796 std::sort(matches.begin(), matches.end(), WTF::codePointCompareLessThan); 797 EXPECT_STREQ(matches[0].utf8().data(), "a.txt"); 798 EXPECT_STREQ(matches[1].utf8().data(), "b.txt"); 799 EXPECT_STREQ(matches[2].utf8().data(), "bar.png"); 800 EXPECT_STREQ(matches[3].utf8().data(), "foo.png"); 801 EXPECT_STREQ(matches[4].utf8().data(), "subfolder"); 802 803 matches = FileSystem::listDirectory(FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "subfolder")); 804 ASSERT_EQ(matches.size(), 2U); 805 std::sort(matches.begin(), matches.end(), WTF::codePointCompareLessThan); 806 EXPECT_STREQ(matches[0].utf8().data(), "c.txt"); 807 EXPECT_STREQ(matches[1].utf8().data(), "d.txt"); 808 809 matches = FileSystem::listDirectory(FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "does-not-exist")); 810 ASSERT_EQ(matches.size(), 0U); 811 812 matches = FileSystem::listDirectory(FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "a.txt")); 813 ASSERT_EQ(matches.size(), 0U); 814 815 EXPECT_TRUE(FileSystem::deleteNonEmptyDirectory(tempEmptyFolderPath())); 816 } 817 783 818 } // namespace TestWebKitAPI -
trunk/Tools/TestWebKitAPI/Tests/WebCore/cocoa/DatabaseTrackerTest.mm
r260366 r277357 79 79 static void removeDirectoryAndAllContents(const String& directoryPath) 80 80 { 81 for ( const auto& file : FileSystem::listDirectory(directoryPath, "*"))82 EXPECT_TRUE(FileSystem::deleteFile( file));81 for (auto& fileName : FileSystem::listDirectory(directoryPath)) 82 EXPECT_TRUE(FileSystem::deleteFile(FileSystem::pathByAppendingComponent(directoryPath, fileName))); 83 83 84 84 if (FileSystem::fileExists(directoryPath))
Note:
See TracChangeset
for help on using the changeset viewer.