MCPcopy Create free account
hub / github.com/acl-dev/acl / file_writev_once

Function file_writev_once

lib_acl/src/stdlib/acl_vstream.c:1574–1633  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1572}
1573
1574static int file_writev_once(ACL_VSTREAM *fp, const struct iovec *vec, int count)
1575{
1576 int n = 0;
1577
1578 if ((fp->oflags & O_APPEND)) {
1579#ifdef ACL_WINDOWS
1580 fp->sys_offset = acl_lseek(ACL_VSTREAM_FILE(fp), 0, SEEK_END);
1581 if (fp->sys_offset < 0) {
1582 fp->errnum = acl_last_error();
1583 fp->flag |= ACL_VSTREAM_FLAG_ERR;
1584 return ACL_VSTREAM_EOF;
1585 }
1586#endif
1587 } else if ((fp->flag & ACL_VSTREAM_FLAG_CACHE_SEEK)
1588 && fp->offset != fp->sys_offset) {
1589
1590 fp->sys_offset = acl_lseek(ACL_VSTREAM_FILE(fp),
1591 fp->offset, SEEK_SET);
1592 if (fp->sys_offset == -1) {
1593 acl_msg_error("%s, %s(%d): lseek error(%s), "
1594 "offset(" ACL_FMT_I64D "), sys_offset("
1595 ACL_FMT_I64D ")", __FUNCTION__, __FILE__,
1596 __LINE__, acl_last_serror(),
1597 fp->offset, fp->sys_offset);
1598
1599 fp->errnum = acl_last_error();
1600 fp->flag |= ACL_VSTREAM_FLAG_ERR;
1601 return ACL_VSTREAM_EOF;
1602 }
1603 }
1604
1605 if (fp->fwrite_fn == acl_file_write) {
1606 n = fp->fwritev_fn(ACL_VSTREAM_FILE(fp), vec, count,
1607 fp->rw_timeout, fp, fp->context);
1608 } else {
1609 int i, ret;
1610
1611 for (i = 0; i < count; i++) {
1612 ret = write_once(fp, vec[i].iov_base,
1613 (int) vec[i].iov_len);
1614 if (ret == ACL_VSTREAM_EOF) {
1615 return ACL_VSTREAM_EOF;
1616 }
1617 n += ret;
1618 if (ret < (int) vec[i].iov_len) {
1619 break;
1620 }
1621 }
1622 }
1623
1624 if (n > 0) {
1625 fp->sys_offset += n;
1626 fp->offset = fp->sys_offset;
1627
1628 /* ��ֹ�������ڵ�������ʵ�ʲ�һ��, �����ļ�IO��Ч */
1629 fp->read_cnt = 0;
1630 }
1631

Callers 1

acl_vstream.cFile · 0.85

Calls 4

acl_lseekFunction · 0.85
acl_last_errorFunction · 0.85
acl_msg_errorFunction · 0.85
acl_last_serrorFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…