Open cknight opened 4 years ago
Sounds reasonable.
Should presumably also apply to the soon-to-be added mode
option on open
(#4289, should be merged soon) and truncate
(#4288, waiting on some other PRs). Perhaps also the mode
option on mkdir
, but I've got little Windows experience so I don't know if they accept/honor the read-only attribute on directories.
Should the API be that 0o000
and 0o777
are required to change these attributes, and other values are ignored? Or that other values throw an error? Or that only the user-write bit (0o200
) has an effect, and other bits are ignored?
Of course, calling truncate
and open
with a read-only mode
are guaranteed to either be ignored (if the file already exists) or fail (because you can't write to a file you're creating with read-only permissions). Still if the mode
arguments are interpreted a given way on Windows for chmod
, they should be interpreted the same way here too.
I guess it shouldn't be an error to open(path, {read:true, write:false, create:true, mode:0o400})
. But if the file is created, it's going to be an empty read-only file, so this won't generally be useful.
Should the API be that
0o000
and0o777
are required to change these attributes, and other values are ignored? Or that other values throw an error? Or that only the user-write bit (0o200
) has an effect, and other bits are ignored?
I think the way node handles this is that only the user write-bit is honored. In my example 0o000
and 0o777
were arbitrary. 0o077
and 0o007
both behave as per 0o000
for example. Caveat, my access to a windows test box is limited, so I'm going off memory here.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I see similar issues in Deno.writeTextFile(). I'm setting the mode to 0o444 (read only). The file is created and filled correctly. But the permissions are wrong. They are "-rw-r--r--" (644) according to git bash, and all permissions for the current use according to Windows file explorer.
I should have created a read only file. Barring that I should have gotten an exception or at least seen more details in the documentation.
It would be nice if Deno.chmod
would allow to change read permissions on Windows, so Deno tests could include file access tests on Windows as well.
In Node, the following is observed on Windows:
However, in Deno (v0.36.0) no file mode I tested changed the read-only attribute in any way (including the above two file modes).
From the Node docs:
Windows is not mentioned in the Deno docs.
It would be good if Deno could manipulate the read-only attribute of Windows files and specifically call out Windows quirks in the documentation for chmod.