Changeset 277448 in webkit
- Timestamp:
- May 13, 2021, 1:08:36 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 20 edited
-
Source/JavaScriptCore/API/JSScript.mm (modified) (1 diff)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/WTF/ChangeLog (modified) (1 diff)
-
Source/WTF/wtf/FileSystem.cpp (modified) (2 diffs)
-
Source/WTF/wtf/FileSystem.h (modified) (2 diffs)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp (modified) (1 diff)
-
Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm (modified) (1 diff)
-
Source/WebCore/fileapi/File.cpp (modified) (1 diff)
-
Source/WebCore/html/DirectoryFileListCreator.cpp (modified) (1 diff)
-
Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm (modified) (1 diff)
-
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (modified) (1 diff)
-
Source/WebCore/platform/network/FormData.cpp (modified) (1 diff)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp (modified) (3 diffs)
-
Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.cpp (modified) (1 diff)
-
Source/WebKit/Shared/mac/AuxiliaryProcessMac.mm (modified) (3 diffs)
-
Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/API/JSScript.mm
r272936 r277448 91 91 } 92 92 93 if (!FileSystem:: fileIsDirectory(directory, FileSystem::ShouldFollowSymbolicLinks::No)) {93 if (!FileSystem::isDirectory(directory)) { 94 94 createError([NSString stringWithFormat:@"Cache directory `%@` is not a directory or does not exist", static_cast<NSString *>(directory)], error); 95 95 return false; -
trunk/Source/JavaScriptCore/ChangeLog
r277437 r277448 1 2021-05-13 Chris Dumez <cdumez@apple.com> 2 3 Rename FileSystem::fileIsDirectory(path, followSymlinks) to isDirectory(path) / isDirectoryFollowingSymlinks(path) 4 https://bugs.webkit.org/show_bug.cgi?id=225772 5 6 Reviewed by Darin Adler. 7 8 Update code base due to API naming change. 9 10 * API/JSScript.mm: 11 (validateBytecodeCachePath): 12 1 13 2021-05-13 Darin Adler <darin@apple.com> 2 14 -
trunk/Source/WTF/ChangeLog
r277446 r277448 1 2021-05-13 Chris Dumez <cdumez@apple.com> 2 3 Rename FileSystem::fileIsDirectory(path, followSymlinks) to isDirectory(path) / isDirectoryFollowingSymlinks(path) 4 https://bugs.webkit.org/show_bug.cgi?id=225772 5 6 Reviewed by Darin Adler. 7 8 I don't think the "file" prefix is useful here so I am renaming the function to 9 isDirectory(). Also, instead of using an enum parameter to decide whether or 10 not to follow symlink, I am adding a separate function called 11 isDirectoryFollowingSymlinks(). This is consistent with the 12 fileMetadata() / fileMetadataFollowingSymlinks() pattern, which Darin said he 13 preferred. 14 15 * wtf/FileSystem.cpp: 16 (WTF::FileSystemImpl::isDirectory): 17 (WTF::FileSystemImpl::isDirectoryFollowingSymlinks): 18 (WTF::FileSystemImpl::fileIsDirectory): Deleted. 19 * wtf/FileSystem.h: 20 1 21 2021-05-13 Chris Dumez <cdumez@apple.com> 2 22 -
trunk/Source/WTF/wtf/FileSystem.cpp
r277446 r277448 608 608 } 609 609 610 bool fileIsDirectory(const String& path, ShouldFollowSymbolicLinks shouldFollowSymbolicLinks) 611 { 612 std::error_code ec; 613 std::filesystem::file_status fileStatus; 614 if (shouldFollowSymbolicLinks == ShouldFollowSymbolicLinks::Yes) 615 fileStatus = std::filesystem::status(toStdFileSystemPath(path), ec); 616 else 617 fileStatus = std::filesystem::symlink_status(toStdFileSystemPath(path), ec); 618 return fileStatus.type() == std::filesystem::file_type::directory; 610 bool isDirectory(const String& path) 611 { 612 std::error_code ec; 613 return std::filesystem::symlink_status(toStdFileSystemPath(path), ec).type() == std::filesystem::file_type::directory; 614 } 615 616 bool isDirectoryFollowingSymlinks(const String& path) 617 { 618 std::error_code ec; 619 return std::filesystem::status(toStdFileSystemPath(path), ec).type() == std::filesystem::file_type::directory; 619 620 } 620 621 … … 687 688 } 688 689 690 enum class ShouldFollowSymbolicLinks { No, Yes }; 689 691 static Optional<FileMetadata> fileMetadataPotentiallyFollowingSymlinks(const String& path, ShouldFollowSymbolicLinks shouldFollowSymbolicLinks) 690 692 { -
trunk/Source/WTF/wtf/FileSystem.h
r277446 r277448 108 108 }; 109 109 110 enum class ShouldFollowSymbolicLinks { No, Yes };111 112 110 WTF_EXPORT_PRIVATE bool fileExists(const String&); 113 111 WTF_EXPORT_PRIVATE bool deleteFile(const String&); … … 120 118 WTF_EXPORT_PRIVATE Optional<FileMetadata> fileMetadata(const String& path); 121 119 WTF_EXPORT_PRIVATE Optional<FileMetadata> fileMetadataFollowingSymlinks(const String& path); 122 WTF_EXPORT_PRIVATE bool fileIsDirectory(const String&, ShouldFollowSymbolicLinks); 120 WTF_EXPORT_PRIVATE bool isDirectory(const String&); 121 WTF_EXPORT_PRIVATE bool isDirectoryFollowingSymlinks(const String&); 123 122 WTF_EXPORT_PRIVATE String pathByAppendingComponent(const String& path, const String& component); 124 123 WTF_EXPORT_PRIVATE String pathByAppendingComponents(StringView path, const Vector<StringView>& components); -
trunk/Source/WebCore/ChangeLog
r277442 r277448 1 2021-05-13 Chris Dumez <cdumez@apple.com> 2 3 Rename FileSystem::fileIsDirectory(path, followSymlinks) to isDirectory(path) / isDirectoryFollowingSymlinks(path) 4 https://bugs.webkit.org/show_bug.cgi?id=225772 5 6 Reviewed by Darin Adler. 7 8 Update code base due to API naming change. 9 10 * Modules/entriesapi/DOMFileSystem.cpp: 11 (WebCore::listDirectoryWithMetadata): 12 * editing/cocoa/WebContentReaderCocoa.mm: 13 (WebCore::attachmentForFilePath): 14 * fileapi/File.cpp: 15 (WebCore::File::isDirectory const): 16 * html/DirectoryFileListCreator.cpp: 17 (WebCore::gatherFileInformation): 18 * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm: 19 (WebCore::CDMInstanceFairPlayStreamingAVFObjC::setStorageDirectory): 20 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: 21 (WebCore::ensureAssetCacheExistsForPath): 22 * platform/network/FormData.cpp: 23 (WebCore::FormData::prepareForUpload): 24 1 25 2021-05-13 Jer Noble <jer.noble@apple.com> 2 26 -
trunk/Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp
r277357 r277448 52 52 { 53 53 ASSERT(!isMainThread()); 54 if (!FileSystem:: fileIsDirectory(fullPath, FileSystem::ShouldFollowSymbolicLinks::No))54 if (!FileSystem::isDirectory(fullPath)) 55 55 return Exception { NotFoundError, "Path no longer exists or is no longer a directory" }; 56 56 -
trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm
r273128 r277448 713 713 } 714 714 715 bool isDirectory = FileSystem:: fileIsDirectory(path, FileSystem::ShouldFollowSymbolicLinks::Yes);715 bool isDirectory = FileSystem::isDirectoryFollowingSymlinks(path); 716 716 String contentType = typeForAttachmentElement(explicitContentType); 717 717 if (contentType.isEmpty()) { -
trunk/Source/WebCore/fileapi/File.cpp
r266181 r277448 149 149 { 150 150 if (!m_isDirectory) 151 m_isDirectory = FileSystem:: fileIsDirectory(m_path, FileSystem::ShouldFollowSymbolicLinks::Yes);151 m_isDirectory = FileSystem::isDirectoryFollowingSymlinks(m_path); 152 152 return *m_isDirectory; 153 153 } -
trunk/Source/WebCore/html/DirectoryFileListCreator.cpp
r277357 r277448 77 77 Vector<FileInformation> files; 78 78 for (auto& info : paths) { 79 if (FileSystem:: fileIsDirectory(info.path, FileSystem::ShouldFollowSymbolicLinks::No))79 if (FileSystem::isDirectory(info.path)) 80 80 appendDirectoryFiles(info.path, FileSystem::pathGetFileName(info.path), files); 81 81 else -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm
r275900 r277448 402 402 if (!FileSystem::makeAllDirectories(storageDirectory)) 403 403 return; 404 } else if (!FileSystem:: fileIsDirectory(storageDirectory, FileSystem::ShouldFollowSymbolicLinks::Yes)) {404 } else if (!FileSystem::isDirectoryFollowingSymlinks(storageDirectory)) { 405 405 auto tempDirectory = FileSystem::createTemporaryDirectory(@"MediaKeys"); 406 406 if (!tempDirectory) -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
r277442 r277448 339 339 auto fileExistsAtPath = FileSystem::fileExists(path); 340 340 341 if (fileExistsAtPath && !FileSystem:: fileIsDirectory(path, FileSystem::ShouldFollowSymbolicLinks::Yes)) {341 if (fileExistsAtPath && !FileSystem::isDirectoryFollowingSymlinks(path)) { 342 342 // Non-directory file already exists at the path location; bail. 343 343 ASSERT_NOT_REACHED(); -
trunk/Source/WebCore/platform/network/FormData.cpp
r268904 r277448 358 358 if (!fileData) 359 359 continue; 360 if (!FileSystem:: fileIsDirectory(fileData->filename, FileSystem::ShouldFollowSymbolicLinks::Yes))360 if (!FileSystem::isDirectoryFollowingSymlinks(fileData->filename)) 361 361 continue; 362 362 if (fileData->fileStart || fileData->fileLength != BlobDataItem::toEndOfFile) -
trunk/Source/WebKit/ChangeLog
r277447 r277448 1 2021-05-13 Chris Dumez <cdumez@apple.com> 2 3 Rename FileSystem::fileIsDirectory(path, followSymlinks) to isDirectory(path) / isDirectoryFollowingSymlinks(path) 4 https://bugs.webkit.org/show_bug.cgi?id=225772 5 6 Reviewed by Darin Adler. 7 8 Update code base due to API naming change. 9 10 * NetworkProcess/cache/CacheStorageEngine.cpp: 11 (WebKit::CacheStorage::getDirectorySize): 12 (WebKit::CacheStorage::Engine::getDirectories): 13 (WebKit::CacheStorage::Engine::clearAllCachesFromDisk): 14 * NetworkProcess/cache/NetworkCacheFileSystem.cpp: 15 (WebKit::NetworkCache::traverseDirectory): 16 * UIProcess/Cocoa/WebProcessPoolCocoa.mm: 17 (WebKit::isInternalInstall): 18 1 19 2021-05-13 Chris Dumez <cdumez@apple.com> 2 20 -
trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp
r277357 r277448 208 208 while (!paths.isEmpty()) { 209 209 auto path = paths.takeFirst(); 210 if (FileSystem:: fileIsDirectory(path, FileSystem::ShouldFollowSymbolicLinks::No)) {210 if (FileSystem::isDirectory(path)) { 211 211 auto fileNames = FileSystem::listDirectory(path); 212 212 for (auto& fileName : fileNames) { … … 617 617 for (auto& fileName : FileSystem::listDirectory(path)) { 618 618 auto filePath = FileSystem::pathByAppendingComponent(path, fileName); 619 if (FileSystem:: fileIsDirectory(filePath, FileSystem::ShouldFollowSymbolicLinks::No))619 if (FileSystem::isDirectory(filePath)) 620 620 folderPaths.append(filePath.isolatedCopy()); 621 621 } … … 705 705 for (auto& fileName : FileSystem::listDirectory(path)) { 706 706 auto filePath = FileSystem::pathByAppendingComponent(path, fileName); 707 if (FileSystem:: fileIsDirectory(filePath, FileSystem::ShouldFollowSymbolicLinks::No))707 if (FileSystem::isDirectory(filePath)) 708 708 FileSystem::deleteNonEmptyDirectory(filePath); 709 709 } -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.cpp
r277357 r277448 59 59 for (auto& entry : entries) { 60 60 auto entryPath = FileSystem::pathByAppendingComponent(path, entry); 61 auto type = FileSystem:: fileIsDirectory(entryPath, FileSystem::ShouldFollowSymbolicLinks::No) ? DirectoryEntryType::Directory : DirectoryEntryType::File;61 auto type = FileSystem::isDirectory(entryPath) ? DirectoryEntryType::Directory : DirectoryEntryType::File; 62 62 function(entry, type); 63 63 } -
trunk/Source/WebKit/Shared/mac/AuxiliaryProcessMac.mm
r275108 r277448 332 332 static bool ensureSandboxCacheDirectory(const SandboxInfo& info) 333 333 { 334 if (!FileSystem:: fileIsDirectory(info.parentDirectoryPath, FileSystem::ShouldFollowSymbolicLinks::Yes)) {334 if (!FileSystem::isDirectoryFollowingSymlinks(info.parentDirectoryPath)) { 335 335 FileSystem::makeAllDirectories(info.parentDirectoryPath); 336 if (!FileSystem:: fileIsDirectory(info.parentDirectoryPath, FileSystem::ShouldFollowSymbolicLinks::Yes)) {336 if (!FileSystem::isDirectoryFollowingSymlinks(info.parentDirectoryPath)) { 337 337 WTFLogAlways("%s: Could not create sandbox directory\n", getprogname()); 338 338 return false; … … 364 364 return true; 365 365 366 bool isDirectory = FileSystem:: fileIsDirectory(info.directoryPath, FileSystem::ShouldFollowSymbolicLinks::No);366 bool isDirectory = FileSystem::isDirectory(info.directoryPath); 367 367 if (isDirectory) { 368 368 if (!FileSystem::deleteNonEmptyDirectory(info.directoryPath)) … … 380 380 } 381 381 #else 382 bool hasSandboxDirectory = FileSystem:: fileIsDirectory(info.directoryPath, FileSystem::ShouldFollowSymbolicLinks::Yes);382 bool hasSandboxDirectory = FileSystem::isDirectoryFollowingSymlinks(info.directoryPath); 383 383 if (!hasSandboxDirectory) { 384 384 if (FileSystem::makeAllDirectories(info.directoryPath)) { 385 ASSERT(FileSystem:: fileIsDirectory(info.directoryPath, FileSystem::ShouldFollowSymbolicLinks::Yes));385 ASSERT(FileSystem::isDirectoryFollowingSymlinks(info.directoryPath)); 386 386 hasSandboxDirectory = true; 387 387 } else { 388 388 // We may have raced with someone else making it. That's ok. 389 hasSandboxDirectory = FileSystem:: fileIsDirectory(info.directoryPath, FileSystem::ShouldFollowSymbolicLinks::Yes);389 hasSandboxDirectory = FileSystem::isDirectoryFollowingSymlinks(info.directoryPath); 390 390 } 391 391 } -
trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm
r277354 r277448 218 218 static bool isInternal = MGGetBoolAnswer(kMGQAppleInternalInstallCapability); 219 219 #else 220 static bool isInternal = FileSystem:: fileIsDirectory("/AppleInternal", FileSystem::ShouldFollowSymbolicLinks::No);220 static bool isInternal = FileSystem::isDirectory("/AppleInternal"); 221 221 #endif 222 222 return isInternal; -
trunk/Tools/ChangeLog
r277446 r277448 1 2021-05-13 Chris Dumez <cdumez@apple.com> 2 3 Rename FileSystem::fileIsDirectory(path, followSymlinks) to isDirectory(path) / isDirectoryFollowingSymlinks(path) 4 https://bugs.webkit.org/show_bug.cgi?id=225772 5 6 Reviewed by Darin Adler. 7 8 Update code base due to API naming change. 9 10 * TestWebKitAPI/Tests/WTF/FileSystem.cpp: 11 (TestWebKitAPI::TEST_F): 12 1 13 2021-05-13 Chris Dumez <cdumez@apple.com> 2 14 -
trunk/Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp
r277446 r277448 504 504 } 505 505 506 TEST_F(FileSystemTest, fileIsDirectory)507 { 508 EXPECT_TRUE(FileSystem:: fileIsDirectory(tempEmptyFolderPath(), FileSystem::ShouldFollowSymbolicLinks::No));509 EXPECT_TRUE(FileSystem:: fileIsDirectory(tempEmptyFolderPath(), FileSystem::ShouldFollowSymbolicLinks::Yes));506 TEST_F(FileSystemTest, isDirectory) 507 { 508 EXPECT_TRUE(FileSystem::isDirectory(tempEmptyFolderPath())); 509 EXPECT_TRUE(FileSystem::isDirectoryFollowingSymlinks(tempEmptyFolderPath())); 510 510 511 511 auto folderSymlinkMetadata = FileSystem::fileMetadata(tempEmptyFolderSymlinkPath()); 512 512 EXPECT_TRUE(!!folderSymlinkMetadata); 513 513 EXPECT_EQ(folderSymlinkMetadata->type, FileMetadata::Type::SymbolicLink); 514 EXPECT_FALSE(FileSystem:: fileIsDirectory(tempEmptyFolderSymlinkPath(), FileSystem::ShouldFollowSymbolicLinks::No));515 EXPECT_TRUE(FileSystem:: fileIsDirectory(tempEmptyFolderSymlinkPath(), FileSystem::ShouldFollowSymbolicLinks::Yes));516 517 EXPECT_FALSE(FileSystem:: fileIsDirectory(tempFilePath(), FileSystem::ShouldFollowSymbolicLinks::No));518 EXPECT_FALSE(FileSystem:: fileIsDirectory(tempFilePath(), FileSystem::ShouldFollowSymbolicLinks::Yes));514 EXPECT_FALSE(FileSystem::isDirectory(tempEmptyFolderSymlinkPath())); 515 EXPECT_TRUE(FileSystem::isDirectoryFollowingSymlinks(tempEmptyFolderSymlinkPath())); 516 517 EXPECT_FALSE(FileSystem::isDirectory(tempFilePath())); 518 EXPECT_FALSE(FileSystem::isDirectoryFollowingSymlinks(tempFilePath())); 519 519 520 520 auto fileSymlinkMetadata = FileSystem::fileMetadata(tempFileSymlinkPath()); 521 521 EXPECT_TRUE(!!fileSymlinkMetadata); 522 522 EXPECT_EQ(fileSymlinkMetadata->type, FileMetadata::Type::SymbolicLink); 523 EXPECT_FALSE(FileSystem:: fileIsDirectory(tempFileSymlinkPath(), FileSystem::ShouldFollowSymbolicLinks::No));524 EXPECT_FALSE(FileSystem:: fileIsDirectory(tempFileSymlinkPath(), FileSystem::ShouldFollowSymbolicLinks::Yes));523 EXPECT_FALSE(FileSystem::isDirectory(tempFileSymlinkPath())); 524 EXPECT_FALSE(FileSystem::isDirectoryFollowingSymlinks(tempFileSymlinkPath())); 525 525 526 526 String fileThatDoesNotExist = FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "does-not-exist"_s); 527 EXPECT_FALSE(FileSystem:: fileIsDirectory(fileThatDoesNotExist, FileSystem::ShouldFollowSymbolicLinks::No));528 EXPECT_FALSE(FileSystem:: fileIsDirectory(fileThatDoesNotExist, FileSystem::ShouldFollowSymbolicLinks::Yes));527 EXPECT_FALSE(FileSystem::isDirectory(fileThatDoesNotExist)); 528 EXPECT_FALSE(FileSystem::isDirectoryFollowingSymlinks(fileThatDoesNotExist)); 529 529 } 530 530 … … 532 532 { 533 533 EXPECT_TRUE(FileSystem::fileExists(tempEmptyFolderPath())); 534 EXPECT_TRUE(FileSystem:: fileIsDirectory(tempEmptyFolderPath(), FileSystem::ShouldFollowSymbolicLinks::No));534 EXPECT_TRUE(FileSystem::isDirectory(tempEmptyFolderPath())); 535 535 EXPECT_TRUE(FileSystem::makeAllDirectories(tempEmptyFolderPath())); 536 536 String subFolderPath = FileSystem::pathByAppendingComponents(tempEmptyFolderPath(), { "subFolder1", "subFolder2", "subFolder3" }); … … 538 538 EXPECT_TRUE(FileSystem::makeAllDirectories(subFolderPath)); 539 539 EXPECT_TRUE(FileSystem::fileExists(subFolderPath)); 540 EXPECT_TRUE(FileSystem:: fileIsDirectory(subFolderPath, FileSystem::ShouldFollowSymbolicLinks::No));540 EXPECT_TRUE(FileSystem::isDirectory(subFolderPath)); 541 541 EXPECT_TRUE(FileSystem::deleteNonEmptyDirectory(tempEmptyFolderPath())); 542 542 EXPECT_FALSE(FileSystem::fileExists(subFolderPath)); … … 581 581 EXPECT_EQ(symlinkMetadata->type, FileMetadata::Type::SymbolicLink); 582 582 583 EXPECT_FALSE(FileSystem:: fileIsDirectory(symlinkPath, FileSystem::ShouldFollowSymbolicLinks::No));584 EXPECT_TRUE(FileSystem:: fileIsDirectory(symlinkPath, FileSystem::ShouldFollowSymbolicLinks::Yes));583 EXPECT_FALSE(FileSystem::isDirectory(symlinkPath)); 584 EXPECT_TRUE(FileSystem::isDirectoryFollowingSymlinks(symlinkPath)); 585 585 586 586 EXPECT_TRUE(FileSystem::deleteFile(symlinkPath));
Note:
See TracChangeset
for help on using the changeset viewer.