C++ Logo

std-proposals

Advanced search

Re: [std-proposals] D2854 Proposal of std::filesystem::program_path() LIVE LINK

From: Thiago Macieira <thiago_at_[hidden]>
Date: Thu, 27 Apr 2023 15:20:11 -0700
On Thursday, 27 April 2023 06:18:21 PDT Andrew Tomazos via Std-Proposals
wrote:
> Please find below a live link to a short proposal:
>
> *D2854 Proposal of std::filesystem::program_path()*
>
> https://docs.google.com/document/d/1YzHFwGEEvbeohua7aLLysfCSOHevGi_N5Stv-z--> GpA
> > We propose adding the following two functions to std::filesystem:
> >
> > namespace std::filesystem {
> >
> > path program_path();
> >
> > path program_path(error_code& ec);
> >
> > }
> >
> > They return a std::filesystem::path to the currently running program.

Sounds good. Please add:

"It is implementation-defined what this path will be. It may point to to a non-
existent file, or point to a file that is not the current executable."

These are not failure conditions of the API and the library simply can't know
that it isn't what the user wants:

* case non-existent: file has been deleted, file never existed in the filesystem
in the first place (e.g., a memfd)

* case something completely different: mount namespace has changed (e.g.,
pivot_root or equivalent)

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DCAI Cloud Engineering

Received on 2023-04-27 22:20:13