MCPcopy Create free account
hub / github.com/apache/arrow / FileWrite

Function FileWrite

cpp/src/arrow/util/io_util.cc:1715–1739  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1713//
1714
1715Status FileWrite(int fd, const uint8_t* buffer, const int64_t nbytes) {
1716 int64_t bytes_written = 0;
1717
1718 while (bytes_written < nbytes) {
1719 const int64_t chunksize =
1720 std::min(static_cast<int64_t>(ARROW_MAX_IO_CHUNKSIZE), nbytes - bytes_written);
1721#if defined(_WIN32)
1722 int64_t ret = static_cast<int64_t>(
1723 _write(fd, buffer + bytes_written, static_cast<uint32_t>(chunksize)));
1724#else
1725 int64_t ret = static_cast<int64_t>(
1726 write(fd, buffer + bytes_written, static_cast<size_t>(chunksize)));
1727 if (ret == -1 && errno == EINTR) {
1728 continue;
1729 }
1730#endif
1731
1732 if (ret == -1) {
1733 return IOErrorFromErrno(errno, "Error writing bytes to file");
1734 }
1735 bytes_written += ret;
1736 }
1737
1738 return Status::OK();
1739}
1740
1741Status FileTruncate(int fd, const int64_t size) {
1742 int ret, errno_actual;

Callers 4

StopMethod · 0.85
WriteMethod · 0.85
TEST_FFunction · 0.85

Calls 2

IOErrorFromErrnoFunction · 0.85
OKFunction · 0.50

Tested by 2

TEST_FFunction · 0.68