Title: [277448] trunk
Revision
277448
Author
[email protected]
Date
2021-05-13 13:08:36 -0700 (Thu, 13 May 2021)

Log Message

Rename FileSystem::fileIsDirectory(path, followSymlinks) to isDirectory(path) / isDirectoryFollowingSymlinks(path)
https://bugs.webkit.org/show_bug.cgi?id=225772

Reviewed by Darin Adler.

Source/_javascript_Core:

Update code base due to API naming change.

* API/JSScript.mm:
(validateBytecodeCachePath):

Source/WebCore:

Update code base due to API naming change.

* Modules/entriesapi/DOMFileSystem.cpp:
(WebCore::listDirectoryWithMetadata):
* editing/cocoa/WebContentReaderCocoa.mm:
(WebCore::attachmentForFilePath):
* fileapi/File.cpp:
(WebCore::File::isDirectory const):
* html/DirectoryFileListCreator.cpp:
(WebCore::gatherFileInformation):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::CDMInstanceFairPlayStreamingAVFObjC::setStorageDirectory):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::ensureAssetCacheExistsForPath):
* platform/network/FormData.cpp:
(WebCore::FormData::prepareForUpload):

Source/WebKit:

Update code base due to API naming change.

* NetworkProcess/cache/CacheStorageEngine.cpp:
(WebKit::CacheStorage::getDirectorySize):
(WebKit::CacheStorage::Engine::getDirectories):
(WebKit::CacheStorage::Engine::clearAllCachesFromDisk):
* NetworkProcess/cache/NetworkCacheFileSystem.cpp:
(WebKit::NetworkCache::traverseDirectory):
* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::isInternalInstall):

Source/WTF:

I don't think the "file" prefix is useful here so I am renaming the function to
isDirectory(). Also, instead of using an enum parameter to decide whether or
not to follow symlink, I am adding a separate function called
isDirectoryFollowingSymlinks(). This is consistent with the
fileMetadata() / fileMetadataFollowingSymlinks() pattern, which Darin said he
preferred.

* wtf/FileSystem.cpp:
(WTF::FileSystemImpl::isDirectory):
(WTF::FileSystemImpl::isDirectoryFollowingSymlinks):
(WTF::FileSystemImpl::fileIsDirectory): Deleted.
* wtf/FileSystem.h:

Tools:

Update code base due to API naming change.

* TestWebKitAPI/Tests/WTF/FileSystem.cpp:
(TestWebKitAPI::TEST_F):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/API/JSScript.mm (277447 => 277448)


--- trunk/Source/_javascript_Core/API/JSScript.mm	2021-05-13 19:45:02 UTC (rev 277447)
+++ trunk/Source/_javascript_Core/API/JSScript.mm	2021-05-13 20:08:36 UTC (rev 277448)
@@ -90,7 +90,7 @@
         return false;
     }
 
