This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] Fix create_directories returning false but actually creating the directories, if the path name is with trailing seperators
Needs RevisionPublic

Authored by caojingfan on Jul 17 2021, 4:10 AM.

Details

Reviewers
curdeius
ldionne
Mordante
Group Reviewers
Restricted Project
Summary

if the path name is with trailing seperators like 'dir1/dir2/dir3/',
create_directories should process it just like 'dir1/dir2/dir3',
but according to https://godbolt.org/z/Wh3axvYM5, the trailing seperators
case was handled mistakenly, this patch fix it.

Diff Detail

Event Timeline

caojingfan requested review of this revision.Jul 17 2021, 4:10 AM
caojingfan created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJul 17 2021, 4:10 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
ldionne requested changes to this revision.Jul 20 2021, 12:46 PM
ldionne added a subscriber: ldionne.

It looks like CI is failing, so that should be addressed. Also, can you provide a link to the place where it says how create_directories should behave the way you say (I believe you, I just don't know the filesystem spec by heart and I want to check). Thanks for fixing this!

This revision now requires changes to proceed.Jul 20 2021, 12:46 PM

It looks like CI is failing, so that should be addressed. Also, can you provide a link to the place where it says how create_directories should behave the way you say (I believe you, I just don't know the filesystem spec by heart and I want to check). Thanks for fixing this!

Thanks for reviewing.

The CI failing actually is involving a more complicated (possibly)misbehavior about path::parent_path() function which I am currently investigating.
As for why create_directories should behave this way, it is obvious, according to the definition of the return value of create_directories https://en.cppreference.com/w/cpp/filesystem/create_directory, that create_directories can not create the directories and return false indicating that it didn't create the directories at the same time, also I can list some supplementaries:

  1. GCC 8.3 has fixed this, see https://godbolt.org/z/qe8YGj9zr
  2. A stackoverflow discussion regarding to this, https://stackoverflow.com/questions/60130796/return-value-of-stdfilesystemcreate-directories-on-paths-with-trailing-sla

rewrite the fix in a more elegant way, also add more test cases

Mordante requested changes to this revision.Sep 4 2023, 10:13 AM
Mordante added a subscriber: Mordante.

We're moving to GitHub PRs it would be great when this patch can be finished before moving. Are you interested in finishing it? If not I'll take over. Please start by rebasing the patch to see whether it passes the CI.

This revision now requires changes to proceed.Sep 4 2023, 10:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 4 2023, 10:13 AM