[libcxx-commits] [PATCH] D76798: [libc++] Make sure that temp_directory_path() doesn't return a path with a trailing slash

Eric Fiselier via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Mar 26 09:12:14 PDT 2020

EricWF added a comment.

I don't necessarily agree.

First, no implementation currently has the behavior you describe.
Both libstdc++ and Boost filesystem return the environment variable as specified.

Also, on OS X, the TEMPDIR variable includes the trailing slash. If that's what the operating system does, why should we differ?

I also think there are some subtle differences in pathname resolution. Specifically around symlinks and when the basename doesn't exist.

For example, let's assume `TEMPDIR` is `/this-directory-does-not-exist/`. `touch foo; cp foo $TEMPDIR` fails because there is no such directory. Without the trailing slash it succeeds and copies `foo` to a new file called `this-directory-does-not-exist`.

In general trailing slashes are used to denote that the entity is a directory. I don't see a strong reason to differ.

But if you disagree, I'm willing to proceed with your fix, on the condition that you file a LWG issue about this proposing this behavior as standard.

  rG LLVM Github Monorepo



More information about the libcxx-commits mailing list