Skip to content

Directory.CreateDirectory with UnixFileMode: behavior for missing parents #73899

Closed

Description

@tmds

Currently, the mode argument is used to create missing parents too.
I would like to change it to only apply to the leaf directory.

This is consistent with mkdir which doesn't use the -m <mode> argument for parents (-p flag).

It avoids unintentionally creating parent directories with wrong permissions.
For example:

// Create app data folder with `700` permission.
string appPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData, Environment.SpecialFolderOption.DoNotVerify), "my-app");
Directory.CreateDirectory(appPath, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute);

@eerhardt @adamsitnik @dotnet/area-system-io do you agree? If so, I'll make a PR to implement this change.

Activity

  1. ghost added
    untriaged
    on Aug 13, 2022
  2. danmoseley commented on Aug 13, 2022

    @danmoseley
    Contributor
  3. added this to the 7.0.0 milestone on Aug 15, 2022
  4. ghost removed
    untriaged
    on Aug 15, 2022
  5. jeffhandley commented on Aug 15, 2022

    @jeffhandley
    Member

    @adamsitnik + @jozkee, I know that @eerhardt won't be able to look at this until later in the week. Could one of you two please take a look Monday/Tuesday to see if we can address this with RC1?

  6. jozkee commented on Aug 15, 2022

    @jozkee
    Member

    @tmds the proposed change sounds good to me.

  7. ghost added
    in-pr
    on Aug 16, 2022
  8. ghost removed
    in-pr
    on Aug 19, 2022
  9. ghost locked as resolved and limited conversation to collaborators on Sep 19, 2022
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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions