Skip to content

I want to know best practices for checking directory permissions #3871

Description

@KazukiSugiyama107

Details

Before creating a directory under a specific directory like mkdir, I would like to check the permissions and see if the directory can be created.
I think the method of receiving an error in the mkdir callback is correct originally, but that method cannot be used because mkdir is executed in the processing of the external library.
After reviewing the documentation, I think the correct way is to use "opendir" to receive the callback.
Is that the right way?

Also, if you use the fs module "opendir", "access" for a directory that you do not have write permission for, the result will be different.
I'd like to know why the results are different, do you understand?

  • access (params : fs.constants.W_OK)
    • No error returned
  • opendir
    • Error callback is returned

OS: Windows 10
Directory: Program Files

Node.js version

14.15.3

Example code

No response

Operating system

Windows 10

Scope

other

Module and version

Not applicable.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions