https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101510
--- Comment #9 from Madhu <enometh at meer dot net> --- * "redi at gcc dot gnu.org" <bug-101510-34102-afanzey...@http.gcc.gnu.org/bugzilla/> Wrote on Tue, 20 Jul 2021 16:25:44 +0000 > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101510 > > --- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> --- > I think you are still confused between the bool that crate_directory returns, > and the bool that you get from !ec > > The bool that is returned tells you if a new directory was created. > > The bool you get from !ec tells you if the directory exists (whether it was > created or already existed). I'm afraid I'm still confused. From what you suggest I should be able to write // return true if p resolves to an existing directory int ensure_directories(p) { std::error_code ec; std::filesystem::create_directories("p", ec); return !ec; } But this does not work $ mkdir xxx $ ln -sv fff asdf $ ls asdf asdf -> xxx std::filesystem::create_directories("asdf", ec); ec.value() = 20, !ec = 0 ensure_directories would return false but it shouldn't because asdf resolves to an existing directory.