]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Make std::filesystem::copy_file work for procfs [PR108178]
authorJonathan Wakely <jwakely@redhat.com>
Tue, 21 Mar 2023 12:29:08 +0000 (12:29 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 6 Jun 2023 11:31:57 +0000 (12:31 +0100)
commit07a0e108247f23fcb919c61595adae143f1ea02a
tree04a66d00d13fde60fd8c4e6c76a7c3bddd8e7c5b
parentd87caacf8e2df563afda85f3a5b7b852e08b6b2c
libstdc++: Make std::filesystem::copy_file work for procfs [PR108178]

The size reported by stat is always zero for some special files such as
those under /proc, which means the current copy_file implementation
thinks there is nothing to copy. Instead of trusting the stat value, try
to read a character from a streambuf and check for EOF.

libstdc++-v3/ChangeLog:

PR libstdc++/108178
* src/filesystem/ops-common.h (do_copy_file): Check for empty
files by trying to read a character.
* testsuite/27_io/filesystem/operations/copy_file_108178.cc:
New test.
libstdc++-v3/src/filesystem/ops-common.h
libstdc++-v3/testsuite/27_io/filesystem/operations/copy_file_108178.cc [new file with mode: 0644]