mirror of
https://git.mirrors.martin98.com/https://github.com/gulrak/filesystem
synced 2025-07-25 10:04:29 +08:00
refs #90, made wchar_t/wstring default on Windows
This commit is contained in:
parent
9e3d42fd72
commit
fdf5bb0179
@ -225,10 +225,13 @@
|
|||||||
// LWG #2937 enforces that fs::equivalent emits an error, if !fs::exists(p1)||!exists(p2)
|
// LWG #2937 enforces that fs::equivalent emits an error, if !fs::exists(p1)||!exists(p2)
|
||||||
#define LWG_2937_BEHAVIOUR
|
#define LWG_2937_BEHAVIOUR
|
||||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
// UTF8-Everywhere is the original behaviour of ghc::filesystem. With this define you can
|
// UTF8-Everywhere is the original behaviour of ghc::filesystem. But since v1.5 the windows
|
||||||
// enable the more standard conforming implementation option that uses wstring on Windows
|
// version defaults to std::wstring storage backend. Still all std::string will be interpreted
|
||||||
// as ghc::filesystem::string_type.
|
// as UTF-8 encoded. With this define you can enfoce the old behavior on Windows, using
|
||||||
// #define GHC_WIN_WSTRING_STRING_TYPE
|
// std::string as backend and for fs::path::native() and char for fs::path::c_str(). This
|
||||||
|
// needs more conversions so it is (an was before v1.5) slower, bot might help keeping source
|
||||||
|
// homogenous in a multi platform project.
|
||||||
|
// #define GHC_WIN_DISABLE_WSTRING_STORAGE_TYPE
|
||||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
// Raise errors/exceptions when invalid unicode codepoints or UTF-8 sequences are found,
|
// Raise errors/exceptions when invalid unicode codepoints or UTF-8 sequences are found,
|
||||||
// instead of replacing them with the unicode replacement character (U+FFFD).
|
// instead of replacing them with the unicode replacement character (U+FFFD).
|
||||||
@ -290,7 +293,7 @@ bool has_executable_extension(const path& p);
|
|||||||
|
|
||||||
// 30.10.8 class path
|
// 30.10.8 class path
|
||||||
class GHC_FS_API_CLASS path
|
class GHC_FS_API_CLASS path
|
||||||
#if defined(GHC_OS_WINDOWS) && defined(GHC_WIN_WSTRING_STRING_TYPE)
|
#if defined(GHC_OS_WINDOWS) && !defined(GHC_WIN_DISABLE_WSTRING_STORAGE_TYPE)
|
||||||
#define GHC_USE_WCHAR_T
|
#define GHC_USE_WCHAR_T
|
||||||
#define GHC_NATIVEWP(p) p.c_str()
|
#define GHC_NATIVEWP(p) p.c_str()
|
||||||
#define GHC_PLATFORM_LITERAL(str) L##str
|
#define GHC_PLATFORM_LITERAL(str) L##str
|
||||||
|
@ -43,7 +43,7 @@ using fstream = std::fstream;
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#ifndef GHC_USE_STD_FS
|
#ifndef GHC_USE_STD_FS
|
||||||
#define GHC_WIN_WSTRING_STRING_TYPE
|
//#define GHC_WIN_DISABLE_WSTRING_STORAGE_TYPE
|
||||||
#include <ghc/filesystem.hpp>
|
#include <ghc/filesystem.hpp>
|
||||||
namespace fs {
|
namespace fs {
|
||||||
using namespace ghc::filesystem;
|
using namespace ghc::filesystem;
|
||||||
|
@ -46,7 +46,7 @@ using fstream = std::fstream;
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#ifndef GHC_USE_STD_FS
|
#ifndef GHC_USE_STD_FS
|
||||||
#define GHC_WIN_WSTRING_STRING_TYPE
|
//#define GHC_WIN_DISABLE_WSTRING_STORAGE_TYPE
|
||||||
#define GHC_FILESYSTEM_FWD
|
#define GHC_FILESYSTEM_FWD
|
||||||
#include <ghc/filesystem.hpp>
|
#include <ghc/filesystem.hpp>
|
||||||
namespace fs {
|
namespace fs {
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#ifndef GHC_USE_STD_FS
|
#ifndef GHC_USE_STD_FS
|
||||||
#define GHC_WIN_WSTRING_STRING_TYPE
|
//#define GHC_WIN_DISABLE_WSTRING_STORAGE_TYPE
|
||||||
#define GHC_FILESYSTEM_IMPLEMENTATION
|
#define GHC_FILESYSTEM_IMPLEMENTATION
|
||||||
#include <ghc/filesystem.hpp>
|
#include <ghc/filesystem.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
@ -31,18 +31,18 @@ else()
|
|||||||
ParseAndAddCatchTests(filesystem_test)
|
ParseAndAddCatchTests(filesystem_test)
|
||||||
AddExecutableWithStdFS(std_filesystem_test filesystem_test.cpp catch.hpp)
|
AddExecutableWithStdFS(std_filesystem_test filesystem_test.cpp catch.hpp)
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
add_executable(filesystem_test_wchar filesystem_test.cpp catch.hpp)
|
add_executable(filesystem_test_char filesystem_test.cpp catch.hpp)
|
||||||
target_link_libraries(filesystem_test_wchar ghc_filesystem)
|
target_link_libraries(filesystem_test_char ghc_filesystem)
|
||||||
target_compile_options(filesystem_test_wchar PRIVATE
|
target_compile_options(filesystem_test_char PRIVATE
|
||||||
$<$<CXX_COMPILER_ID:Clang>:-Wall -Wextra -Werror>
|
$<$<CXX_COMPILER_ID:Clang>:-Wall -Wextra -Werror>
|
||||||
$<$<CXX_COMPILER_ID:GNU>:-Wall -Werror>
|
$<$<CXX_COMPILER_ID:GNU>:-Wall -Werror>
|
||||||
$<$<CXX_COMPILER_ID:MSVC>:/WX>)
|
$<$<CXX_COMPILER_ID:MSVC>:/WX>)
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
|
if(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
|
||||||
target_compile_definitions(filesystem_test_wchar PRIVATE _CRT_SECURE_NO_WARNINGS GHC_WIN_WSTRING_STRING_TYPE)
|
target_compile_definitions(filesystem_test_char PRIVATE _CRT_SECURE_NO_WARNINGS GHC_WIN_DISABLE_WSTRING_STORAGE_TYPE)
|
||||||
else()
|
else()
|
||||||
target_compile_definitions(filesystem_test_wchar PRIVATE GHC_WIN_WSTRING_STRING_TYPE)
|
target_compile_definitions(filesystem_test_char PRIVATE GHC_WIN_DISABLE_WSTRING_STORAGE_TYPE)
|
||||||
endif()
|
endif()
|
||||||
ParseAndAddCatchTests(filesystem_test_wchar)
|
ParseAndAddCatchTests(filesystem_test_char)
|
||||||
endif()
|
endif()
|
||||||
if("cxx_std_17" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
|
if("cxx_std_17" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
|
||||||
AddTestExecutableWithStdCpp(17 filesystem_test.cpp catch.hpp)
|
AddTestExecutableWithStdCpp(17 filesystem_test.cpp catch.hpp)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user