-    if (!FileSystem::fileIsDirectory(directory, FileSystem::ShouldFollowSymbolicLinks::No)) {
+    if (!FileSystem::isDirectory(directory)) {
         createError([NSString stringWithFormat:@"Cache directory `%@` is not a directory or does not exist", static_cast<NSString *>(directory)], error);
         return false;
     }

Modified: trunk/Source/_javascript_Core/ChangeLog (277447 => 277448)


--- trunk/Source/_javascript_Core/ChangeLog	2021-05-13 19:45:02 UTC (rev 277447)
+++ trunk/Source/_javascript_Core/ChangeLog	2021-05-13 20:08:36 UTC (rev 277448)
@@ -1,3 +1,15 @@
+2021-05-13  Chris Dumez  <[email protected]>
+
+        Rename FileSystem::fileIsDirectory(path, followSymlinks) to isDirectory(path) / isDirectoryFollowingSymlinks(path)
+        https://bugs.webkit.org/show_bug.cgi?id=225772
+
+        Reviewed by Darin Adler.
+
+        Update code base due to API naming change.
+
+        * API/JSScript.mm:
+        (validateBytecodeCachePath):
+
 2021-05-13  Darin Adler  <[email protected]>
 
         Remove StringBuilder::appendNumber

Modified: trunk/Source/WTF/ChangeLog (277447 => 277448)


--- trunk/Source/WTF/ChangeLog	2021-05-13 19:45:02 UTC (rev 277447)
+++ trunk/Source/WTF/ChangeLog	2021-05-13 20:08:36 UTC (rev 277448)
@@ -1,5 +1,25 @@
 2021-05-13  Chris Dumez  <[email protected]>
 
+        Rename FileSystem::fileIsDirectory(path, followSymlinks) to isDirectory(path) / isDirectoryFollowingSymlinks(path)
+        https://bugs.webkit.org/show_bug.cgi?id=225772
+
+        Reviewed by Darin Adler.
+
+        I don't think the "file" prefix is useful here so I am renaming the function to
+        isDirectory(). Also, instead of using an enum parameter to decide whether or
+        not to follow symlink, I am adding a separate function called
+        isDirectoryFollowingSymlinks(). This is consistent with the
+        fileMetadata() / fileMetadataFollowingSymlinks() pattern, which Darin said he
+        preferred.
+
+        * wtf/FileSystem.cpp:
+        (WTF::FileSystemImpl::isDirectory):
+        (WTF::FileSystemImpl::isDirectoryFollowingSymlinks):
+        (WTF::FileSystemImpl::fileIsDirectory): Deleted.
+        * wtf/FileSystem.h:
+
+2021-05-13  Chris Dumez  <[email protected]>
+
         Introduce FileSystem::hardLinkCount()
         https://bugs.webkit.org/show_bug.cgi?id=225767
 

Modified: trunk/Source/WTF/wtf/FileSystem.cpp (277447 => 277448)


--- trunk/Source/WTF/wtf/FileSystem.cpp	2021-05-13 19:45:02 UTC (rev 277447)
+++ trunk/Source/WTF/wtf/FileSystem.cpp	2021-05-13 20:08:36 UTC (rev 277448)
@@ -607,17 +607,18 @@
     return true;
 }
 
-bool fileIsDirectory(const String& path, ShouldFollowSymbolicLinks shouldFollowSymbolicLinks)
+bool isDirectory(const String& path)
 {
     std::error_code ec;
-    std::filesystem::file_status fileStatus;
-    if (shouldFollowSymbolicLinks == ShouldFollowSymbolicLinks::Yes)
-        fileStatus = std::filesystem::status(toStdFileSystemPath(path), ec);
-    else
-        fileStatus = std::filesystem::symlink_status(toStdFileSystemPath(path), ec);
-    return fileStatus.type() == std::filesystem::file_type::directory;
+    return std::filesystem::symlink_status(toStdFileSystemPath(path), ec).type() == std::filesystem::file_type::directory;
 }
 
+bool isDirectoryFollowingSymlinks(const String& path)
+{
+    std::error_code ec;
+    return std::filesystem::status(toStdFileSystemPath(path), ec).type() == std::filesystem::file_type::directory;
+}
+
 bool makeAllDirectories(const String& path)
 {
     std::error_code ec;
@@ -686,6 +687,7 @@
     return toWallTime(modificationTime);
 }
 
+enum class ShouldFollowSymbolicLinks { No, Yes };
 static Optional<FileMetadata> fileMetadataPotentiallyFollowingSymlinks(const String& path, ShouldFollowSymbolicLinks shouldFollowSymbolicLinks)
 {
     if (path.isEmpty())

Modified: trunk/Source/WTF/wtf/FileSystem.h (277447 => 277448)


--- trunk/Source/WTF/wtf/FileSystem.h	2021-05-13 19:45:02 UTC (rev 277447)
+++ trunk/Source/WTF/wtf/FileSystem.h	2021-05-13 20:08:36 UTC (rev 277448)
@@ -107,8 +107,6 @@
     Private,
 };
 
-enum class ShouldFollowSymbolicLinks { No, Yes };
-
 WTF_EXPORT_PRIVATE bool fileExists(const String&);
 WTF_EXPORT_PRIVATE bool deleteFile(const String&);
 WTF_EXPORT_PRIVATE bool deleteEmptyDirectory(const String&);
@@ -119,7 +117,8 @@
 WTF_EXPORT_PRIVATE Optional<WallTime> getFileCreationTime(const String&); // Not all platforms store file creation time.
 WTF_EXPORT_PRIVATE Optional<FileMetadata> fileMetadata(const String& path);
 WTF_EXPORT_PRIVATE Optional<FileMetadata> fileMetadataFollowingSymlinks(const String& path);
