fix
This commit is contained in:
parent
79c72d1aef
commit
72899173a0
@ -309,19 +309,15 @@ auto winfsp_drive::Create(PWSTR file_name, UINT32 create_options,
|
|||||||
UINT64 /*allocation_size*/, PVOID * /*file_node*/,
|
UINT64 /*allocation_size*/, PVOID * /*file_node*/,
|
||||||
PVOID *file_desc, OpenFileInfo *ofi) -> NTSTATUS {
|
PVOID *file_desc, OpenFileInfo *ofi) -> NTSTATUS {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
*file_desc = reinterpret_cast<PVOID>(INVALID_HANDLE_VALUE);
|
*file_desc = reinterpret_cast<PVOID>(INVALID_HANDLE_VALUE);
|
||||||
|
|
||||||
// TODO Need to revisit this
|
// TODO Need to revisit this
|
||||||
// (ConvertSecurityDescriptorToStringSecurityDescriptor/ConvertStringSecurityDescriptorToSecurityDescriptor)
|
// (ConvertSecurityDescriptorToStringSecurityDescriptor/ConvertStringSecurityDescriptorToSecurityDescriptor)
|
||||||
auto error = api_error::error;
|
|
||||||
|
|
||||||
if ((create_options & FILE_DIRECTORY_FILE) != 0U) {
|
attributes |=
|
||||||
attributes |= FILE_ATTRIBUTE_DIRECTORY;
|
((create_options & FILE_DIRECTORY_FILE) != 0U ? FILE_ATTRIBUTE_DIRECTORY
|
||||||
} else {
|
: FILE_ATTRIBUTE_ARCHIVE);
|
||||||
attributes &= static_cast<UINT32>(
|
|
||||||
~(FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_NORMAL));
|
|
||||||
attributes |= FILE_ATTRIBUTE_ARCHIVE;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto now = utils::time::get_time_now();
|
auto now = utils::time::get_time_now();
|
||||||
auto meta = create_meta_attributes(
|
auto meta = create_meta_attributes(
|
||||||
@ -339,6 +335,7 @@ auto winfsp_drive::Create(PWSTR file_name, UINT32 create_options,
|
|||||||
open_file_data ofd{};
|
open_file_data ofd{};
|
||||||
std::uint64_t handle{};
|
std::uint64_t handle{};
|
||||||
std::shared_ptr<i_open_file> file;
|
std::shared_ptr<i_open_file> file;
|
||||||
|
auto error{api_error::error};
|
||||||
if ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0U) {
|
if ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0U) {
|
||||||
error = provider_.create_directory(api_path, meta);
|
error = provider_.create_directory(api_path, meta);
|
||||||
if (error == api_error::success) {
|
if (error == api_error::success) {
|
||||||
@ -760,19 +757,13 @@ auto winfsp_drive::Overwrite(PVOID /*file_node*/, PVOID file_desc,
|
|||||||
return handle_error(res);
|
return handle_error(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (replace_attributes != 0U) {
|
attributes |= FILE_ATTRIBUTE_ARCHIVE;
|
||||||
if (attributes == 0U || attributes == FILE_ATTRIBUTE_NORMAL) {
|
|
||||||
attributes = FILE_ATTRIBUTE_ARCHIVE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (replace_attributes == 0U) {
|
||||||
meta[META_ATTRIBUTES] = std::to_string(attributes);
|
meta[META_ATTRIBUTES] = std::to_string(attributes);
|
||||||
return handle_error(provider_.set_item_meta(api_path, meta));
|
return handle_error(provider_.set_item_meta(api_path, meta));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attributes == 0U) {
|
|
||||||
return handle_error(api_error::success);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto current_attributes = utils::get_attributes_from_meta(meta);
|
auto current_attributes = utils::get_attributes_from_meta(meta);
|
||||||
auto merged_attributes = attributes | current_attributes;
|
auto merged_attributes = attributes | current_attributes;
|
||||||
if (merged_attributes != current_attributes) {
|
if (merged_attributes != current_attributes) {
|
||||||
@ -1050,19 +1041,11 @@ auto winfsp_drive::SetBasicInfo(PVOID /*file_node*/, PVOID file_desc,
|
|||||||
api_path = file->get_api_path();
|
api_path = file->get_api_path();
|
||||||
if (attributes == INVALID_FILE_ATTRIBUTES) {
|
if (attributes == INVALID_FILE_ATTRIBUTES) {
|
||||||
attributes = 0U;
|
attributes = 0U;
|
||||||
} else if (attributes == 0U) {
|
|
||||||
attributes = file->is_directory() ? FILE_ATTRIBUTE_DIRECTORY
|
|
||||||
: FILE_ATTRIBUTE_ARCHIVE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
api_meta_map meta;
|
api_meta_map meta;
|
||||||
if (attributes != 0U) {
|
if (attributes != 0U) {
|
||||||
auto next_attributes =
|
meta[META_ATTRIBUTES] = std::to_string(attributes);
|
||||||
attributes & static_cast<UINT32>(~FILE_ATTRIBUTE_NORMAL);
|
|
||||||
if (next_attributes == 0U) {
|
|
||||||
next_attributes = attributes;
|
|
||||||
}
|
|
||||||
meta[META_ATTRIBUTES] = std::to_string(next_attributes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((creation_time != 0U) && (creation_time != max_time)) {
|
if ((creation_time != 0U) && (creation_time != max_time)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user