Fix in canonical root path handling.

This commit is contained in:
Steffen Schümann 2019-04-27 09:42:20 +02:00
parent 1cd346d23e
commit f96b65562d
2 changed files with 27 additions and 28 deletions

View File

@ -1258,8 +1258,7 @@ namespace detail {
GHC_INLINE bool startsWith(const std::string& what, const std::string& with)
{
return with.length() <= what.length()
&& equal(with.begin(), with.end(), what.begin());
return with.length() <= what.length() && equal(with.begin(), with.end(), what.begin());
}
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();
continue;
}
else if ((result/pe).string().length() <= root.string().length()) {
result /= pe;
continue;
}
auto sls = symlink_status(result / pe, ec);
if (ec) {
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 __GNUC__
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;
if (oldAttr == newAttr || SetFileAttributesW(p.wstring().c_str(), newAttr)) {
return;

View File

@ -180,10 +180,8 @@ inline bool isWow64Proc()
typedef BOOL(WINAPI * IsWow64Process_t)(HANDLE, PBOOL);
BOOL bIsWow64 = FALSE;
auto fnIsWow64Process = (IsWow64Process_t)GetProcAddress(GetModuleHandle(TEXT("kernel32")), "IsWow64Process");
if( NULL != fnIsWow64Process )
{
if (!fnIsWow64Process(GetCurrentProcess(), &bIsWow64))
{
if (NULL != fnIsWow64Process) {
if (!fnIsWow64Process(GetCurrentProcess(), &bIsWow64)) {
bIsWow64 = FALSE;
}
}
@ -192,7 +190,7 @@ inline bool isWow64Proc()
static bool is_symlink_creation_supported()
{
bool result = false;
bool result = true;
HKEY key;
REGSAM flags = KEY_READ;
#ifdef _WIN64
@ -2314,7 +2312,7 @@ TEST_CASE("Windows: Long filename support", "[filesystem][path][fs.path.win.long
CHECK(fs::exists(dir));
generateFile(dir / "f0");
CHECK(fs::exists(dir / "f0"));
std::string native = dir.native();
std::string native = dir.u8string();
if (native.substr(0, 4) == "\\\\?\\") {
break;
}