This commit is contained in:
Scott E. Graves 2024-10-28 15:15:10 -05:00
parent 79c72d1aef
commit 72899173a0

View File

@ -309,19 +309,15 @@ auto winfsp_drive::Create(PWSTR file_name, UINT32 create_options,
UINT64 /*allocation_size*/, PVOID * /*file_node*/,
PVOID *file_desc, OpenFileInfo *ofi) -> NTSTATUS {
REPERTORY_USES_FUNCTION_NAME();
*file_desc = reinterpret_cast<PVOID>(INVALID_HANDLE_VALUE);
// TODO Need to revisit this
// (ConvertSecurityDescriptorToStringSecurityDescriptor/ConvertStringSecurityDescriptorToSecurityDescriptor)
auto error = api_error::error;
if ((create_options & FILE_DIRECTORY_FILE) != 0U) {
attributes |= FILE_ATTRIBUTE_DIRECTORY;
} else {
attributes &= static_cast<UINT32>(
~(FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_NORMAL));
attributes |= FILE_ATTRIBUTE_ARCHIVE;
}
attributes |=
((create_options & FILE_DIRECTORY_FILE) != 0U ? FILE_ATTRIBUTE_DIRECTORY
: FILE_ATTRIBUTE_ARCHIVE);
auto now = utils::time::get_time_now();
auto meta = create_meta_attributes(
@ -339,6 +335,7 @@ auto winfsp_drive::Create(PWSTR file_name, UINT32 create_options,
open_file_data ofd{};
std::uint64_t handle{};
std::shared_ptr<i_open_file> file;
auto error{api_error::error};
if ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0U) {
error = provider_.create_directory(api_path, meta);
if (error == api_error::success) {
@ -760,19 +757,13 @@ auto winfsp_drive::Overwrite(PVOID /*file_node*/, PVOID file_desc,
return handle_error(res);
}
if (replace_attributes != 0U) {
if (attributes == 0U || attributes == FILE_ATTRIBUTE_NORMAL) {
attributes = FILE_ATTRIBUTE_ARCHIVE;
}
attributes |= FILE_ATTRIBUTE_ARCHIVE;
if (replace_attributes == 0U) {
meta[META_ATTRIBUTES] = std::to_string(attributes);
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 merged_attributes = 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();
if (attributes == INVALID_FILE_ATTRIBUTES) {
attributes = 0U;
} else if (attributes == 0U) {
attributes = file->is_directory() ? FILE_ATTRIBUTE_DIRECTORY
: FILE_ATTRIBUTE_ARCHIVE;
}
api_meta_map meta;
if (attributes != 0U) {
auto next_attributes =
attributes & static_cast<UINT32>(~FILE_ATTRIBUTE_NORMAL);
if (next_attributes == 0U) {
next_attributes = attributes;
}
meta[META_ATTRIBUTES] = std::to_string(next_attributes);
meta[META_ATTRIBUTES] = std::to_string(attributes);
}
if ((creation_time != 0U) && (creation_time != max_time)) {