|
38 | 38 | #include <fcntl.h> /* values for fchmodat */
|
39 | 39 | #include <time.h>
|
40 | 40 |
|
41 |
| -// since Linux 4.5 and FreeBSD 13 |
42 |
| -#if defined(__linux__) || defined(__FreeBSD__) |
| 41 | +// since Linux 4.5 and FreeBSD 13, but the Linux libc wrapper is only provided by glibc and musl |
| 42 | +#if (defined(__linux__) && (defined(__GLIBC__) || _LIBCPP_HAS_MUSL_LIBC)) || defined(__FreeBSD__) |
43 | 43 | # define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE
|
44 | 44 | #endif
|
45 | 45 | #if __has_include(<sys/sendfile.h>)
|
|
54 | 54 |
|
55 | 55 | // sendfile and copy_file_range need to fall back
|
56 | 56 | // to the fstream implementation for special files
|
57 |
| -#if defined(_LIBCPP_FILESYSTEM_USE_SENDFILE) || defined(_LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE) || \ |
58 |
| - defined(_LIBCPP_FILESYSTEM_USE_FSTREAM) |
| 57 | +#if (defined(_LIBCPP_FILESYSTEM_USE_SENDFILE) || defined(_LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE) || \ |
| 58 | + defined(_LIBCPP_FILESYSTEM_USE_FSTREAM)) && \ |
| 59 | + _LIBCPP_HAS_LOCALIZATION |
59 | 60 | # include <fstream>
|
60 | 61 | # define _LIBCPP_FILESYSTEM_NEED_FSTREAM
|
61 | 62 | #endif
|
@@ -316,7 +317,12 @@ bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_cod
|
316 | 317 | ec.clear();
|
317 | 318 | # endif
|
318 | 319 |
|
| 320 | +# if defined(_LIBCPP_FILESYSTEM_NEED_FSTREAM) |
319 | 321 | return copy_file_impl_fstream(read_fd, write_fd, ec);
|
| 322 | +# else |
| 323 | + // since iostreams are unavailable in the no-locale build, just fail after a failed sendfile |
| 324 | + return false; |
| 325 | +# endif |
320 | 326 | }
|
321 | 327 | #elif defined(_LIBCPP_FILESYSTEM_USE_COPYFILE)
|
322 | 328 | bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_code& ec) {
|
|
0 commit comments