-WTF_EXPORT_PRIVATE bool fileIsDirectory(const String&, ShouldFollowSymbolicLinks);
+WTF_EXPORT_PRIVATE bool isDirectory(const String&);
+WTF_EXPORT_PRIVATE bool isDirectoryFollowingSymlinks(const String&);
 WTF_EXPORT_PRIVATE String pathByAppendingComponent(const String& path, const String& component);
 WTF_EXPORT_PRIVATE String pathByAppendingComponents(StringView path, const Vector<StringView>& components);
 WTF_EXPORT_PRIVATE String lastComponentOfPathIgnoringTrailingSlash(const String& path);

Modified: trunk/Source/WebCore/ChangeLog (277447 => 277448)


--- trunk/Source/WebCore/ChangeLog	2021-05-13 19:45:02 UTC (rev 277447)
+++ trunk/Source/WebCore/ChangeLog	2021-05-13 20:08:36 UTC (rev 277448)
@@ -1,3 +1,27 @@
+2021-05-13  Chris Dumez  <[email protected]>
+
+        Rename FileSystem::fileIsDirectory(path, followSymlinks) to isDirectory(path) / isDirectoryFollowingSymlinks(path)
+        https://bugs.webkit.org/show_bug.cgi?id=225772
+
+        Reviewed by Darin Adler.
+
+        Update code base due to API naming change.
+
+        * Modules/entriesapi/DOMFileSystem.cpp:
+        (WebCore::listDirectoryWithMetadata):
+        * editing/cocoa/WebContentReaderCocoa.mm:
+        (WebCore::attachmentForFilePath):
+        * fileapi/File.cpp:
+        (WebCore::File::isDirectory const):
+        * html/DirectoryFileListCreator.cpp:
+        (WebCore::gatherFileInformation):
+        * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
+        (WebCore::CDMInstanceFairPlayStreamingAVFObjC::setStorageDirectory):
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::ensureAssetCacheExistsForPath):
+        * platform/network/FormData.cpp:
+        (WebCore::FormData::prepareForUpload):
+
 2021-05-13  Jer Noble  <[email protected]>
 
         [ macOS Wk2 ] media/media-fragments/TC0051.html is flakey crashing

Modified: trunk/Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp (277447 => 277448)


--- trunk/Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp	2021-05-13 19:45:02 UTC (rev 277447)
+++ trunk/Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp	2021-05-13 20:08:36 UTC (rev 277448)
@@ -51,7 +51,7 @@
 static ExceptionOr<Vector<ListedChild>> listDirectoryWithMetadata(const String& fullPath)
 {
     ASSERT(!isMainThread());
-    if (!FileSystem::fileIsDirectory(fullPath, FileSystem::ShouldFollowSymbolicLinks::No))
+    if (!FileSystem::isDirectory(fullPath))
         return Exception { NotFoundError, "Path no longer exists or is no longer a directory" };
 
     auto childNames = FileSystem::listDirectory(fullPath);

Modified: trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm (277447 => 277448)


--- trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm	2021-05-13 19:45:02 UTC (rev 277447)
+++ trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm	2021-05-13 20:08:36 UTC (rev 277448)
@@ -712,7 +712,7 @@
         return attachment;
     }
 
