mirror of
https://github.com/boostorg/filesystem.git
synced 2025-05-12 13:41:47 +00:00
Correct handling of status() for reparse point when it is not a symlink.
This commit is contained in:
parent
ed9e019b01
commit
d3e3f46ce6
@ -1864,6 +1864,8 @@ file_status status(const path& p, error_code* ec)
|
||||
return process_status_failure(p, ec);
|
||||
}
|
||||
|
||||
if (ec != 0) ec->clear();
|
||||
|
||||
perms permissions = make_permissions(p, attr);
|
||||
|
||||
// reparse point handling;
|
||||
@ -1871,6 +1873,12 @@ file_status status(const path& p, error_code* ec)
|
||||
// handle to discover if the file exists
|
||||
if (attr & FILE_ATTRIBUTE_REPARSE_POINT)
|
||||
{
|
||||
if (!is_reparse_point_a_symlink(p))
|
||||
{
|
||||
return file_status(reparse_file, permissions);
|
||||
}
|
||||
|
||||
// try to resolve symlink
|
||||
handle_wrapper h(
|
||||
create_file_handle(
|
||||
p.c_str(),
|
||||
@ -1880,16 +1888,22 @@ file_status status(const path& p, error_code* ec)
|
||||
OPEN_EXISTING,
|
||||
FILE_FLAG_BACKUP_SEMANTICS,
|
||||
0)); // hTemplateFile
|
||||
|
||||
if (h.handle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
return process_status_failure(p, ec);
|
||||
}
|
||||
|
||||
if (!is_reparse_point_a_symlink(p))
|
||||
return file_status(reparse_file, permissions);
|
||||
// take attributes of target
|
||||
BY_HANDLE_FILE_INFORMATION info;
|
||||
if (!::GetFileInformationByHandle(h.handle, &info))
|
||||
{
|
||||
return process_status_failure(p, ec);
|
||||
}
|
||||
|
||||
attr = info.dwFileAttributes;
|
||||
}
|
||||
|
||||
if (ec != 0) ec->clear();
|
||||
return (attr & FILE_ATTRIBUTE_DIRECTORY)
|
||||
? file_status(directory_file, permissions)
|
||||
: file_status(regular_file, permissions);
|
||||
|
Loading…
x
Reference in New Issue
Block a user