mirror of
https://git.mirrors.martin98.com/https://github.com/gulrak/filesystem
synced 2025-07-21 23:54:26 +08:00
Fix in canonical root path handling.
This commit is contained in:
parent
1cd346d23e
commit
f96b65562d
@ -1258,8 +1258,7 @@ namespace detail {
|
|||||||
|
|
||||||
GHC_INLINE bool startsWith(const std::string& what, const std::string& with)
|
GHC_INLINE bool startsWith(const std::string& what, const std::string& with)
|
||||||
{
|
{
|
||||||
return with.length() <= what.length()
|
return with.length() <= what.length() && equal(with.begin(), with.end(), what.begin());
|
||||||
&& equal(with.begin(), with.end(), what.begin());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GHC_INLINE void postprocess_path_with_format(path::string_type& p, path::format fmt)
|
GHC_INLINE void postprocess_path_with_format(path::string_type& p, path::format fmt)
|
||||||
@ -2856,7 +2855,10 @@ GHC_INLINE path canonical(const path& p, std::error_code& ec)
|
|||||||
result = result.parent_path();
|
result = result.parent_path();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
else if ((result/pe).string().length() <= root.string().length()) {
|
||||||
|
result /= pe;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
auto sls = symlink_status(result / pe, ec);
|
auto sls = symlink_status(result / pe, ec);
|
||||||
if (ec) {
|
if (ec) {
|
||||||
return path();
|
return path();
|
||||||
@ -3708,8 +3710,7 @@ GHC_INLINE void permissions(const path& p, perms prms, perm_options opts, std::e
|
|||||||
#ifdef GHC_OS_WINDOWS
|
#ifdef GHC_OS_WINDOWS
|
||||||
# ifdef __GNUC__
|
# ifdef __GNUC__
|
||||||
auto oldAttr = GetFileAttributesW(p.wstring().c_str());
|
auto oldAttr = GetFileAttributesW(p.wstring().c_str());
|
||||||
if (oldAttr != INVALID_FILE_ATTRIBUTES)
|
if (oldAttr != INVALID_FILE_ATTRIBUTES) {
|
||||||
{
|
|
||||||
DWORD newAttr = ((prms & perms::owner_write) == perms::owner_write) ? oldAttr & ~FILE_ATTRIBUTE_READONLY : oldAttr | FILE_ATTRIBUTE_READONLY;
|
DWORD newAttr = ((prms & perms::owner_write) == perms::owner_write) ? oldAttr & ~FILE_ATTRIBUTE_READONLY : oldAttr | FILE_ATTRIBUTE_READONLY;
|
||||||
if (oldAttr == newAttr || SetFileAttributesW(p.wstring().c_str(), newAttr)) {
|
if (oldAttr == newAttr || SetFileAttributesW(p.wstring().c_str(), newAttr)) {
|
||||||
return;
|
return;
|
||||||
|
@ -180,10 +180,8 @@ inline bool isWow64Proc()
|
|||||||
typedef BOOL(WINAPI * IsWow64Process_t)(HANDLE, PBOOL);
|
typedef BOOL(WINAPI * IsWow64Process_t)(HANDLE, PBOOL);
|
||||||
BOOL bIsWow64 = FALSE;
|
BOOL bIsWow64 = FALSE;
|
||||||
auto fnIsWow64Process = (IsWow64Process_t)GetProcAddress(GetModuleHandle(TEXT("kernel32")), "IsWow64Process");
|
auto fnIsWow64Process = (IsWow64Process_t)GetProcAddress(GetModuleHandle(TEXT("kernel32")), "IsWow64Process");
|
||||||
if( NULL != fnIsWow64Process )
|
if (NULL != fnIsWow64Process) {
|
||||||
{
|
if (!fnIsWow64Process(GetCurrentProcess(), &bIsWow64)) {
|
||||||
if (!fnIsWow64Process(GetCurrentProcess(), &bIsWow64))
|
|
||||||
{
|
|
||||||
bIsWow64 = FALSE;
|
bIsWow64 = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -192,7 +190,7 @@ inline bool isWow64Proc()
|
|||||||
|
|
||||||
static bool is_symlink_creation_supported()
|
static bool is_symlink_creation_supported()
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = true;
|
||||||
HKEY key;
|
HKEY key;
|
||||||
REGSAM flags = KEY_READ;
|
REGSAM flags = KEY_READ;
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
@ -2314,7 +2312,7 @@ TEST_CASE("Windows: Long filename support", "[filesystem][path][fs.path.win.long
|
|||||||
CHECK(fs::exists(dir));
|
CHECK(fs::exists(dir));
|
||||||
generateFile(dir / "f0");
|
generateFile(dir / "f0");
|
||||||
CHECK(fs::exists(dir / "f0"));
|
CHECK(fs::exists(dir / "f0"));
|
||||||
std::string native = dir.native();
|
std::string native = dir.u8string();
|
||||||
if (native.substr(0, 4) == "\\\\?\\") {
|
if (native.substr(0, 4) == "\\\\?\\") {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user