This is an archive of the discontinued LLVM Phabricator instance.

[Support][Unix] create_directory should fail if the path is not directory
Needs ReviewPublic

Authored by steven_wu on Jun 15 2023, 10:05 AM.

Details

Reviewers
Bigcheese
Summary

When create_directory is called with IngoreExisting is true, the function
will return success if the path provided exists, no matter if that is a
directory or not.

At the same time, the caller of the function would expect that if the
function returns success, the path provided should be a directory. Update
the function so it matches the expectation and caller doesn't need to
check if the path is a directory before using it.

Diff Detail

Event Timeline

steven_wu created this revision.Jun 15 2023, 10:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 15 2023, 10:05 AM
steven_wu requested review of this revision.Jun 15 2023, 10:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 15 2023, 10:05 AM

Two comments on this patch:

  • I don't know what is the behavior on windows. From docs, it should have the correct behavior, but probably not returning the same error_code.
  • It currently returns EEXIST in such case (at least on macOS). I am not sure if other unix/linux returns the same error, or it returns ENOTDIR? Pre-commit test might give some answer.