Skip to content

Commit 92765db

Browse files
committed
fix no-locale empty file copy
1 parent 482ce86 commit 92765db

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

libcxx/src/filesystem/operations.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,14 @@ bool copy_file_impl_sendfile(FileDescriptor& read_fd, FileDescriptor& write_fd,
261261
size_t count = read_fd.get_stat().st_size;
262262
// a zero-length file is either empty, or not copyable by this syscall
263263
// return early to avoid the syscall cost
264+
// however, we can't afford this luxury in the no-locale build,
265+
// as we can't utilize the fstream impl to copy empty files
266+
# if _LIBCPP_HAS_LOCALIZATION
264267
if (count == 0) {
265268
ec = {EINVAL, generic_category()};
266269
return false;
267270
}
271+
# endif
268272
do {
269273
ssize_t res;
270274
if ((res = ::sendfile(write_fd.fd, read_fd.fd, nullptr, count)) == -1) {

libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy_file/copy_file_procfs.pass.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// UNSUPPORTED: c++03, c++11, c++14
1010
// REQUIRES: linux
1111
// UNSUPPORTED: no-filesystem
12+
// XFAIL: no-localization
1213
// UNSUPPORTED: availability-filesystem-missing
1314

1415
// <filesystem>

0 commit comments

Comments
 (0)