haikuwebkit/Source/WTF/wtf/StdFilesystem.h

38 lines
1.6 KiB
C
Raw Permalink Normal View History

Start leveraging std::filesystem in WTF::FileSystem https://bugs.webkit.org/show_bug.cgi?id=225255 Reviewed by Sam Weinig. Source/JavaScriptCore: Unexport some symbols to fix build. * Configurations/JavaScriptCore.xcconfig: Source/WTF: Start leveraging std::filesystem in WTF::FileSystem to reduce the amount of platform-specific code. * WTF.xcodeproj/project.pbxproj: * wtf/FileSystem.cpp: (WTF::FileSystemImpl::fileExists): (WTF::FileSystemImpl::deleteFile): (WTF::FileSystemImpl::deleteEmptyDirectory): (WTF::FileSystemImpl::moveFile): (WTF::FileSystemImpl::getFileSize): (WTF::FileSystemImpl::fileIsDirectory): (WTF::FileSystemImpl::makeAllDirectories): (WTF::FileSystemImpl::getVolumeFreeSpace): (WTF::FileSystemImpl::createSymbolicLink): (WTF::FileSystemImpl::hardLink): (WTF::FileSystemImpl::hardLinkOrCopyFile): (WTF::FileSystemImpl::deleteNonEmptyDirectory): * wtf/FileSystem.h: * wtf/cocoa/FileSystemCocoa.mm: (WTF::FileSystemImpl::createTemporaryDirectory): * wtf/glib/FileSystemGlib.cpp: * wtf/posix/FileSystemPOSIX.cpp: * wtf/win/FileSystemWin.cpp: * wtf/PlatformJSCOnly.cmake: GNU implementation prior to 9.1 requires linking with -lstdc++fs and LLVM implementation prior to LLVM 9.0 requires linking with -lc++fs. * wtf/StdFilesystem.cpp: Removed. * wtf/StdFilesystem.h: Drop our own copy of std::filesystem as all the operating system we support now have support for this. Tools: Add API test coverage for the FileSystem API that was modified. * TestWebKitAPI/Tests/WTF/FileSystem.cpp: (TestWebKitAPI::FileSystemTest::tempFilePath const): (TestWebKitAPI::FileSystemTest::tempFileSymlinkPath const): (TestWebKitAPI::FileSystemTest::tempEmptyFolderPath const): (TestWebKitAPI::FileSystemTest::tempEmptyFolderSymlinkPath const): (TestWebKitAPI::FileSystemTest::tempEmptyFilePath const): (TestWebKitAPI::FileSystemTest::spaceContainingFilePath const): (TestWebKitAPI::FileSystemTest::bangContainingFilePath const): (TestWebKitAPI::FileSystemTest::quoteContainingFilePath const): (TestWebKitAPI::TEST_F): Canonical link: https://commits.webkit.org/237225@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276879 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-02 02:36:14 +00:00
/*
* Copyright (C) 2021 Apple 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:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE INC. 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.
*/
[PlayStation] Implement FileSystem without std::filesystem https://bugs.webkit.org/show_bug.cgi?id=226197 Reviewed by Chris Dumez. .: Expose the result of the check for <filesystem> support as HAVE_STD_FILESYSTEM. * Source/cmake/OptionsCommon.cmake: Source/WTF: The PlayStation 4 doesn't have support in its SDK for std::filesystem so backport the functions jettisoned from FileSystemPOSIX and add them to a FileSystemPlayStation.cpp. The ordering matches the contents of FileSystem.cpp. Most of the functions ported to std::filesystem were just moved over as is from the commit prior to r276879. Minor changes to the function signatures made when required. The fileTypePotentiallyFollowingSymLinks function was created from the previous behavior of fileMetadataUsingFunction and toFileMetataType. The hardLinkCount was created from looking at the behavior hardLinkCount replaced in r277446. * wtf/FileSystem.cpp: * wtf/PlatformHave.h: * wtf/PlatformPlayStation.cmake: * wtf/StdFilesystem.h: * wtf/playstation/FileSystemPlayStation.cpp: Added. (WTF::FileSystemImpl::fileTypePotentiallyFollowingSymLinks): (WTF::FileSystemImpl::fileExists): (WTF::FileSystemImpl::deleteFile): (WTF::FileSystemImpl::deleteEmptyDirectory): (WTF::FileSystemImpl::moveFile): (WTF::FileSystemImpl::fileSize): (WTF::FileSystemImpl::makeAllDirectories): (WTF::FileSystemImpl::volumeFreeSpace): (WTF::FileSystemImpl::createSymbolicLink): (WTF::FileSystemImpl::hardLink): (WTF::FileSystemImpl::hardLinkOrCopyFile): (WTF::FileSystemImpl::hardLinkCount): (WTF::FileSystemImpl::deleteNonEmptyDirectory): (WTF::FileSystemImpl::fileModificationTime): (WTF::FileSystemImpl::updateFileModificationTime): (WTF::FileSystemImpl::isHiddenFile): (WTF::FileSystemImpl::fileType): (WTF::FileSystemImpl::fileTypeFollowingSymlinks): (WTF::FileSystemImpl::pathFileName): (WTF::FileSystemImpl::parentPath): (WTF::FileSystemImpl::realPath): (WTF::FileSystemImpl::pathByAppendingComponent): (WTF::FileSystemImpl::pathByAppendingComponents): (WTF::FileSystemImpl::listDirectory): Canonical link: https://commits.webkit.org/238124@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278027 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-25 17:34:01 +00:00
#pragma once
#if HAVE(STD_FILESYSTEM)
#include <filesystem>
#elif HAVE(STD_EXPERIMENTAL_FILESYSTEM)
#include <experimental/filesystem>
namespace std {
namespace filesystem = std::experimental::filesystem;
}
#else
Start leveraging std::filesystem in WTF::FileSystem https://bugs.webkit.org/show_bug.cgi?id=225255 Reviewed by Sam Weinig. Source/JavaScriptCore: Unexport some symbols to fix build. * Configurations/JavaScriptCore.xcconfig: Source/WTF: Start leveraging std::filesystem in WTF::FileSystem to reduce the amount of platform-specific code. * WTF.xcodeproj/project.pbxproj: * wtf/FileSystem.cpp: (WTF::FileSystemImpl::fileExists): (WTF::FileSystemImpl::deleteFile): (WTF::FileSystemImpl::deleteEmptyDirectory): (WTF::FileSystemImpl::moveFile): (WTF::FileSystemImpl::getFileSize): (WTF::FileSystemImpl::fileIsDirectory): (WTF::FileSystemImpl::makeAllDirectories): (WTF::FileSystemImpl::getVolumeFreeSpace): (WTF::FileSystemImpl::createSymbolicLink): (WTF::FileSystemImpl::hardLink): (WTF::FileSystemImpl::hardLinkOrCopyFile): (WTF::FileSystemImpl::deleteNonEmptyDirectory): * wtf/FileSystem.h: * wtf/cocoa/FileSystemCocoa.mm: (WTF::FileSystemImpl::createTemporaryDirectory): * wtf/glib/FileSystemGlib.cpp: * wtf/posix/FileSystemPOSIX.cpp: * wtf/win/FileSystemWin.cpp: * wtf/PlatformJSCOnly.cmake: GNU implementation prior to 9.1 requires linking with -lstdc++fs and LLVM implementation prior to LLVM 9.0 requires linking with -lc++fs. * wtf/StdFilesystem.cpp: Removed. * wtf/StdFilesystem.h: Drop our own copy of std::filesystem as all the operating system we support now have support for this. Tools: Add API test coverage for the FileSystem API that was modified. * TestWebKitAPI/Tests/WTF/FileSystem.cpp: (TestWebKitAPI::FileSystemTest::tempFilePath const): (TestWebKitAPI::FileSystemTest::tempFileSymlinkPath const): (TestWebKitAPI::FileSystemTest::tempEmptyFolderPath const): (TestWebKitAPI::FileSystemTest::tempEmptyFolderSymlinkPath const): (TestWebKitAPI::FileSystemTest::tempEmptyFilePath const): (TestWebKitAPI::FileSystemTest::spaceContainingFilePath const): (TestWebKitAPI::FileSystemTest::bangContainingFilePath const): (TestWebKitAPI::FileSystemTest::quoteContainingFilePath const): (TestWebKitAPI::TEST_F): Canonical link: https://commits.webkit.org/237225@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276879 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-02 02:36:14 +00:00
#error "Missing support for std::filesystem or std::experimental::filesystem"
#endif