From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7ED1E3847836; Tue, 20 Jul 2021 16:40:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7ED1E3847836 From: "enometh at meer dot net" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/101510] std::filesystem::create_directory on an existing symlink to a directory Date: Tue, 20 Jul 2021 16:40:54 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 11.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: enometh at meer dot net X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: redi at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Jul 2021 16:40:54 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101510 --- Comment #9 from Madhu --- * "redi at gcc dot gnu.org"=20 Wrote on Tue, 20 Jul 2021 16:25:44 +0000 > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101510 > > --- Comment #8 from Jonathan Wakely --- > I think you are still confused between the bool that crate_directory retu= rns, > 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 w= as > created or already existed). I'm afraid I'm still confused. From what you suggest I should be able to wr= ite // 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() =3D 20, !ec =3D 0 ensure_directories would return false but it shouldn't because asdf resolves to an existing directory.=