From: Jonathan Wakely <jwakely@redhat.com>
To: Jonathan Wakely <jwakely@redhat.com>
Cc: "libstdc++" <libstdc++@gcc.gnu.org>,
gcc Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [committed] libstdc++: Improve directory iterator abstractions for openat
Date: Tue, 28 Jun 2022 15:55:39 +0100 [thread overview]
Message-ID: <CACb0b4krJC7uO_bOXKzsbGR9Y_JP9oYBXAXSrACF13=6DM16aw@mail.gmail.com> (raw)
In-Reply-To: <20220628111212.206509-1-jwakely@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1109 bytes --]
On Tue, 28 Jun 2022 at 15:24, Jonathan Wakely via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
> --- a/libstdc++-v3/src/filesystem/dir-common.h
> +++ b/libstdc++-v3/src/filesystem/dir-common.h
> @@ -25,6 +25,7 @@
> #ifndef _GLIBCXX_DIR_COMMON_H
> #define _GLIBCXX_DIR_COMMON_H 1
>
> +#include <stdint.h> // uint32_t
> #include <string.h> // strcmp
> #include <errno.h>
> #if _GLIBCXX_FILESYSTEM_IS_WINDOWS
> @@ -91,12 +92,50 @@ is_permission_denied_error(int e)
>
> struct _Dir_base
> {
> + // As well as the full pathname (including the directory iterator's path)
> + // this type contains a file descriptor for a directory and a second pathname
> + // relative to that directory. The file descriptor and relative pathname
> + // can be used with POSIX openat and unlinkat.
> + struct _At_path
> + {
> + // No file descriptor given, so interpret the pathname relative to the CWD.
> + _At_path(const char* p) noexcept
I forgot to consistently use the char_type alias to support wchar_t
paths on Windows. Fixed by the attached patch.
Tested x86_64-linux and x86_64-mingw32, pushed to trunk.
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1705 bytes --]
commit bb1f266a7d602ffee4a070f586351bdfafcb6150
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Tue Jun 28 12:56:19 2022
libstdc++: Fix filesystem build for Windows
I only half remembered to use char_type instead of char for filesystem
paths, so that it works with wchar_t on Windows. This fixes the
bootstrap failure.
libstdc++-v3/ChangeLog:
* src/filesystem/dir-common.h (_Dir_base::_At_path):
Use char_type consistently for paths.
diff --git a/libstdc++-v3/src/filesystem/dir-common.h b/libstdc++-v3/src/filesystem/dir-common.h
index 4844b1ac453..228fab55afb 100644
--- a/libstdc++-v3/src/filesystem/dir-common.h
+++ b/libstdc++-v3/src/filesystem/dir-common.h
@@ -99,18 +99,22 @@ struct _Dir_base
struct _At_path
{
// No file descriptor given, so interpret the pathname relative to the CWD.
- _At_path(const char* p) noexcept
+ _At_path(const posix::char_type* p) noexcept
: pathname(p), dir_fd(fdcwd()), offset(0)
{ }
- _At_path(int fd, const char* p, size_t offset) noexcept
+ _At_path(int fd, const posix::char_type* p, size_t offset) noexcept
: pathname(p), dir_fd(fd), offset(offset)
{ }
- const char* path() const noexcept { return pathname; }
+ const posix::char_type*
+ path() const noexcept { return pathname; }
- int dir() const noexcept { return dir_fd; }
- const char* path_at_dir() const noexcept { return pathname + offset; }
+ int
+ dir() const noexcept { return dir_fd; }
+
+ const posix::char_type*
+ path_at_dir() const noexcept { return pathname + offset; }
private:
const posix::char_type* pathname; // Full path relative to CWD.
prev parent reply other threads:[~2022-06-28 14:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-28 11:12 Jonathan Wakely
2022-06-28 14:55 ` Jonathan Wakely [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CACb0b4krJC7uO_bOXKzsbGR9Y_JP9oYBXAXSrACF13=6DM16aw@mail.gmail.com' \
--to=jwakely@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).