mirror of
https://git.mirrors.martin98.com/https://github.com/gulrak/filesystem
synced 2025-06-04 11:13:58 +08:00
parent
c4b507e9d8
commit
91e71f7f54
@ -32,6 +32,8 @@ endif()
|
||||
if(CMAKE_CXX_STANDARD LESS 11)
|
||||
message(FATAL_ERROR "CMAKE_CXX_STANDARD is less than 11, ghc::filesystem only works with C++11 and above.")
|
||||
endif()
|
||||
message(STATUS "System name: ${CMAKE_SYSTEM_NAME}")
|
||||
message(STATUS "Compiler ID: ${CMAKE_CXX_COMPILER_ID}")
|
||||
message(STATUS "CMAKE_CXX_COMPILE_FEATURES: ${CMAKE_CXX_COMPILE_FEATURES}")
|
||||
|
||||
add_library(ghc_filesystem INTERFACE)
|
||||
|
@ -1,6 +1,5 @@
|
||||
macro(AddExecutableWithStdFS targetName)
|
||||
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND (CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 7.0 OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0))
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND (CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 7.0 OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0))
|
||||
if(APPLE)
|
||||
include_directories(/usr/local/opt/llvm/include)
|
||||
link_directories(/usr/local/opt/llvm/lib)
|
||||
@ -20,6 +19,9 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND (CMAKE_CXX_COMPILER_VERSION
|
||||
target_link_libraries(${targetName} -stdlib=libc++)
|
||||
endif()
|
||||
endif()
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "(SunOS|Solaris)")
|
||||
target_link_libraries(filesystem_test xnet)
|
||||
endif()
|
||||
target_compile_definitions(${targetName} PRIVATE USE_STD_FS)
|
||||
endif()
|
||||
|
||||
@ -29,6 +31,9 @@ if (CMAKE_COMPILER_IS_GNUCXX AND (CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 8.0 O
|
||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
|
||||
target_link_libraries(${targetName} -lstdc++fs)
|
||||
endif()
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "(SunOS|Solaris)")
|
||||
target_link_libraries(${targetName} xnet)
|
||||
endif()
|
||||
target_compile_options(${targetName} PRIVATE $<$<BOOL:${CYGWIN}>:-Wa,-mbig-obj>)
|
||||
target_compile_definitions(${targetName} PRIVATE USE_STD_FS)
|
||||
endif()
|
||||
@ -47,6 +52,9 @@ macro(AddTestExecutableWithStdCpp cppStd)
|
||||
add_executable(filesystem_test_cpp${cppStd} ${ARGN})
|
||||
set_property(TARGET filesystem_test_cpp${cppStd} PROPERTY CXX_STANDARD ${cppStd})
|
||||
target_link_libraries(filesystem_test_cpp${cppStd} ghc_filesystem)
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "(SunOS|Solaris)")
|
||||
target_link_libraries(filesystem_test_cpp${cppStd} xnet)
|
||||
endif()
|
||||
target_compile_options(filesystem_test_cpp${cppStd} PRIVATE
|
||||
$<$<BOOL:${EMSCRIPTEN}>:-s DISABLE_EXCEPTION_CATCHING=0>
|
||||
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Werror -Wno-error=deprecated-declarations>
|
||||
|
@ -1316,22 +1316,38 @@ template <typename T>
|
||||
GHC_INLINE file_type file_type_from_dirent_impl(const T& t, std::true_type)
|
||||
{
|
||||
switch (t.d_type) {
|
||||
#ifdef DT_BLK
|
||||
case DT_BLK:
|
||||
return file_type::block;
|
||||
#endif
|
||||
#ifdef DT_CHR
|
||||
case DT_CHR:
|
||||
return file_type::character;
|
||||
#endif
|
||||
#ifdef DT_DIR
|
||||
case DT_DIR:
|
||||
return file_type::directory;
|
||||
#endif
|
||||
#ifdef DT_FIFO
|
||||
case DT_FIFO:
|
||||
return file_type::fifo;
|
||||
#endif
|
||||
#ifdef DT_LNK
|
||||
case DT_LNK:
|
||||
return file_type::symlink;
|
||||
#endif
|
||||
#ifdef DT_REG
|
||||
case DT_REG:
|
||||
return file_type::regular;
|
||||
#endif
|
||||
#ifdef DT_SOCK
|
||||
case DT_SOCK:
|
||||
return file_type::socket;
|
||||
#endif
|
||||
#ifdef DT_UNKNOWN
|
||||
case DT_UNKNOWN:
|
||||
return file_type::none;
|
||||
#endif
|
||||
default:
|
||||
return file_type::unknown;
|
||||
}
|
||||
@ -4624,7 +4640,7 @@ GHC_INLINE void last_write_time(const path& p, file_time_type new_time, std::err
|
||||
#if defined(__ANDROID_API__) && __ANDROID_API__ < 12
|
||||
if (syscall(__NR_utimensat, AT_FDCWD, p.c_str(), times, AT_SYMLINK_NOFOLLOW) != 0) {
|
||||
#else
|
||||
if (::utimensat(AT_FDCWD, p.c_str(), times, AT_SYMLINK_NOFOLLOW) != 0) {
|
||||
if (::utimensat((int)AT_FDCWD, p.c_str(), times, AT_SYMLINK_NOFOLLOW) != 0) {
|
||||
#endif
|
||||
ec = detail::make_system_error();
|
||||
}
|
||||
|
@ -13,6 +13,9 @@ if(GHC_COVERAGE)
|
||||
target_compile_options(filesystem_test PUBLIC --coverage)
|
||||
endif()
|
||||
target_link_libraries(filesystem_test PUBLIC ghc_filesystem --coverage)
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "(SunOS|Solaris)")
|
||||
target_link_libraries(filesystem_test PUBLIC xnet)
|
||||
endif()
|
||||
if("cxx_std_17" IN_LIST GHC_FILESYSTEM_TEST_COMPILE_FEATURES)
|
||||
AddTestExecutableWithStdCpp(17 filesystem_test.cpp catch.hpp)
|
||||
endif()
|
||||
@ -23,6 +26,9 @@ else()
|
||||
message("Generating test runner for normal test...")
|
||||
add_executable(filesystem_test filesystem_test.cpp catch.hpp)
|
||||
target_link_libraries(filesystem_test ghc_filesystem)
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "(SunOS|Solaris)")
|
||||
target_link_libraries(filesystem_test xnet)
|
||||
endif()
|
||||
target_compile_options(filesystem_test PRIVATE
|
||||
$<$<BOOL:${EMSCRIPTEN}>:-s DISABLE_EXCEPTION_CATCHING=0>
|
||||
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Werror>
|
||||
|
@ -2163,6 +2163,7 @@ public:
|
||||
|
||||
fs::path character_path() const
|
||||
{
|
||||
#ifndef GHC_OS_SOLARIS
|
||||
std::error_code ec;
|
||||
if (fs::exists("/dev/null", ec)) {
|
||||
return "/dev/null";
|
||||
@ -2170,6 +2171,7 @@ public:
|
||||
else if (fs::exists("NUL", ec)) {
|
||||
return "NUL";
|
||||
}
|
||||
#endif
|
||||
return fs::path();
|
||||
}
|
||||
fs::path temp_path() const { return _t.path(); }
|
||||
|
Loading…
x
Reference in New Issue
Block a user