-    bool isDirectory = FileSystem::fileIsDirectory(path, FileSystem::ShouldFollowSymbolicLinks::Yes);
+    bool isDirectory = FileSystem::isDirectoryFollowingSymlinks(path);
     String contentType = typeForAttachmentElement(explicitContentType);
     if (contentType.isEmpty()) {
 ALLOW_DEPRECATED_DECLARATIONS_BEGIN

Modified: trunk/Source/WebCore/fileapi/File.cpp (277447 => 277448)


--- trunk/Source/WebCore/fileapi/File.cpp	2021-05-13 19:45:02 UTC (rev 277447)
+++ trunk/Source/WebCore/fileapi/File.cpp	2021-05-13 20:08:36 UTC (rev 277448)
@@ -148,7 +148,7 @@
 bool File::isDirectory() const
 {
     if (!m_isDirectory)
-        m_isDirectory = FileSystem::fileIsDirectory(m_path, FileSystem::ShouldFollowSymbolicLinks::Yes);
+        m_isDirectory = FileSystem::isDirectoryFollowingSymlinks(m_path);
     return *m_isDirectory;
 }
 

Modified: trunk/Source/WebCore/html/DirectoryFileListCreator.cpp (277447 => 277448)


--- trunk/Source/WebCore/html/DirectoryFileListCreator.cpp	2021-05-13 19:45:02 UTC (rev 277447)
+++ trunk/Source/WebCore/html/DirectoryFileListCreator.cpp	2021-05-13 20:08:36 UTC (rev 277448)
@@ -76,7 +76,7 @@
     ASSERT(!isMainThread());
     Vector<FileInformation> files;
     for (auto& info : paths) {
-        if (FileSystem::fileIsDirectory(info.path, FileSystem::ShouldFollowSymbolicLinks::No))
+        if (FileSystem::isDirectory(info.path))
             appendDirectoryFiles(info.path, FileSystem::pathGetFileName(info.path), files);
         else
             files.append(FileInformation { info.path, { }, info.displayName });

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm (277447 => 277448)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm	2021-05-13 19:45:02 UTC (rev 277447)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm	2021-05-13 20:08:36 UTC (rev 277448)
@@ -401,7 +401,7 @@
     if (!FileSystem::fileExists(storageDirectory)) {
         if (!FileSystem::makeAllDirectories(storageDirectory))
             return;
-    } else if (!FileSystem::fileIsDirectory(storageDirectory, FileSystem::ShouldFollowSymbolicLinks::Yes)) {
+    } else if (!FileSystem::isDirectoryFollowingSymlinks(storageDirectory)) {
         auto tempDirectory = FileSystem::createTemporaryDirectory(@"MediaKeys");
         if (!tempDirectory)
             return;

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (277447 => 277448)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2021-05-13 19:45:02 UTC (rev 277447)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2021-05-13 20:08:36 UTC (rev 277448)
@@ -338,7 +338,7 @@
 
     auto fileExistsAtPath = FileSystem::fileExists(path);
 
-    if (fileExistsAtPath && !FileSystem::fileIsDirectory(path, FileSystem::ShouldFollowSymbolicLinks::Yes)) {
+    if (fileExistsAtPath && !FileSystem::isDirectoryFollowingSymlinks(path)) {
         // Non-directory file already exists at the path location; bail.
         ASSERT_NOT_REACHED();
         return nil;

Modified: trunk/Source/WebCore/platform/network/FormData.cpp (277447 => 277448)


--- trunk/Source/WebCore/platform/network/FormData.cpp	2021-05-13 19:45:02 UTC (rev 277447)
+++ trunk/Source/WebCore/platform/network/FormData.cpp	2021-05-13 20:08:36 UTC (rev 277448)
@@ -357,7 +357,7 @@
         auto* fileData = WTF::get_if<FormDataElement::EncodedFileData>(element.data);
         if (!fileData)
             continue;
-        if (!FileSystem::fileIsDirectory(fileData->filename, FileSystem::ShouldFollowSymbolicLinks::Yes))
+        if (!FileSystem::isDirectoryFollowingSymlinks(fileData->filename))
             continue;
         if (fileData->fileStart || fileData->fileLength != BlobDataItem::toEndOfFile)
             continue;

Modified: trunk/Source/WebKit/ChangeLog (277447 => 277448)


--- trunk/Source/WebKit/ChangeLog	2021-05-13 19:45:02 UTC (rev 277447)
+++ trunk/Source/WebKit/ChangeLog	2021-05-13 20:08:36 UTC (rev 277448)
@@ -1,5 +1,23 @@
 2021-05-13  Chris Dumez  <[email protected]>
 
+        Rename FileSystem::fileIsDirectory(path, followSymlinks) to isDirectory(path) / isDirectoryFollowingSymlinks(path)
+        https://bugs.webkit.org/show_bug.cgi?id=225772
+
+        Reviewed by Darin Adler.
+
+        Update code base due to API naming change.
+
+        * NetworkProcess/cache/CacheStorageEngine.cpp:
+        (WebKit::CacheStorage::getDirectorySize):
+        (WebKit::CacheStorage::Engine::getDirectories):
+        (WebKit::CacheStorage::Engine::clearAllCachesFromDisk):
+        * NetworkProcess/cache/NetworkCacheFileSystem.cpp:
+        (WebKit::NetworkCache::traverseDirectory):
+        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+        (WebKit::isInternalInstall):
+
+2021-05-13  Chris Dumez  <[email protected]>
+
         Process suspension may be delayed by up to 5 seconds after there is no longer any database activity
         https://bugs.webkit.org/show_bug.cgi?id=225774
 

Modified: trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp (277447 => 277448)


--- trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp	2021-05-13 19:45:02 UTC (rev 277447)
+++ trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp	2021-05-13 20:08:36 UTC (rev 277448)
@@ -207,7 +207,7 @@
     paths.append(directoryPath);
     while (!paths.isEmpty()) {
         auto path = paths.takeFirst();
-        if (FileSystem::fileIsDirectory(path, FileSystem::ShouldFollowSymbolicLinks::No)) {
+        if (FileSystem::isDirectory(path)) {
             auto fileNames = FileSystem::listDirectory(path);
             for (auto& fileName : fileNames) {
                 // Files in /Blobs directory are hard link.
@@ -616,7 +616,7 @@
         Vector<String> folderPaths;
         for (auto& fileName : FileSystem::listDirectory(path)) {
             auto filePath = FileSystem::pathByAppendingComponent(path, fileName);
-            if (FileSystem::fileIsDirectory(filePath, FileSystem::ShouldFollowSymbolicLinks::No))
+            if (FileSystem::isDirectory(filePath))
                 folderPaths.append(filePath.isolatedCopy());
         }
 
@@ -704,7 +704,7 @@
         LockHolder locker(globalSizeFileLock);
         for (auto& fileName : FileSystem::listDirectory(path)) {
             auto filePath = FileSystem::pathByAppendingComponent(path, fileName);
-            if (FileSystem::fileIsDirectory(filePath, FileSystem::ShouldFollowSymbolicLinks::No))
+            if (FileSystem::isDirectory(filePath))
                 FileSystem::deleteNonEmptyDirectory(filePath);
         }
         RunLoop::main().dispatch(WTFMove(completionHandler));

Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.cpp (277447 => 277448)


--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.cpp	2021-05-13 19:45:02 UTC (rev 277447)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.cpp	2021-05-13 20:08:36 UTC (rev 277448)
@@ -58,7 +58,7 @@
     auto entries = FileSystem::listDirectory(path);
     for (auto& entry : entries) {
         auto entryPath = FileSystem::pathByAppendingComponent(path, entry);
-        auto type = FileSystem::fileIsDirectory(entryPath, FileSystem::ShouldFollowSymbolicLinks::No) ? DirectoryEntryType::Directory : DirectoryEntryType::File;
+        auto type = FileSystem::isDirectory(entryPath) ? DirectoryEntryType::Directory : DirectoryEntryType::File;
         function(entry, type);
     }
 }

Modified: trunk/Source/WebKit/Shared/mac/AuxiliaryProcessMac.mm (277447 => 277448)


--- trunk/Source/WebKit/Shared/mac/AuxiliaryProcessMac.mm	2021-05-13 19:45:02 UTC (rev 277447)
+++ trunk/Source/WebKit/Shared/mac/AuxiliaryProcessMac.mm	2021-05-13 20:08:36 UTC (rev 277448)
@@ -331,9 +331,9 @@
 
 static bool ensureSandboxCacheDirectory(const SandboxInfo& info)
 {
-    if (!FileSystem::fileIsDirectory(info.parentDirectoryPath, FileSystem::ShouldFollowSymbolicLinks::Yes)) {
+    if (!FileSystem::isDirectoryFollowingSymlinks(info.parentDirectoryPath)) {
         FileSystem::makeAllDirectories(info.parentDirectoryPath);
-        if (!FileSystem::fileIsDirectory(info.parentDirectoryPath, FileSystem::ShouldFollowSymbolicLinks::Yes)) {
+        if (!FileSystem::isDirectoryFollowingSymlinks(info.parentDirectoryPath)) {
             WTFLogAlways("%s: Could not create sandbox directory\n", getprogname());
             return false;
         }
@@ -363,7 +363,7 @@
         if (!rootless_check_datavault_flag(directoryPath.data(), storageClass))
             return true;
 
-        bool isDirectory = FileSystem::fileIsDirectory(info.directoryPath, FileSystem::ShouldFollowSymbolicLinks::No);
+        bool isDirectory = FileSystem::isDirectory(info.directoryPath);
         if (isDirectory) {
             if (!FileSystem::deleteNonEmptyDirectory(info.directoryPath))
                 return false;
@@ -379,14 +379,14 @@
         return false;
     }
 #else
-    bool hasSandboxDirectory = FileSystem::fileIsDirectory(info.directoryPath, FileSystem::ShouldFollowSymbolicLinks::Yes);
+    bool hasSandboxDirectory = FileSystem::isDirectoryFollowingSymlinks(info.directoryPath);
     if (!hasSandboxDirectory) {
         if (FileSystem::makeAllDirectories(info.directoryPath)) {
-            ASSERT(FileSystem::fileIsDirectory(info.directoryPath, FileSystem::ShouldFollowSymbolicLinks::Yes));
+            ASSERT(FileSystem::isDirectoryFollowingSymlinks(info.directoryPath));
             hasSandboxDirectory = true;
         } else {
             // We may have raced with someone else making it. That's ok.
-            hasSandboxDirectory = FileSystem::fileIsDirectory(info.directoryPath, FileSystem::ShouldFollowSymbolicLinks::Yes);
+            hasSandboxDirectory = FileSystem::isDirectoryFollowingSymlinks(info.directoryPath);
         }
     }
 

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (277447 => 277448)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2021-05-13 19:45:02 UTC (rev 277447)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2021-05-13 20:08:36 UTC (rev 277448)
@@ -217,7 +217,7 @@
 #if PLATFORM(IOS_FAMILY)
     static bool isInternal = MGGetBoolAnswer(kMGQAppleInternalInstallCapability);
 #else
-    static bool isInternal = FileSystem::fileIsDirectory("/AppleInternal", FileSystem::ShouldFollowSymbolicLinks::No);
+    static bool isInternal = FileSystem::isDirectory("/AppleInternal");
 #endif
     return isInternal;
 }

Modified: trunk/Tools/ChangeLog (277447 => 277448)


--- trunk/Tools/ChangeLog	2021-05-13 19:45:02 UTC (rev 277447)
+++ trunk/Tools/ChangeLog	2021-05-13 20:08:36 UTC (rev 277448)
@@ -1,5 +1,17 @@
 2021-05-13  Chris Dumez  <[email protected]>
 
+        Rename FileSystem::fileIsDirectory(path, followSymlinks) to isDirectory(path) / isDirectoryFollowingSymlinks(path)
+        https://bugs.webkit.org/show_bug.cgi?id=225772
+
+        Reviewed by Darin Adler.
+
+        Update code base due to API naming change.
+
+        * TestWebKitAPI/Tests/WTF/FileSystem.cpp:
+        (TestWebKitAPI::TEST_F):
+
+2021-05-13  Chris Dumez  <[email protected]>
+
         Introduce FileSystem::hardLinkCount()
         https://bugs.webkit.org/show_bug.cgi?id=225767
 

Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp (277447 => 277448)


--- trunk/Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp	2021-05-13 19:45:02 UTC (rev 277447)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp	2021-05-13 20:08:36 UTC (rev 277448)
@@ -503,41 +503,41 @@
     EXPECT_TRUE(!fileSize);
 }
 
-TEST_F(FileSystemTest, fileIsDirectory)
+TEST_F(FileSystemTest, isDirectory)
 {
-    EXPECT_TRUE(FileSystem::fileIsDirectory(tempEmptyFolderPath(), FileSystem::ShouldFollowSymbolicLinks::No));
-    EXPECT_TRUE(FileSystem::fileIsDirectory(tempEmptyFolderPath(), FileSystem::ShouldFollowSymbolicLinks::Yes));
+    EXPECT_TRUE(FileSystem::isDirectory(tempEmptyFolderPath()));
+    EXPECT_TRUE(FileSystem::isDirectoryFollowingSymlinks(tempEmptyFolderPath()));
 
     auto folderSymlinkMetadata = FileSystem::fileMetadata(tempEmptyFolderSymlinkPath());
     EXPECT_TRUE(!!folderSymlinkMetadata);
     EXPECT_EQ(folderSymlinkMetadata->type, FileMetadata::Type::SymbolicLink);
-    EXPECT_FALSE(FileSystem::fileIsDirectory(tempEmptyFolderSymlinkPath(), FileSystem::ShouldFollowSymbolicLinks::No));
-    EXPECT_TRUE(FileSystem::fileIsDirectory(tempEmptyFolderSymlinkPath(), FileSystem::ShouldFollowSymbolicLinks::Yes));
+    EXPECT_FALSE(FileSystem::isDirectory(tempEmptyFolderSymlinkPath()));
+    EXPECT_TRUE(FileSystem::isDirectoryFollowingSymlinks(tempEmptyFolderSymlinkPath()));
 
-    EXPECT_FALSE(FileSystem::fileIsDirectory(tempFilePath(), FileSystem::ShouldFollowSymbolicLinks::No));
-    EXPECT_FALSE(FileSystem::fileIsDirectory(tempFilePath(), FileSystem::ShouldFollowSymbolicLinks::Yes));
+    EXPECT_FALSE(FileSystem::isDirectory(tempFilePath()));
+    EXPECT_FALSE(FileSystem::isDirectoryFollowingSymlinks(tempFilePath()));
 
     auto fileSymlinkMetadata = FileSystem::fileMetadata(tempFileSymlinkPath());
     EXPECT_TRUE(!!fileSymlinkMetadata);
     EXPECT_EQ(fileSymlinkMetadata->type, FileMetadata::Type::SymbolicLink);
-    EXPECT_FALSE(FileSystem::fileIsDirectory(tempFileSymlinkPath(), FileSystem::ShouldFollowSymbolicLinks::No));
-    EXPECT_FALSE(FileSystem::fileIsDirectory(tempFileSymlinkPath(), FileSystem::ShouldFollowSymbolicLinks::Yes));
+    EXPECT_FALSE(FileSystem::isDirectory(tempFileSymlinkPath()));
+    EXPECT_FALSE(FileSystem::isDirectoryFollowingSymlinks(tempFileSymlinkPath()));
 
     String fileThatDoesNotExist = FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "does-not-exist"_s);
-    EXPECT_FALSE(FileSystem::fileIsDirectory(fileThatDoesNotExist, FileSystem::ShouldFollowSymbolicLinks::No));
-    EXPECT_FALSE(FileSystem::fileIsDirectory(fileThatDoesNotExist, FileSystem::ShouldFollowSymbolicLinks::Yes));
+    EXPECT_FALSE(FileSystem::isDirectory(fileThatDoesNotExist));
+    EXPECT_FALSE(FileSystem::isDirectoryFollowingSymlinks(fileThatDoesNotExist));
 }
 
 TEST_F(FileSystemTest, makeAllDirectories)
 {
     EXPECT_TRUE(FileSystem::fileExists(tempEmptyFolderPath()));
-    EXPECT_TRUE(FileSystem::fileIsDirectory(tempEmptyFolderPath(), FileSystem::ShouldFollowSymbolicLinks::No));
+    EXPECT_TRUE(FileSystem::isDirectory(tempEmptyFolderPath()));
     EXPECT_TRUE(FileSystem::makeAllDirectories(tempEmptyFolderPath()));
     String subFolderPath = FileSystem::pathByAppendingComponents(tempEmptyFolderPath(), { "subFolder1", "subFolder2", "subFolder3" });
     EXPECT_FALSE(FileSystem::fileExists(subFolderPath));
     EXPECT_TRUE(FileSystem::makeAllDirectories(subFolderPath));
     EXPECT_TRUE(FileSystem::fileExists(subFolderPath));
-    EXPECT_TRUE(FileSystem::fileIsDirectory(subFolderPath, FileSystem::ShouldFollowSymbolicLinks::No));
+    EXPECT_TRUE(FileSystem::isDirectory(subFolderPath));
     EXPECT_TRUE(FileSystem::deleteNonEmptyDirectory(tempEmptyFolderPath()));
     EXPECT_FALSE(FileSystem::fileExists(subFolderPath));
 }
@@ -580,8 +580,8 @@
     EXPECT_TRUE(!!symlinkMetadata);
     EXPECT_EQ(symlinkMetadata->type, FileMetadata::Type::SymbolicLink);
 
-    EXPECT_FALSE(FileSystem::fileIsDirectory(symlinkPath, FileSystem::ShouldFollowSymbolicLinks::No));
-    EXPECT_TRUE(FileSystem::fileIsDirectory(symlinkPath, FileSystem::ShouldFollowSymbolicLinks::Yes));
+    EXPECT_FALSE(FileSystem::isDirectory(symlinkPath));
+    EXPECT_TRUE(FileSystem::isDirectoryFollowingSymlinks(symlinkPath));
 
     EXPECT_TRUE(FileSystem::deleteFile(symlinkPath));
     EXPECT_FALSE(FileSystem::fileExists(symlinkPath));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to