File tree Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -463,15 +463,24 @@ static NTSTATUS DOKAN_CALLBACK memfs_setfileattributes(
463
463
fileattributes);
464
464
if (!f) return STATUS_OBJECT_NAME_NOT_FOUND;
465
465
466
- // No attributes need to be changed
467
- if (fileattributes == 0 ) return STATUS_SUCCESS;
466
+ // from https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-setfileattributesw
467
+ DWORD const attributes_allowed_to_set =
468
+ FILE_ATTRIBUTE_ARCHIVE | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_NORMAL |
469
+ FILE_ATTRIBUTE_NOT_CONTENT_INDEXED | FILE_ATTRIBUTE_OFFLINE |
470
+ FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM |
471
+ FILE_ATTRIBUTE_TEMPORARY;
468
472
469
- // FILE_ATTRIBUTE_NORMAL is override if any other attribute is set
470
- if (fileattributes & FILE_ATTRIBUTE_NORMAL &&
471
- (fileattributes & (fileattributes - 1 )))
472
- fileattributes &= ~FILE_ATTRIBUTE_NORMAL;
473
+ fileattributes &= attributes_allowed_to_set;
473
474
474
- f->attributes = fileattributes;
475
+ DWORD new_file_attributes =
476
+ (f->attributes & ~attributes_allowed_to_set) | fileattributes;
477
+
478
+ // FILE_ATTRIBUTE_NORMAL is overriden if any other attribute is set
479
+ if ((new_file_attributes & FILE_ATTRIBUTE_NORMAL) &&
480
+ (new_file_attributes & ~static_cast <DWORD>(FILE_ATTRIBUTE_NORMAL)))
481
+ new_file_attributes &= ~static_cast <DWORD>(FILE_ATTRIBUTE_NORMAL);
482
+
483
+ f->attributes = new_file_attributes;
475
484
return STATUS_SUCCESS;
476
485
}
477
486
You can’t perform that action at this time.
0 commit comments