Diff
Modified: trunk/Source/_javascript_Core/API/JSScript.mm (277534 => 277535)
--- trunk/Source/_javascript_Core/API/JSScript.mm 2021-05-15 05:26:41 UTC (rev 277534)
+++ trunk/Source/_javascript_Core/API/JSScript.mm 2021-05-15 05:46:43 UTC (rev 277535)
@@ -38,7 +38,6 @@
#import "JSVirtualMachineInternal.h"
#import "Symbol.h"
#import <sys/stat.h>
-#import <wtf/FileMetadata.h>
#import <wtf/FileSystem.h>
#import <wtf/SHA1.h>
#import <wtf/Scope.h>
@@ -77,8 +76,8 @@
String systemPath = cachePathURL.fileSystemPath();
- if (auto metadata = FileSystem::fileMetadata(systemPath)) {
- if (metadata->type != FileMetadata::Type::File) {
+ if (auto fileType = FileSystem::fileType(systemPath)) {
+ if (*fileType != FileSystem::FileType::Regular) {
createError([NSString stringWithFormat:@"Cache path `%@` already exists and is not a file", static_cast<NSString *>(systemPath)], error);
return false;
}
@@ -90,7 +89,7 @@
return false;
}
- if (!FileSystem::isDirectory(directory)) {
+ if (FileSystem::fileType(directory) != FileSystem::FileType::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 (277534 => 277535)
--- trunk/Source/_javascript_Core/ChangeLog 2021-05-15 05:26:41 UTC (rev 277534)
+++ trunk/Source/_javascript_Core/ChangeLog 2021-05-15 05:46:43 UTC (rev 277535)
@@ -1,3 +1,15 @@
+2021-05-14 Chris Dumez <[email protected]>
+
+ Drop FileSystem::fileMetadata() / fileMetadataFollowingSymlinks()
+ https://bugs.webkit.org/show_bug.cgi?id=225820
+
+ Reviewed by Darin Adler.
+
+ Update our code base because of the FileSystem API changes.
+
+ * API/JSScript.mm:
+ (validateBytecodeCachePath):
+
2021-05-14 Ross Kirsling <[email protected]>
REGRESSION (r277221): 2 test262 tests failing
Modified: trunk/Source/WTF/ChangeLog (277534 => 277535)
--- trunk/Source/WTF/ChangeLog 2021-05-15 05:26:41 UTC (rev 277534)
+++ trunk/Source/WTF/ChangeLog 2021-05-15 05:46:43 UTC (rev 277535)
@@ -1,5 +1,34 @@
2021-05-14 Chris Dumez <[email protected]>
+ Drop FileSystem::fileMetadata() / fileMetadataFollowingSymlinks()
+ https://bugs.webkit.org/show_bug.cgi?id=225820
+
+ Reviewed by Darin Adler.
+
+ Drop FileSystem::fileMetadata() / fileMetadataFollowingSymlinks(). Those don't match very closely the
+ std::filesystem API we use internally and they are not very efficient because we gather several attributes
+ of a file but the callers are usually only interested in one thing (e.g. file type or file size).
+
+ Callers interested in the file size, can call the pre-existing FileSystem::fileSize(). For call sites
+ wanting to check if it is a hidden file, I introduced a new FileSystem::isHiddenFile() API. For call sites
+ interested in the file type, I replaced FileSystem::isDirectory() / FileSystem::isDirectoryFollowingSymlinks()
+ with more generic FileSystem::fileType() / FileSystem::fileTypeFollowingSymlinks().
+
+ * WTF.xcodeproj/project.pbxproj:
+ * wtf/CMakeLists.txt:
+ * wtf/FileMetadata.h: Removed.
+ * wtf/FileSystem.cpp:
+ (WTF::FileSystemImpl::isHiddenFile):
+ (WTF::FileSystemImpl::fileTypePotentiallyFollowingSymLinks):
+ (WTF::FileSystemImpl::fileType):
+ (WTF::FileSystemImpl::fileTypeFollowingSymlinks):
+ * wtf/FileSystem.h:
+ * wtf/glib/FileSystemGlib.cpp:
+ * wtf/posix/FileSystemPOSIX.cpp:
+ * wtf/win/FileSystemWin.cpp:
+
+2021-05-14 Chris Dumez <[email protected]>
+
Drop legacy / prefixed WebAudio implementation
https://bugs.webkit.org/show_bug.cgi?id=225832
Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (277534 => 277535)
--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj 2021-05-15 05:26:41 UTC (rev 277534)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj 2021-05-15 05:46:43 UTC (rev 277535)
@@ -512,7 +512,6 @@
A30D412C1F0DE0BA00B71954 /* SoftLinking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SoftLinking.h; sourceTree = "<group>"; };
A30D412D1F0DE13F00B71954 /* SoftLinking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SoftLinking.h; sourceTree = "<group>"; };
A32D8FA421FFFAB400780662 /* ThreadingPOSIX.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadingPOSIX.cpp; sourceTree = "<group>"; };
- A331D95821F24978009F02AA /* FileMetadata.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileMetadata.h; sourceTree = "<group>"; };
A331D95921F24992009F02AA /* FileSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileSystem.h; sourceTree = "<group>"; };
A331D95A21F24992009F02AA /* FileSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileSystem.cpp; sourceTree = "<group>"; };
A331D95C21F249E4009F02AA /* FileSystemCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileSystemCF.cpp; sourceTree = "<group>"; };
@@ -1039,7 +1038,6 @@
A8A472A1151A825A004123FF /* FastMalloc.cpp */,
A8A472A2151A825A004123FF /* FastMalloc.h */,
0F79C7C31E73511800EB34D1 /* FastTLS.h */,
- A331D95821F24978009F02AA /* FileMetadata.h */,
0F9D335B165DBA73005AD387 /* FilePrintStream.cpp */,
0F9D335C165DBA73005AD387 /* FilePrintStream.h */,
A331D95A21F24992009F02AA /* FileSystem.cpp */,
Modified: trunk/Source/WTF/wtf/CMakeLists.txt (277534 => 277535)
--- trunk/Source/WTF/wtf/CMakeLists.txt 2021-05-15 05:26:41 UTC (rev 277534)
+++ trunk/Source/WTF/wtf/CMakeLists.txt 2021-05-15 05:46:43 UTC (rev 277535)
@@ -68,7 +68,6 @@
FastBitVector.h
FastMalloc.h
FastTLS.h
- FileMetadata.h
FilePrintStream.h
FileSystem.h
FixedVector.h
Deleted: trunk/Source/WTF/wtf/FileMetadata.h (277534 => 277535)
--- trunk/Source/WTF/wtf/FileMetadata.h 2021-05-15 05:26:41 UTC (rev 277534)
+++ trunk/Source/WTF/wtf/FileMetadata.h 2021-05-15 05:46:43 UTC (rev 277535)
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2010 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#include <wtf/WallTime.h>
-
-namespace WTF {
-
-struct FileMetadata {
- WTF_MAKE_STRUCT_FAST_ALLOCATED;
-
- // The last modification time of the file, in seconds.
- WallTime modificationTime;
-
- // The length of the file in bytes.
- long long length;
-
- bool isHidden;
-
- enum class Type { File, Directory, SymbolicLink };
- Type type;
-};
-
-} // namespace WTF
-
-using WTF::FileMetadata;
Modified: trunk/Source/WTF/wtf/FileSystem.cpp (277534 => 277535)
--- trunk/Source/WTF/wtf/FileSystem.cpp 2021-05-15 05:26:41 UTC (rev 277534)
+++ trunk/Source/WTF/wtf/FileSystem.cpp 2021-05-15 05:46:43 UTC (rev 277535)
@@ -28,7 +28,6 @@
#include <wtf/FileSystem.h>
#include <wtf/CryptographicallyRandomNumber.h>
-#include <wtf/FileMetadata.h>
#include <wtf/HexNumber.h>
#include <wtf/Scope.h>
#include <wtf/StdFilesystem.h>
@@ -139,20 +138,6 @@
return WallTime::fromRawSeconds(toTimeT(fileTime));
}
-static std::filesystem::path resolveSymlinks(std::filesystem::path path, std::error_code& ec)
-{
-#ifdef MAXSYMLINKS
- static constexpr unsigned maxSymlinkDepth = MAXSYMLINKS;
-#else
- static constexpr unsigned maxSymlinkDepth = 40;
-#endif
-
- unsigned currentDepth = 0;
- while (++currentDepth <= maxSymlinkDepth && !ec && std::filesystem::is_symlink(path, ec))
- path = std::filesystem::read_symlink(path, ec);
- return path;
-}
-
String encodeForFileName(const String& inputString)
{
unsigned length = inputString.length();
@@ -606,18 +591,6 @@
return size;
}
-bool isDirectory(const String& path)
-{
- std::error_code ec;
- 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;
@@ -692,56 +665,44 @@
return !ec;
}
-enum class ShouldFollowSymbolicLinks { No, Yes };
-static Optional<FileMetadata> fileMetadataPotentiallyFollowingSymlinks(const String& path, ShouldFollowSymbolicLinks shouldFollowSymbolicLinks)
+bool isHiddenFile(const String& path)
{
- if (path.isEmpty())
- return WTF::nullopt;
-
+#if OS(UNIX)
auto fsPath = toStdFileSystemPath(path);
+ std::filesystem::path::string_type filename = fsPath.filename();
+ return !filename.empty() && filename[0] == '.';
+#else
+ UNUSED_PARAM(path);
+ return false;
+#endif
+}
+enum class ShouldFollowSymbolicLinks { No, Yes };
+static Optional<FileType> fileTypePotentiallyFollowingSymLinks(const String& path, ShouldFollowSymbolicLinks shouldFollowSymbolicLinks)
+{
std::error_code ec;
- if (shouldFollowSymbolicLinks == ShouldFollowSymbolicLinks::Yes && std::filesystem::is_symlink(fsPath, ec)) {
- fsPath = resolveSymlinks(fsPath, ec);
- if (ec)
- return WTF::nullopt;
- }
-
- ec = { };
- std::filesystem::directory_entry entry(fsPath, ec);
+ auto status = shouldFollowSymbolicLinks == ShouldFollowSymbolicLinks::Yes ? std::filesystem::status(toStdFileSystemPath(path), ec) : std::filesystem::symlink_status(toStdFileSystemPath(path), ec);
if (ec)
return WTF::nullopt;
-
- auto modificationTime = toWallTime(entry.last_write_time(ec));
-
- // Note that the result of attempting to determine the size of a directory is implementation-defined.
- auto fileSize = entry.file_size(ec);
- if (ec)
- fileSize = 0;
-
-#if OS(UNIX)
- std::filesystem::path::string_type filename = fsPath.filename();
- bool isHidden = !filename.empty() && filename[0] == '.';
-#else
- bool isHidden = false;
-#endif
- FileMetadata::Type type = FileMetadata::Type::File;
- if (entry.is_symlink(ec))
- type = FileMetadata::Type::SymbolicLink;
- else if (entry.is_directory(ec))
- type = FileMetadata::Type::Directory;
-
- return FileMetadata { modificationTime, static_cast<long long>(fileSize), isHidden, type };
+ switch (status.type()) {
+ case std::filesystem::file_type::directory:
+ return FileType::Directory;
+ case std::filesystem::file_type::symlink:
+ return FileType::SymbolicLink;
+ default:
+ break;
+ }
+ return FileType::Regular;
}
-Optional<FileMetadata> fileMetadata(const String& path)
+Optional<FileType> fileType(const String& path)
{
- return fileMetadataPotentiallyFollowingSymlinks(path, ShouldFollowSymbolicLinks::No);
+ return fileTypePotentiallyFollowingSymLinks(path, ShouldFollowSymbolicLinks::No);
}
-Optional<FileMetadata> fileMetadataFollowingSymlinks(const String& path)
+Optional<FileType> fileTypeFollowingSymlinks(const String& path)
{
- return fileMetadataPotentiallyFollowingSymlinks(path, ShouldFollowSymbolicLinks::Yes);
+ return fileTypePotentiallyFollowingSymLinks(path, ShouldFollowSymbolicLinks::Yes);
}
String pathFileName(const String& path)
Modified: trunk/Source/WTF/wtf/FileSystem.h (277534 => 277535)
--- trunk/Source/WTF/wtf/FileSystem.h 2021-05-15 05:26:41 UTC (rev 277534)
+++ trunk/Source/WTF/wtf/FileSystem.h 2021-05-15 05:46:43 UTC (rev 277535)
@@ -58,8 +58,6 @@
namespace WTF {
-struct FileMetadata;
-
namespace FileSystemImpl {
// PlatformFileHandle
@@ -111,15 +109,12 @@
WTF_EXPORT_PRIVATE bool deleteFile(const String&);
WTF_EXPORT_PRIVATE bool deleteEmptyDirectory(const String&);
WTF_EXPORT_PRIVATE bool moveFile(const String& oldPath, const String& newPath);
-WTF_EXPORT_PRIVATE Optional<uint64_t> fileSize(const String&);
+WTF_EXPORT_PRIVATE Optional<uint64_t> fileSize(const String&); // Follows symlinks.
WTF_EXPORT_PRIVATE Optional<uint64_t> fileSize(PlatformFileHandle);
WTF_EXPORT_PRIVATE Optional<WallTime> fileModificationTime(const String&);
WTF_EXPORT_PRIVATE bool updateFileModificationTime(const String& path); // Sets modification time to now.
WTF_EXPORT_PRIVATE Optional<WallTime> fileCreationTime(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 isDirectory(const String&);
-WTF_EXPORT_PRIVATE bool isDirectoryFollowingSymlinks(const String&);
+WTF_EXPORT_PRIVATE bool isHiddenFile(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);
@@ -131,6 +126,10 @@
WTF_EXPORT_PRIVATE bool createSymbolicLink(const String& targetPath, const String& symbolicLinkPath);
WTF_EXPORT_PRIVATE String createTemporaryZipArchive(const String& directory);
+enum class FileType { Regular, Directory, SymbolicLink };
+WTF_EXPORT_PRIVATE Optional<FileType> fileType(const String&);
+WTF_EXPORT_PRIVATE Optional<FileType> fileTypeFollowingSymlinks(const String&);
+
WTF_EXPORT_PRIVATE void setMetadataURL(const String& path, const String& urlString, const String& referrer = { });
bool canExcludeFromBackup(); // Returns true if any file can ever be excluded from backup.
Modified: trunk/Source/WTF/wtf/glib/FileSystemGlib.cpp (277534 => 277535)
--- trunk/Source/WTF/wtf/glib/FileSystemGlib.cpp 2021-05-15 05:26:41 UTC (rev 277534)
+++ trunk/Source/WTF/wtf/glib/FileSystemGlib.cpp 2021-05-15 05:46:43 UTC (rev 277535)
@@ -29,7 +29,6 @@
#include <glib/gstdio.h>
#include <sys/file.h>
#include <wtf/EnumTraits.h>
-#include <wtf/FileMetadata.h>
#include <wtf/UUID.h>
#include <wtf/glib/GLibUtilities.h>
#include <wtf/glib/GRefPtr.h>
Modified: trunk/Source/WTF/wtf/posix/FileSystemPOSIX.cpp (277534 => 277535)
--- trunk/Source/WTF/wtf/posix/FileSystemPOSIX.cpp 2021-05-15 05:26:41 UTC (rev 277534)
+++ trunk/Source/WTF/wtf/posix/FileSystemPOSIX.cpp 2021-05-15 05:46:43 UTC (rev 277535)
@@ -40,7 +40,6 @@
#include <sys/types.h>
#include <unistd.h>
#include <wtf/EnumTraits.h>
-#include <wtf/FileMetadata.h>
#include <wtf/text/CString.h>
#include <wtf/text/StringBuilder.h>
#include <wtf/text/WTFString.h>
Modified: trunk/Source/WTF/wtf/win/FileSystemWin.cpp (277534 => 277535)
--- trunk/Source/WTF/wtf/win/FileSystemWin.cpp 2021-05-15 05:26:41 UTC (rev 277534)
+++ trunk/Source/WTF/wtf/win/FileSystemWin.cpp 2021-05-15 05:46:43 UTC (rev 277535)
@@ -36,7 +36,6 @@
#include <sys/stat.h>
#include <windows.h>
#include <wtf/CryptographicallyRandomNumber.h>
-#include <wtf/FileMetadata.h>
#include <wtf/HashMap.h>
#include <wtf/text/CString.h>
#include <wtf/text/StringBuilder.h>
Modified: trunk/Source/WebCore/ChangeLog (277534 => 277535)
--- trunk/Source/WebCore/ChangeLog 2021-05-15 05:26:41 UTC (rev 277534)
+++ trunk/Source/WebCore/ChangeLog 2021-05-15 05:46:43 UTC (rev 277535)
@@ -1,3 +1,39 @@
+2021-05-14 Chris Dumez <[email protected]>
+
+ Drop FileSystem::fileMetadata() / fileMetadataFollowingSymlinks()
+ https://bugs.webkit.org/show_bug.cgi?id=225820
+
+ Reviewed by Darin Adler.
+
+ Update our code base because of the FileSystem API changes.
+
+ * Modules/entriesapi/DOMFileSystem.cpp:
+ (WebCore::listDirectoryWithMetadata):
+ (WebCore::toFileSystemEntries):
+ (WebCore::fileTypeIgnoringHiddenFiles):
+ (WebCore::validatePathIsExpectedType):
+ (WebCore::DOMFileSystem::getParent):
+ (WebCore::DOMFileSystem::getEntry):
+ (WebCore::DOMFileSystem::getFile):
+ * editing/cocoa/WebContentReaderCocoa.mm:
+ (WebCore::attachmentForFilePath):
+ * fileapi/File.cpp:
+ (WebCore::File::isDirectory const):
+ * html/DirectoryFileListCreator.cpp:
+ (WebCore::appendDirectoryFiles):
+ (WebCore::gatherFileInformation):
+ * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
+ (WebCore::CDMInstanceFairPlayStreamingAVFObjC::setStorageDirectory):
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+ (WebCore::ensureAssetCacheExistsForPath):
+ * platform/network/BlobDataFileReference.cpp:
+ (WebCore::BlobDataFileReference::startTrackingModifications):
+ * platform/network/BlobRegistryImpl.cpp:
+ * platform/network/FormData.cpp:
+ (WebCore::FormData::prepareForUpload):
+ * platform/network/mac/BlobDataFileReferenceMac.mm:
+ (WebCore::BlobDataFileReference::generateReplacementFile):
+
2021-05-14 John Wilander <[email protected]>
_javascript_ can't access a SameSite=Strict cookie after page is loaded after a redirect from a third party site
Modified: trunk/Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp (277534 => 277535)
--- trunk/Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp 2021-05-15 05:26:41 UTC (rev 277534)
+++ trunk/Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp 2021-05-15 05:46:43 UTC (rev 277535)
@@ -31,7 +31,6 @@
#include "FileSystemFileEntry.h"
#include "ScriptExecutionContext.h"
#include <wtf/CrossThreadCopier.h>
-#include <wtf/FileMetadata.h>
#include <wtf/FileSystem.h>
#include <wtf/IsoMallocInlines.h>
#include <wtf/UUID.h>
@@ -43,15 +42,22 @@
struct ListedChild {
String filename;
- FileMetadata::Type type;
+ FileSystem::FileType type;
ListedChild isolatedCopy() const { return { filename.isolatedCopy(), type }; }
};
+static Optional<FileSystem::FileType> fileTypeIgnoringHiddenFiles(const String& fullPath)
+{
+ if (FileSystem::isHiddenFile(fullPath))
+ return WTF::nullopt;
+ return FileSystem::fileType(fullPath);
+}
+
static ExceptionOr<Vector<ListedChild>> listDirectoryWithMetadata(const String& fullPath)
{
ASSERT(!isMainThread());
- if (!FileSystem::isDirectory(fullPath))
+ if (FileSystem::fileType(fullPath) != FileSystem::FileType::Directory)
return Exception { NotFoundError, "Path no longer exists or is no longer a directory" };
auto childNames = FileSystem::listDirectory(fullPath);
@@ -58,10 +64,11 @@
Vector<ListedChild> listedChildren;
listedChildren.reserveInitialCapacity(childNames.size());
for (auto& childName : childNames) {
- auto metadata = FileSystem::fileMetadata(FileSystem::pathByAppendingComponent(fullPath, childName));
- if (!metadata || metadata.value().isHidden)
+ auto childPath = FileSystem::pathByAppendingComponent(fullPath, childName);
+ auto fileType = fileTypeIgnoringHiddenFiles(childPath);
+ if (!fileType)
continue;
- listedChildren.uncheckedAppend(ListedChild { childName, metadata.value().type });
+ listedChildren.uncheckedAppend(ListedChild { childName, *fileType });
}
return listedChildren;
}
@@ -77,10 +84,10 @@
for (auto& child : listedChildren.returnValue()) {
String virtualPath = parentVirtualPath + "/" + child.filename;
switch (child.type) {
- case FileMetadata::Type::File:
+ case FileSystem::FileType::Regular:
entries.uncheckedAppend(FileSystemFileEntry::create(context, fileSystem, virtualPath));
break;
- case FileMetadata::Type::Directory:
+ case FileSystem::FileType::Directory:
entries.uncheckedAppend(FileSystemDirectoryEntry::create(context, fileSystem, virtualPath));
break;
default:
@@ -166,28 +173,20 @@
return FileSystemFileEntry::create(context, *this, "/" + m_file->name());
}
-static ExceptionOr<String> validatePathIsExpectedType(const String& fullPath, String&& virtualPath, FileMetadata::Type expectedType)
+static ExceptionOr<String> validatePathIsExpectedType(const String& fullPath, String&& virtualPath, FileSystem::FileType expectedType)
{
ASSERT(!isMainThread());
- auto metadata = FileSystem::fileMetadata(fullPath);
- if (!metadata || metadata.value().isHidden)
+ auto fileType = fileTypeIgnoringHiddenFiles(fullPath);
+ if (!fileType)
return Exception { NotFoundError, "Path does not exist"_s };
- if (metadata.value().type != expectedType)
+ if (*fileType != expectedType)
return Exception { TypeMismatchError, "Entry at path does not have expected type" };
return WTFMove(virtualPath);
}
-static Optional<FileMetadata::Type> fileType(const String& fullPath)
-{
- auto metadata = FileSystem::fileMetadata(fullPath);
- if (!metadata || metadata.value().isHidden)
- return WTF::nullopt;
- return metadata.value().type;
-}
-
// https://wicg.github.io/entries-api/#resolve-a-relative-path
static String resolveRelativeVirtualPath(StringView baseVirtualPath, StringView relativeVirtualPath)
{
@@ -271,7 +270,7 @@
ASSERT(virtualPath[0] == '/');
auto fullPath = evaluatePath(virtualPath);
m_workQueue->dispatch([protectedThis = makeRef(*this), context = makeRef(context), fullPath = crossThreadCopy(fullPath), virtualPath = crossThreadCopy(virtualPath), completionCallback = WTFMove(completionCallback)]() mutable {
- auto validatedVirtualPath = validatePathIsExpectedType(fullPath, WTFMove(virtualPath), FileMetadata::Type::Directory);
+ auto validatedVirtualPath = validatePathIsExpectedType(fullPath, WTFMove(virtualPath), FileSystem::FileType::Directory);
callOnMainThread([protectedThis = WTFMove(protectedThis), context = WTFMove(context), validatedVirtualPath = crossThreadCopy(validatedVirtualPath), completionCallback = WTFMove(completionCallback)]() mutable {
if (validatedVirtualPath.hasException())
completionCallback(validatedVirtualPath.releaseException());
@@ -312,7 +311,7 @@
}
m_workQueue->dispatch([protectedThis = makeRef(*this), context = makeRef(context), fullPath = crossThreadCopy(fullPath), resolvedVirtualPath = crossThreadCopy(resolvedVirtualPath), completionCallback = WTFMove(completionCallback)]() mutable {
- auto entryType = fileType(fullPath);
+ auto entryType = fileTypeIgnoringHiddenFiles(fullPath);
callOnMainThread([protectedThis = WTFMove(protectedThis), context = WTFMove(context), resolvedVirtualPath = crossThreadCopy(resolvedVirtualPath), entryType, completionCallback = WTFMove(completionCallback)]() mutable {
if (!entryType) {
completionCallback(Exception { NotFoundError, "Cannot find entry at given path"_s });
@@ -319,10 +318,10 @@
return;
}
switch (entryType.value()) {
- case FileMetadata::Type::Directory:
+ case FileSystem::FileType::Directory:
completionCallback(Ref<FileSystemEntry> { FileSystemDirectoryEntry::create(context, protectedThis.get(), resolvedVirtualPath) });
break;
- case FileMetadata::Type::File:
+ case FileSystem::FileType::Regular:
completionCallback(Ref<FileSystemEntry> { FileSystemFileEntry::create(context, protectedThis.get(), resolvedVirtualPath) });
break;
default:
@@ -338,7 +337,7 @@
auto virtualPath = fileEntry.virtualPath();
auto fullPath = evaluatePath(virtualPath);
m_workQueue->dispatch([fullPath = crossThreadCopy(fullPath), virtualPath = crossThreadCopy(virtualPath), context = makeRef(context), completionCallback = WTFMove(completionCallback)]() mutable {
- auto validatedVirtualPath = validatePathIsExpectedType(fullPath, WTFMove(virtualPath), FileMetadata::Type::File);
+ auto validatedVirtualPath = validatePathIsExpectedType(fullPath, WTFMove(virtualPath), FileSystem::FileType::Regular);
callOnMainThread([fullPath = crossThreadCopy(fullPath), validatedVirtualPath = crossThreadCopy(validatedVirtualPath), context = WTFMove(context), completionCallback = WTFMove(completionCallback)]() mutable {
if (validatedVirtualPath.hasException())
completionCallback(validatedVirtualPath.releaseException());
Modified: trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm (277534 => 277535)
--- trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm 2021-05-15 05:26:41 UTC (rev 277534)
+++ trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm 2021-05-15 05:46:43 UTC (rev 277535)
@@ -712,7 +712,7 @@
return attachment;
}
- bool isDirectory = FileSystem::isDirectoryFollowingSymlinks(path);
+ bool isDirectory = FileSystem::fileTypeFollowingSymlinks(path) == FileSystem::FileType::Directory;
String contentType = typeForAttachmentElement(explicitContentType);
if (contentType.isEmpty()) {
ALLOW_DEPRECATED_DECLARATIONS_BEGIN
Modified: trunk/Source/WebCore/fileapi/File.cpp (277534 => 277535)
--- trunk/Source/WebCore/fileapi/File.cpp 2021-05-15 05:26:41 UTC (rev 277534)
+++ trunk/Source/WebCore/fileapi/File.cpp 2021-05-15 05:46:43 UTC (rev 277535)
@@ -30,7 +30,6 @@
#include "MIMETypeRegistry.h"
#include "ThreadableBlobRegistry.h"
#include <wtf/DateMath.h>
-#include <wtf/FileMetadata.h>
#include <wtf/FileSystem.h>
#include <wtf/IsoMallocInlines.h>
#include <wtf/text/WTFString.h>
@@ -148,7 +147,7 @@
bool File::isDirectory() const
{
if (!m_isDirectory)
- m_isDirectory = FileSystem::isDirectoryFollowingSymlinks(m_path);
+ m_isDirectory = FileSystem::fileTypeFollowingSymlinks(m_path) == FileSystem::FileType::Directory;
return *m_isDirectory;
}
Modified: trunk/Source/WebCore/html/DirectoryFileListCreator.cpp (277534 => 277535)
--- trunk/Source/WebCore/html/DirectoryFileListCreator.cpp 2021-05-15 05:26:41 UTC (rev 277534)
+++ trunk/Source/WebCore/html/DirectoryFileListCreator.cpp 2021-05-15 05:46:43 UTC (rev 277535)
@@ -30,7 +30,6 @@
#include "FileChooser.h"
#include "FileList.h"
#include <wtf/CrossThreadCopier.h>
-#include <wtf/FileMetadata.h>
#include <wtf/FileSystem.h>
namespace WebCore {
@@ -56,17 +55,17 @@
ASSERT(!isMainThread());
for (auto& childName : FileSystem::listDirectory(directory)) {
auto childPath = FileSystem::pathByAppendingComponent(directory, childName);
- auto metadata = FileSystem::fileMetadata(childPath);
- if (!metadata)
+ if (FileSystem::isHiddenFile(childPath))
continue;
- if (metadata.value().isHidden)
+ auto fileType = FileSystem::fileType(childPath);
+ if (!fileType)
continue;
String childRelativePath = relativePath + "/" + childName;
- if (metadata.value().type == FileMetadata::Type::Directory)
+ if (*fileType == FileSystem::FileType::Directory)
appendDirectoryFiles(childPath, childRelativePath, files);
- else if (metadata.value().type == FileMetadata::Type::File)
+ else if (*fileType == FileSystem::FileType::Regular)
files.append(FileInformation { childPath, childRelativePath, { } });
}
}
@@ -76,7 +75,7 @@
ASSERT(!isMainThread());
Vector<FileInformation> files;
for (auto& info : paths) {
- if (FileSystem::isDirectory(info.path))
+ if (FileSystem::fileType(info.path) == FileSystem::FileType::Directory)
appendDirectoryFiles(info.path, FileSystem::pathFileName(info.path), files);
else
files.append(FileInformation { info.path, { }, info.displayName });
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm (277534 => 277535)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm 2021-05-15 05:26:41 UTC (rev 277534)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm 2021-05-15 05:46:43 UTC (rev 277535)
@@ -398,10 +398,11 @@
auto storagePath = FileSystem::pathByAppendingComponent(storageDirectory, "SecureStop.plist");
- if (!FileSystem::fileExists(storageDirectory)) {
+ auto fileType = FileSystem::fileTypeFollowingSymlinks(storageDirectory);
+ if (!fileType) {
if (!FileSystem::makeAllDirectories(storageDirectory))
return;
- } else if (!FileSystem::isDirectoryFollowingSymlinks(storageDirectory)) {
+ } else if (*fileType != FileSystem::FileType::Directory) {
auto tempDirectory = FileSystem::createTemporaryDirectory(@"MediaKeys");
if (!tempDirectory)
return;
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (277534 => 277535)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2021-05-15 05:26:41 UTC (rev 277534)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2021-05-15 05:46:43 UTC (rev 277535)
@@ -337,15 +337,14 @@
if (path.isEmpty())
return nil;
- auto fileExistsAtPath = FileSystem::fileExists(path);
-
- if (fileExistsAtPath && !FileSystem::isDirectoryFollowingSymlinks(path)) {
+ auto fileType = FileSystem::fileTypeFollowingSymlinks(path);
+ if (fileType && *fileType != FileSystem::FileType::Directory) {
// Non-directory file already exists at the path location; bail.
ASSERT_NOT_REACHED();
return nil;
}
- if (!fileExistsAtPath && !FileSystem::makeAllDirectories(path)) {
+ if (!fileType && !FileSystem::makeAllDirectories(path)) {
// Could not create a directory at the specified location; bail.
ASSERT_NOT_REACHED();
return nil;
Modified: trunk/Source/WebCore/platform/network/BlobDataFileReference.cpp (277534 => 277535)
--- trunk/Source/WebCore/platform/network/BlobDataFileReference.cpp 2021-05-15 05:26:41 UTC (rev 277534)
+++ trunk/Source/WebCore/platform/network/BlobDataFileReference.cpp 2021-05-15 05:46:43 UTC (rev 277535)
@@ -27,7 +27,6 @@
#include "BlobDataFileReference.h"
#include "File.h"
-#include <wtf/FileMetadata.h>
#include <wtf/FileSystem.h>
namespace WebCore {
@@ -88,11 +87,11 @@
#endif
// FIXME: Some platforms provide better ways to listen for file system object changes, consider using these.
- auto metadata = FileSystem::fileMetadataFollowingSymlinks(m_path);
- if (!metadata)
+ auto modificationTime = FileSystem::fileModificationTime(m_path);
+ if (!modificationTime)
return;
- m_expectedModificationTime = metadata.value().modificationTime;
+ m_expectedModificationTime = *modificationTime;
#if ENABLE(FILE_REPLACEMENT)
if (m_replacementShouldBeGenerated)
@@ -99,14 +98,12 @@
return;
#endif
- // This is a registered blob with a replacement file. Get the Metadata of the replacement file.
- if (!m_replacementPath.isNull()) {
- metadata = FileSystem::fileMetadataFollowingSymlinks(m_replacementPath);
- if (!metadata)
- return;
- }
+ // This is a registered blob with a replacement file. Get the size of the replacement file.
+ auto fileSize = FileSystem::fileSize(m_replacementPath.isNull() ? m_path : m_replacementPath);
+ if (!fileSize)
+ return;
- m_size = metadata.value().length;
+ m_size = *fileSize;
}
void BlobDataFileReference::prepareForFileAccess()
Modified: trunk/Source/WebCore/platform/network/BlobRegistryImpl.cpp (277534 => 277535)
--- trunk/Source/WebCore/platform/network/BlobRegistryImpl.cpp 2021-05-15 05:26:41 UTC (rev 277534)
+++ trunk/Source/WebCore/platform/network/BlobRegistryImpl.cpp 2021-05-15 05:46:43 UTC (rev 277535)
@@ -40,7 +40,6 @@
#include "ResourceRequest.h"
#include "ResourceResponse.h"
#include <wtf/CompletionHandler.h>
-#include <wtf/FileMetadata.h>
#include <wtf/FileSystem.h>
#include <wtf/MainThread.h>
#include <wtf/NeverDestroyed.h>
Modified: trunk/Source/WebCore/platform/network/FormData.cpp (277534 => 277535)
--- trunk/Source/WebCore/platform/network/FormData.cpp 2021-05-15 05:26:41 UTC (rev 277534)
+++ trunk/Source/WebCore/platform/network/FormData.cpp 2021-05-15 05:46:43 UTC (rev 277535)
@@ -354,7 +354,7 @@
auto* fileData = WTF::get_if<FormDataElement::EncodedFileData>(element.data);
if (!fileData)
continue;
- if (!FileSystem::isDirectoryFollowingSymlinks(fileData->filename))
+ if (FileSystem::fileTypeFollowingSymlinks(fileData->filename) != FileSystem::FileType::Directory)
continue;
if (fileData->fileStart || fileData->fileLength != BlobDataItem::toEndOfFile)
continue;
Modified: trunk/Source/WebCore/platform/network/mac/BlobDataFileReferenceMac.mm (277534 => 277535)
--- trunk/Source/WebCore/platform/network/mac/BlobDataFileReferenceMac.mm 2021-05-15 05:26:41 UTC (rev 277534)
+++ trunk/Source/WebCore/platform/network/mac/BlobDataFileReferenceMac.mm 2021-05-15 05:46:43 UTC (rev 277535)
@@ -28,7 +28,6 @@
#if ENABLE(FILE_REPLACEMENT)
-#import <wtf/FileMetadata.h>
#import <wtf/FileSystem.h>
#import <wtf/text/CString.h>
@@ -47,8 +46,8 @@
m_replacementShouldBeGenerated = false;
if (!m_replacementPath.isNull()) {
- if (auto metadata = FileSystem::fileMetadataFollowingSymlinks(m_replacementPath))
- m_size = metadata.value().length;
+ if (auto fileSize = FileSystem::fileSize(m_replacementPath))
+ m_size = *fileSize;
}
revokeFileAccess();
Modified: trunk/Source/WebKit/ChangeLog (277534 => 277535)
--- trunk/Source/WebKit/ChangeLog 2021-05-15 05:26:41 UTC (rev 277534)
+++ trunk/Source/WebKit/ChangeLog 2021-05-15 05:46:43 UTC (rev 277535)
@@ -1,3 +1,23 @@
+2021-05-14 Chris Dumez <[email protected]>
+
+ Drop FileSystem::fileMetadata() / fileMetadataFollowingSymlinks()
+ https://bugs.webkit.org/show_bug.cgi?id=225820
+
+ Reviewed by Darin Adler.
+
+ Update our code base because of the FileSystem API changes.
+
+ * NetworkProcess/cache/CacheStorageEngine.cpp:
+ (WebKit::CacheStorage::getDirectorySize):
+ (WebKit::CacheStorage::Engine::getDirectories):
+ (WebKit::CacheStorage::Engine::clearAllCachesFromDisk):
+ * NetworkProcess/cache/NetworkCacheFileSystem.cpp:
+ (WebKit::NetworkCache::traverseDirectory):
+ * Shared/mac/AuxiliaryProcessMac.mm:
+ (WebKit::ensureSandboxCacheDirectory):
+ * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+ (WebKit::isInternalInstall):
+
2021-05-14 John Wilander <[email protected]>
_javascript_ can't access a SameSite=Strict cookie after page is loaded after a redirect from a third party site
Modified: trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp (277534 => 277535)
--- trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp 2021-05-15 05:26:41 UTC (rev 277534)
+++ trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp 2021-05-15 05:46:43 UTC (rev 277535)
@@ -207,7 +207,7 @@
paths.append(directoryPath);
while (!paths.isEmpty()) {
auto path = paths.takeFirst();
- if (FileSystem::isDirectory(path)) {
+ if (FileSystem::fileType(path) == FileSystem::FileType::Directory) {
auto fileNames = FileSystem::listDirectory(path);
for (auto& fileName : fileNames) {
// Files in /Blobs directory are hard link.
@@ -613,7 +613,7 @@
Vector<String> folderPaths;
for (auto& fileName : FileSystem::listDirectory(path)) {
auto filePath = FileSystem::pathByAppendingComponent(path, fileName);
- if (FileSystem::isDirectory(filePath))
+ if (FileSystem::fileType(filePath) == FileSystem::FileType::Directory)
folderPaths.append(filePath.isolatedCopy());
}
@@ -701,7 +701,7 @@
LockHolder locker(globalSizeFileLock);
for (auto& fileName : FileSystem::listDirectory(path)) {
auto filePath = FileSystem::pathByAppendingComponent(path, fileName);
- if (FileSystem::isDirectory(filePath))
+ if (FileSystem::fileType(filePath) == FileSystem::FileType::Directory)
FileSystem::deleteNonEmptyDirectory(filePath);
}
RunLoop::main().dispatch(WTFMove(completionHandler));
Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.cpp (277534 => 277535)
--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.cpp 2021-05-15 05:26:41 UTC (rev 277534)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.cpp 2021-05-15 05:46:43 UTC (rev 277535)
@@ -58,7 +58,7 @@
auto entries = FileSystem::listDirectory(path);
for (auto& entry : entries) {
auto entryPath = FileSystem::pathByAppendingComponent(path, entry);
- auto type = FileSystem::isDirectory(entryPath) ? DirectoryEntryType::Directory : DirectoryEntryType::File;
+ auto type = FileSystem::fileType(entryPath) == FileSystem::FileType::Directory ? DirectoryEntryType::Directory : DirectoryEntryType::File;
function(entry, type);
}
}
Modified: trunk/Source/WebKit/Shared/mac/AuxiliaryProcessMac.mm (277534 => 277535)
--- trunk/Source/WebKit/Shared/mac/AuxiliaryProcessMac.mm 2021-05-15 05:26:41 UTC (rev 277534)
+++ trunk/Source/WebKit/Shared/mac/AuxiliaryProcessMac.mm 2021-05-15 05:46:43 UTC (rev 277535)
@@ -331,9 +331,9 @@
static bool ensureSandboxCacheDirectory(const SandboxInfo& info)
{
- if (!FileSystem::isDirectoryFollowingSymlinks(info.parentDirectoryPath)) {
+ if (FileSystem::fileTypeFollowingSymlinks(info.parentDirectoryPath) != FileSystem::FileType::Directory) {
FileSystem::makeAllDirectories(info.parentDirectoryPath);
- if (!FileSystem::isDirectoryFollowingSymlinks(info.parentDirectoryPath)) {
+ if (FileSystem::fileTypeFollowingSymlinks(info.parentDirectoryPath) != FileSystem::FileType::Directory) {
WTFLogAlways("%s: Could not create sandbox directory\n", getprogname());
return false;
}
@@ -363,8 +363,7 @@
if (!rootless_check_datavault_flag(directoryPath.data(), storageClass))
return true;
- bool isDirectory = FileSystem::isDirectory(info.directoryPath);
- if (isDirectory) {
+ if (FileSystem::fileType(info.directoryPath) == FileSystem::FileType::Directory) {
if (!FileSystem::deleteNonEmptyDirectory(info.directoryPath))
return false;
} else {
@@ -379,14 +378,14 @@
return false;
}
#else
- bool hasSandboxDirectory = FileSystem::isDirectoryFollowingSymlinks(info.directoryPath);
+ bool hasSandboxDirectory = FileSystem::fileTypeFollowingSymlinks(info.directoryPath) == FileSystem::FileType::Directory;
if (!hasSandboxDirectory) {
if (FileSystem::makeAllDirectories(info.directoryPath)) {
- ASSERT(FileSystem::isDirectoryFollowingSymlinks(info.directoryPath));
+ ASSERT(FileSystem::fileTypeFollowingSymlinks(info.directoryPath) == FileSystem::FileType::Directory);
hasSandboxDirectory = true;
} else {
// We may have raced with someone else making it. That's ok.
- hasSandboxDirectory = FileSystem::isDirectoryFollowingSymlinks(info.directoryPath);
+ hasSandboxDirectory = FileSystem::fileTypeFollowingSymlinks(info.directoryPath) == FileSystem::FileType::Directory;
}
}
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (277534 => 277535)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm 2021-05-15 05:26:41 UTC (rev 277534)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm 2021-05-15 05:46:43 UTC (rev 277535)
@@ -217,7 +217,7 @@
#if PLATFORM(IOS_FAMILY)
static bool isInternal = MGGetBoolAnswer(kMGQAppleInternalInstallCapability);
#else
- static bool isInternal = FileSystem::isDirectory("/AppleInternal");
+ static bool isInternal = FileSystem::fileType("/AppleInternal") == FileSystem::FileType::Directory;
#endif
return isInternal;
}
Modified: trunk/Tools/ChangeLog (277534 => 277535)
--- trunk/Tools/ChangeLog 2021-05-15 05:26:41 UTC (rev 277534)
+++ trunk/Tools/ChangeLog 2021-05-15 05:46:43 UTC (rev 277535)
@@ -1,3 +1,15 @@
+2021-05-14 Chris Dumez <[email protected]>
+
+ Drop FileSystem::fileMetadata() / fileMetadataFollowingSymlinks()
+ https://bugs.webkit.org/show_bug.cgi?id=225820
+
+ Reviewed by Darin Adler.
+
+ Update the FileSystem API tests accordingly.
+
+ * TestWebKitAPI/Tests/WTF/FileSystem.cpp:
+ (TestWebKitAPI::TEST_F):
+
2021-05-14 Jonathan Bedard <[email protected]>
[WebKitTestRunner] Forward WebContent termination reason
Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp (277534 => 277535)
--- trunk/Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp 2021-05-15 05:26:41 UTC (rev 277534)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp 2021-05-15 05:46:43 UTC (rev 277535)
@@ -28,7 +28,6 @@
#include "Test.h"
#include "Utilities.h"
-#include <wtf/FileMetadata.h>
#include <wtf/FileSystem.h>
#include <wtf/MainThread.h>
#include <wtf/StringExtras.h>
@@ -153,91 +152,77 @@
EXPECT_TRUE(FileSystem::filesHaveSameVolume(bangContainingFilePath(), quoteContainingFilePath()));
}
-TEST_F(FileSystemTest, GetFileMetadataFileSymlink)
+TEST_F(FileSystemTest, fileType)
{
- auto symlinkMetadata = FileSystem::fileMetadata(tempFileSymlinkPath());
- ASSERT_TRUE(symlinkMetadata.hasValue());
- EXPECT_TRUE(symlinkMetadata->type == FileMetadata::Type::SymbolicLink);
- EXPECT_FALSE(symlinkMetadata->isHidden);
- EXPECT_TRUE(static_cast<size_t>(symlinkMetadata->length) == strlen(FileSystemTestData));
+ auto doesNotExistPath = FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "does-not-exist");
+ EXPECT_FALSE(FileSystem::fileType(doesNotExistPath));
- auto targetMetadata = FileSystem::fileMetadataFollowingSymlinks(tempFileSymlinkPath());
- ASSERT_TRUE(targetMetadata.hasValue());
- EXPECT_TRUE(targetMetadata->type == FileMetadata::Type::File);
- EXPECT_FALSE(targetMetadata->isHidden);
- EXPECT_EQ(strlen(FileSystemTestData), static_cast<size_t>(targetMetadata->length));
+ EXPECT_EQ(FileSystem::fileType(tempFilePath()), FileSystem::FileType::Regular);
+ EXPECT_EQ(FileSystem::fileType(tempFileSymlinkPath()), FileSystem::FileType::SymbolicLink);
+ EXPECT_EQ(FileSystem::fileType(tempEmptyFolderSymlinkPath()), FileSystem::FileType::SymbolicLink);
+ EXPECT_EQ(FileSystem::fileType(tempEmptyFolderPath()), FileSystem::FileType::Directory);
- auto actualTargetMetadata = FileSystem::fileMetadata(tempFilePath());
- ASSERT_TRUE(actualTargetMetadata.hasValue());
- EXPECT_TRUE(actualTargetMetadata->type == FileMetadata::Type::File);
- EXPECT_EQ(targetMetadata->modificationTime, actualTargetMetadata->modificationTime);
- EXPECT_EQ(strlen(FileSystemTestData), static_cast<size_t>(targetMetadata->length));
- EXPECT_FALSE(actualTargetMetadata->isHidden);
-}
+ // Symlink to file symlink case.
+ auto symlinkToFileSymlinkPath = FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "symlinkToSymlink");
+ EXPECT_TRUE(FileSystem::createSymbolicLink(tempFileSymlinkPath(), symlinkToFileSymlinkPath));
+ EXPECT_EQ(FileSystem::fileType(symlinkToFileSymlinkPath), FileSystem::FileType::SymbolicLink);
-TEST_F(FileSystemTest, GetFileMetadataSymlinkToFileSymlink)
-{
- // Create a symbolic link pointing the tempFileSymlinkPath().
- auto symlinkToSymlinkPath = FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "symlinkToSymlink");
- EXPECT_TRUE(FileSystem::createSymbolicLink(tempFileSymlinkPath(), symlinkToSymlinkPath));
+ // Symlink to directory symlink case.
+ FileSystem::PlatformFileHandle handle;
+ auto symlinkToDirectorySymlinkPath = FileSystem::openTemporaryFile("tempTestFile-symlink", handle);
+ FileSystem::closeFile(handle);
+ FileSystem::deleteFile(symlinkToDirectorySymlinkPath);
+ EXPECT_TRUE(FileSystem::createSymbolicLink(tempEmptyFolderSymlinkPath(), symlinkToDirectorySymlinkPath));
+ EXPECT_EQ(FileSystem::fileType(symlinkToDirectorySymlinkPath), FileSystem::FileType::SymbolicLink);
- auto symlinkMetadata = FileSystem::fileMetadata(symlinkToSymlinkPath);
- ASSERT_TRUE(symlinkMetadata.hasValue());
- EXPECT_TRUE(symlinkMetadata->type == FileMetadata::Type::SymbolicLink);
- EXPECT_FALSE(symlinkMetadata->isHidden);
+ // Broken file symlink case.
+ EXPECT_TRUE(FileSystem::deleteFile(tempFilePath()));
+ EXPECT_EQ(FileSystem::fileType(tempFileSymlinkPath()), FileSystem::FileType::SymbolicLink);
- auto targetMetadata = FileSystem::fileMetadataFollowingSymlinks(symlinkToSymlinkPath);
- ASSERT_TRUE(targetMetadata.hasValue());
- EXPECT_TRUE(targetMetadata->type == FileMetadata::Type::File);
- EXPECT_FALSE(targetMetadata->isHidden);
- EXPECT_EQ(strlen(FileSystemTestData), static_cast<size_t>(targetMetadata->length));
-
- EXPECT_TRUE(FileSystem::deleteFile(symlinkToSymlinkPath));
+ // Broken directory symlink case.
+ EXPECT_TRUE(FileSystem::deleteNonEmptyDirectory(tempEmptyFolderPath()));
+ EXPECT_EQ(FileSystem::fileType(tempEmptyFolderSymlinkPath()), FileSystem::FileType::SymbolicLink);
}
-TEST_F(FileSystemTest, GetFileMetadataDirectorySymlink)
+TEST_F(FileSystemTest, fileTypeFollowingSymlinks)
{
- auto symlinkMetadata = FileSystem::fileMetadata(tempEmptyFolderSymlinkPath());
- ASSERT_TRUE(symlinkMetadata.hasValue());
- EXPECT_TRUE(symlinkMetadata->type == FileMetadata::Type::SymbolicLink);
- EXPECT_FALSE(symlinkMetadata->isHidden);
+ auto doesNotExistPath = FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "does-not-exist");
+ EXPECT_FALSE(FileSystem::fileTypeFollowingSymlinks(doesNotExistPath));
- auto targetMetadata = FileSystem::fileMetadataFollowingSymlinks(tempEmptyFolderSymlinkPath());
- ASSERT_TRUE(targetMetadata.hasValue());
- EXPECT_TRUE(targetMetadata->type == FileMetadata::Type::Directory);
- EXPECT_FALSE(targetMetadata->isHidden);
+ EXPECT_EQ(FileSystem::fileTypeFollowingSymlinks(tempFilePath()), FileSystem::FileType::Regular);
+ EXPECT_EQ(FileSystem::fileTypeFollowingSymlinks(tempFileSymlinkPath()), FileSystem::FileType::Regular);
+ EXPECT_EQ(FileSystem::fileTypeFollowingSymlinks(tempEmptyFolderSymlinkPath()), FileSystem::FileType::Directory);
+ EXPECT_EQ(FileSystem::fileTypeFollowingSymlinks(tempEmptyFolderPath()), FileSystem::FileType::Directory);
- auto actualTargetMetadata = FileSystem::fileMetadata(tempEmptyFolderPath());
- ASSERT_TRUE(actualTargetMetadata.hasValue());
- EXPECT_TRUE(actualTargetMetadata->type == FileMetadata::Type::Directory);
- EXPECT_EQ(targetMetadata->modificationTime, actualTargetMetadata->modificationTime);
- EXPECT_EQ(targetMetadata->length, actualTargetMetadata->length);
- EXPECT_FALSE(actualTargetMetadata->isHidden);
-}
+ // Symlink to file symlink case.
+ auto symlinkToFileSymlinkPath = FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "symlinkToSymlink");
+ EXPECT_TRUE(FileSystem::createSymbolicLink(tempFileSymlinkPath(), symlinkToFileSymlinkPath));
+ EXPECT_EQ(FileSystem::fileTypeFollowingSymlinks(symlinkToFileSymlinkPath), FileSystem::FileType::Regular);
-TEST_F(FileSystemTest, GetFileMetadataFileDoesNotExist)
-{
- auto doesNotExistPath = FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "does-not-exist");
- auto metadata = FileSystem::fileMetadata(doesNotExistPath);
- EXPECT_TRUE(!metadata);
+ // Symlink to directory symlink case.
+ FileSystem::PlatformFileHandle handle;
+ auto symlinkToDirectorySymlinkPath = FileSystem::openTemporaryFile("tempTestFile-symlink", handle);
+ FileSystem::closeFile(handle);
+ FileSystem::deleteFile(symlinkToDirectorySymlinkPath);
+ EXPECT_TRUE(FileSystem::createSymbolicLink(tempEmptyFolderSymlinkPath(), symlinkToDirectorySymlinkPath));
+ EXPECT_EQ(FileSystem::fileTypeFollowingSymlinks(symlinkToDirectorySymlinkPath), FileSystem::FileType::Directory);
+
+ // Broken file symlink case.
+ EXPECT_TRUE(FileSystem::deleteFile(tempFilePath()));
+ EXPECT_FALSE(FileSystem::fileTypeFollowingSymlinks(tempFileSymlinkPath()));
+
+ // Broken directory symlink case.
+ EXPECT_TRUE(FileSystem::deleteNonEmptyDirectory(tempEmptyFolderPath()));
+ EXPECT_FALSE(FileSystem::fileTypeFollowingSymlinks(tempEmptyFolderSymlinkPath()));
}
#if OS(UNIX)
-TEST_F(FileSystemTest, GetFileMetadataHiddenFile)
+TEST_F(FileSystemTest, isHiddenFile)
{
auto hiddenFilePath = FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), ".hiddenFile");
- auto fileHandle = FileSystem::openFile(hiddenFilePath, FileSystem::FileOpenMode::Write);
- EXPECT_TRUE(FileSystem::isHandleValid(fileHandle));
- FileSystem::writeToFile(fileHandle, FileSystemTestData, strlen(FileSystemTestData));
- FileSystem::closeFile(fileHandle);
+ EXPECT_TRUE(FileSystem::isHiddenFile(hiddenFilePath));
- auto metadata = FileSystem::fileMetadata(hiddenFilePath);
- ASSERT_TRUE(metadata.hasValue());
- EXPECT_TRUE(metadata->type == FileMetadata::Type::File);
- EXPECT_TRUE(metadata->isHidden);
- EXPECT_EQ(strlen(FileSystemTestData), static_cast<size_t>(metadata->length));
-
- EXPECT_TRUE(FileSystem::deleteFile(hiddenFilePath));
+ EXPECT_FALSE(FileSystem::isHiddenFile(tempFilePath()));
}
#endif
@@ -289,9 +274,7 @@
EXPECT_TRUE(FileSystem::createSymbolicLink(doesNotExistPath, symlinkPath));
EXPECT_FALSE(FileSystem::fileExists(doesNotExistPath));
EXPECT_FALSE(FileSystem::fileExists(symlinkPath)); // fileExists() follows symlinks.
- auto symlinkMetadata = FileSystem::fileMetadata(symlinkPath);
- ASSERT_TRUE(!!symlinkMetadata);
- EXPECT_EQ(symlinkMetadata->type, FileMetadata::Type::SymbolicLink);
+ EXPECT_EQ(FileSystem::fileType(symlinkPath), FileSystem::FileType::SymbolicLink);
EXPECT_TRUE(FileSystem::deleteFile(symlinkPath));
}
@@ -301,15 +284,9 @@
auto symlinkPath = FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "symlink"_s);
EXPECT_TRUE(FileSystem::createSymbolicLink(tempFileSymlinkPath(), symlinkPath));
EXPECT_TRUE(FileSystem::fileExists(symlinkPath));
+ EXPECT_EQ(FileSystem::fileType(symlinkPath), FileSystem::FileType::SymbolicLink);
+ EXPECT_EQ(FileSystem::fileTypeFollowingSymlinks(symlinkPath), FileSystem::FileType::Regular);
- auto metadata = FileSystem::fileMetadata(symlinkPath);
- ASSERT_TRUE(!!metadata);
- EXPECT_EQ(metadata->type, FileMetadata::Type::SymbolicLink);
-
- auto targetMetadata = FileSystem::fileMetadataFollowingSymlinks(symlinkPath);
- ASSERT_TRUE(!!targetMetadata);
- EXPECT_EQ(targetMetadata->type, FileMetadata::Type::File);
-
// Break the symlink by deleting the target.
EXPECT_TRUE(FileSystem::deleteFile(tempFilePath()));
@@ -317,20 +294,12 @@
EXPECT_FALSE(FileSystem::fileExists(tempFileSymlinkPath())); // fileExists() follows symlinks.
EXPECT_FALSE(FileSystem::fileExists(symlinkPath)); // fileExists() follows symlinks.
- metadata = FileSystem::fileMetadata(symlinkPath);
- ASSERT_TRUE(!!metadata);
- EXPECT_EQ(metadata->type, FileMetadata::Type::SymbolicLink);
+ EXPECT_EQ(FileSystem::fileType(symlinkPath), FileSystem::FileType::SymbolicLink);
+ EXPECT_EQ(FileSystem::fileType(tempFileSymlinkPath()), FileSystem::FileType::SymbolicLink);
- metadata = FileSystem::fileMetadata(tempFileSymlinkPath());
- ASSERT_TRUE(!!metadata);
- EXPECT_EQ(metadata->type, FileMetadata::Type::SymbolicLink);
+ EXPECT_FALSE(FileSystem::fileTypeFollowingSymlinks(tempFileSymlinkPath()));
+ EXPECT_FALSE(FileSystem::fileTypeFollowingSymlinks(symlinkPath));
- targetMetadata = FileSystem::fileMetadataFollowingSymlinks(tempFileSymlinkPath());
- EXPECT_TRUE(!targetMetadata);
-
- targetMetadata = FileSystem::fileMetadataFollowingSymlinks(symlinkPath);
- EXPECT_TRUE(!targetMetadata);
-
EXPECT_TRUE(FileSystem::deleteFile(symlinkPath));
}
@@ -504,41 +473,16 @@
EXPECT_TRUE(!fileSize);
}
-TEST_F(FileSystemTest, isDirectory)
-{
- 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::isDirectory(tempEmptyFolderSymlinkPath()));
- EXPECT_TRUE(FileSystem::isDirectoryFollowingSymlinks(tempEmptyFolderSymlinkPath()));
-
- 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::isDirectory(tempFileSymlinkPath()));
- EXPECT_FALSE(FileSystem::isDirectoryFollowingSymlinks(tempFileSymlinkPath()));
-
- String fileThatDoesNotExist = FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "does-not-exist"_s);
- EXPECT_FALSE(FileSystem::isDirectory(fileThatDoesNotExist));
- EXPECT_FALSE(FileSystem::isDirectoryFollowingSymlinks(fileThatDoesNotExist));
-}
-
TEST_F(FileSystemTest, makeAllDirectories)
{
EXPECT_TRUE(FileSystem::fileExists(tempEmptyFolderPath()));
- EXPECT_TRUE(FileSystem::isDirectory(tempEmptyFolderPath()));
+ EXPECT_EQ(FileSystem::fileType(tempEmptyFolderPath()), FileSystem::FileType::Directory);
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::isDirectory(subFolderPath));
+ EXPECT_EQ(FileSystem::fileType(subFolderPath), FileSystem::FileType::Directory);
EXPECT_TRUE(FileSystem::deleteNonEmptyDirectory(tempEmptyFolderPath()));
EXPECT_FALSE(FileSystem::fileExists(subFolderPath));
}
@@ -560,9 +504,7 @@
EXPECT_TRUE(FileSystem::createSymbolicLink(tempFilePath(), symlinkPath));
EXPECT_TRUE(FileSystem::fileExists(symlinkPath));
- auto symlinkMetadata = FileSystem::fileMetadata(symlinkPath);
- EXPECT_TRUE(!!symlinkMetadata);
- EXPECT_EQ(symlinkMetadata->type, FileMetadata::Type::SymbolicLink);
+ EXPECT_EQ(FileSystem::fileType(symlinkPath), FileSystem::FileType::SymbolicLink);
EXPECT_TRUE(FileSystem::deleteFile(symlinkPath));
EXPECT_FALSE(FileSystem::fileExists(symlinkPath));
@@ -577,13 +519,8 @@
EXPECT_TRUE(FileSystem::createSymbolicLink(tempEmptyFolderPath(), symlinkPath));
EXPECT_TRUE(FileSystem::fileExists(symlinkPath));
- auto symlinkMetadata = FileSystem::fileMetadata(symlinkPath);
- EXPECT_TRUE(!!symlinkMetadata);
- EXPECT_EQ(symlinkMetadata->type, FileMetadata::Type::SymbolicLink);
+ EXPECT_EQ(FileSystem::fileType(symlinkPath), FileSystem::FileType::SymbolicLink);
- EXPECT_FALSE(FileSystem::isDirectory(symlinkPath));
- EXPECT_TRUE(FileSystem::isDirectoryFollowingSymlinks(symlinkPath));
-
EXPECT_TRUE(FileSystem::deleteFile(symlinkPath));
EXPECT_FALSE(FileSystem::fileExists(symlinkPath));
EXPECT_TRUE(FileSystem::fileExists(tempEmptyFolderPath()));
@@ -617,9 +554,7 @@
ASSERT_TRUE(linkFileSize);
EXPECT_EQ(*linkFileSize, *fileSize);
- auto hardlinkMetadata = FileSystem::fileMetadata(hardlinkPath);
- ASSERT_TRUE(!!hardlinkMetadata);
- EXPECT_EQ(hardlinkMetadata->type, FileMetadata::Type::File);
+ EXPECT_EQ(FileSystem::fileType(hardlinkPath), FileSystem::FileType::Regular);
EXPECT_TRUE(FileSystem::deleteFile(tempFilePath()));
EXPECT_FALSE(FileSystem::fileExists(tempFilePath()));
@@ -647,9 +582,7 @@
ASSERT_TRUE(linkFileSize);
EXPECT_EQ(*linkFileSize, *fileSize);
- auto hardlinkMetadata = FileSystem::fileMetadata(hardlinkPath);
- EXPECT_TRUE(!!hardlinkMetadata);
- EXPECT_EQ(hardlinkMetadata->type, FileMetadata::Type::File);
+ EXPECT_EQ(FileSystem::fileType(hardlinkPath), FileSystem::FileType::Regular);
EXPECT_TRUE(FileSystem::deleteFile(tempFilePath()));
EXPECT_FALSE(FileSystem::fileExists(tempFilePath()));
@@ -731,16 +664,6 @@
});
}
-TEST_F(FileSystemTest, fileModificationTimeViaFileMetadata)
-{
- runGetFileModificationTimeTest(tempFilePath(), [](const String& path) -> Optional<WallTime> {
- auto metadata = FileSystem::fileMetadata(path);
- if (!metadata)
- return WTF::nullopt;
- return metadata->modificationTime;
- });
-}
-
TEST_F(FileSystemTest, updateFileModificationTime)
{
auto modificationTime = FileSystem::fileModificationTime(tempFilePath());