Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Erlend E. Aasland <[email protected]>
  • Loading branch information
serhiy-storchaka and erlend-aasland authored Dec 14, 2023
commit 37725be0abae3bd4f4e8c2972ef7187985a5ebc0
14 changes: 9 additions & 5 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -3323,10 +3323,12 @@ win32_lchmod(LPCWSTR path, int mode)
if (attr == INVALID_FILE_ATTRIBUTES) {
return 0;
}
if (mode & _S_IWRITE)
if (mode & _S_IWRITE) {
attr &= ~FILE_ATTRIBUTE_READONLY;
else
}
else {
attr |= FILE_ATTRIBUTE_READONLY;
}
return SetFileAttributesW(path, attr);
}
#endif
Expand Down Expand Up @@ -3404,14 +3406,16 @@ os_chmod_impl(PyObject *module, path_t *path, int mode, int dir_fd,
if (GetFileInformationByHandleEx(hfile, FileBasicInfo,
&info, sizeof(info)))
{
if (mode & _S_IWRITE)
if (mode & _S_IWRITE) {
info.FileAttributes &= ~FILE_ATTRIBUTE_READONLY;
else
}
else {
info.FileAttributes |= FILE_ATTRIBUTE_READONLY;
}
result = SetFileInformationByHandle(hfile, FileBasicInfo,
&info, sizeof(info));
}
CloseHandle(hfile);
(void)CloseHandle(hfile);
}
}
else {
Expand Down