Page MenuHomePhabricator

[libcxx] Explicitly return the expected error code in create_directories if the parent isn't a directory

Authored by mstorsjo on Feb 19 2021, 2:26 PM.



On windows, going ahead and actually trying to create the directory doesn't return an error code that maps to std::errc::not_a_directory in this case.

This fixes two cases of

TEST_CHECK(ErrorIs(ec, std::errc::not_a_directory))

in filesystems/fs.op.funcs/fs.op.create_directories/create_directories.pass.cpp for windows (in testcases added in 59c72a70121567f7aee347e96b4ac8f3cfe9f4b2).

Diff Detail

Event Timeline

mstorsjo requested review of this revision.Feb 19 2021, 2:26 PM
mstorsjo created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 19 2021, 2:26 PM
Herald added 1 blocking reviewer(s): Restricted Project. · View Herald Transcript

(For this one, I'd like to have @curdeius opinion, as he was working on this aspect in D93026 and D92769.)

curdeius added inline comments.Feb 20 2021, 12:27 AM

is_directory can take a file_status (so parent_st) to avoid requerying the filesystem.

mstorsjo added inline comments.Feb 20 2021, 5:49 AM

Good catch, thanks!

mstorsjo updated this revision to Diff 325194.Feb 20 2021, 5:51 AM

Check the existing parent_st instead of re-stat'ing the directory.

mstorsjo updated this revision to Diff 325195.Feb 20 2021, 5:52 AM
mstorsjo set the repository for this revision to rG LLVM Github Monorepo.

Restart CI

@curdeius Does the new version look ok to you?

curdeius accepted this revision.Feb 24 2021, 2:30 AM

Yes, LGTM! Sorry for having forgotten this review.

ldionne accepted this revision.Mar 2 2021, 12:18 PM
This revision is now accepted and ready to land.Mar 2 2021, 12:18 PM