Drop FileSystem::fileMetadata() / fileMetadataFollowingSymlinks(). Those don't match very closely the std::filesystem API 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).
Created attachment 428652 [details] Patch
Created attachment 428660 [details] Patch
Created attachment 428685 [details] Patch
Comment on attachment 428685 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=428685&action=review > Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm:716 > + auto fileType = FileSystem::fileTypeFollowingSymlinks(path); > + bool isDirectory = fileType && *fileType == FileSystem::FileType::Directory; The == operator in Optional should make this easier to write. Like this: bool isDirectory = FileSystem::fileTypeFollowingSymlinks(path) == FileSystem::FileType::Directory; > Source/WebCore/fileapi/File.cpp:151 > + auto fileType = FileSystem::fileTypeFollowingSymlinks(m_path); > + m_isDirectory = fileType && *fileType == FileSystem::FileType::Directory; m_isDirectory = FileSystem::fileTypeFollowingSymlinks(m_path) == FileSystem::FileType::Directory; > Source/WebCore/html/DirectoryFileListCreator.cpp:79 > + auto fileType = FileSystem::fileType(info.path); > + if (fileType && *fileType == FileSystem::FileType::Directory) if (FileSystem::fileType(info.path) == FileSystem::FileType::Directory) > Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.cpp:62 > + auto fileType = FileSystem::fileType(entryPath); > + auto type = (fileType && *fileType == FileSystem::FileType::Directory) ? DirectoryEntryType::Directory : DirectoryEntryType::File; auto type = FileSystem::fileType(entryPath) == FileSystem::FileType::Directory ? DirectoryEntryType::Directory : DirectoryEntryType::File; > Source/WebKit/Shared/mac/AuxiliaryProcessMac.mm:368 > + auto directoryType = FileSystem::fileType(info.directoryPath); > + if (directoryType && *directoryType == FileSystem::FileType::Directory) { if (FileSystem::fileType(info.directoryPath) == FileSystem::FileType::Directory) { > Source/WebKit/Shared/mac/AuxiliaryProcessMac.mm:392 > + auto fileType = FileSystem::fileTypeFollowingSymlinks(info.directoryPath); > + hasSandboxDirectory = fileType && *fileType == FileSystem::FileType::Directory; hasSandboxDirectory = FileSystem::fileTypeFollowingSymlinks(info.directoryPath) == FileSystem::FileType::Directory;
(In reply to Darin Adler from comment #4) > Comment on attachment 428685 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=428685&action=review > > > Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm:716 > > + auto fileType = FileSystem::fileTypeFollowingSymlinks(path); > > + bool isDirectory = fileType && *fileType == FileSystem::FileType::Directory; > > The == operator in Optional should make this easier to write. Like this: > > bool isDirectory = FileSystem::fileTypeFollowingSymlinks(path) == > FileSystem::FileType::Directory; > > > Source/WebCore/fileapi/File.cpp:151 > > + auto fileType = FileSystem::fileTypeFollowingSymlinks(m_path); > > + m_isDirectory = fileType && *fileType == FileSystem::FileType::Directory; > > m_isDirectory = FileSystem::fileTypeFollowingSymlinks(m_path) == > FileSystem::FileType::Directory; > > > Source/WebCore/html/DirectoryFileListCreator.cpp:79 > > + auto fileType = FileSystem::fileType(info.path); > > + if (fileType && *fileType == FileSystem::FileType::Directory) > > if (FileSystem::fileType(info.path) == FileSystem::FileType::Directory) > > > Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.cpp:62 > > + auto fileType = FileSystem::fileType(entryPath); > > + auto type = (fileType && *fileType == FileSystem::FileType::Directory) ? DirectoryEntryType::Directory : DirectoryEntryType::File; > > auto type = FileSystem::fileType(entryPath) == > FileSystem::FileType::Directory ? DirectoryEntryType::Directory : > DirectoryEntryType::File; > > > Source/WebKit/Shared/mac/AuxiliaryProcessMac.mm:368 > > + auto directoryType = FileSystem::fileType(info.directoryPath); > > + if (directoryType && *directoryType == FileSystem::FileType::Directory) { > > if (FileSystem::fileType(info.directoryPath) == > FileSystem::FileType::Directory) { > > > Source/WebKit/Shared/mac/AuxiliaryProcessMac.mm:392 > > + auto fileType = FileSystem::fileTypeFollowingSymlinks(info.directoryPath); > > + hasSandboxDirectory = fileType && *fileType == FileSystem::FileType::Directory; > > hasSandboxDirectory = > FileSystem::fileTypeFollowingSymlinks(info.directoryPath) == > FileSystem::FileType::Directory; Oh that’s great. I did not realize I could do that. This should make things a lot nicer.
Created attachment 428711 [details] Patch
Committed r277535 (237763@main): <https://commits.webkit.org/237763@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 428711 [details].
<rdar://problem/78047472>