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

Function file_write_once

lib_acl/src/stdlib/acl_vstream.c:1453–1496  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1451}
1452
1453static int file_write_once(ACL_VSTREAM *fp, const void *vptr, int dlen)
1454{
1455 int n;
1456
1457 if ((fp->oflags & O_APPEND)) {
1458#ifdef ACL_WINDOWS
1459 fp->sys_offset = acl_lseek(ACL_VSTREAM_FILE(fp), 0, SEEK_END);
1460 if (fp->sys_offset < 0) {
1461 fp->errnum = acl_last_error();
1462 fp->flag |= ACL_VSTREAM_FLAG_ERR;
1463 return ACL_VSTREAM_EOF;
1464 }
1465#endif
1466 } else if ((fp->flag & ACL_VSTREAM_FLAG_CACHE_SEEK)
1467 && fp->offset != fp->sys_offset) {
1468
1469 fp->sys_offset = acl_lseek(ACL_VSTREAM_FILE(fp),
1470 fp->offset, SEEK_SET);
1471 if (fp->sys_offset == -1) {
1472 acl_msg_error("%s, %s(%d): lseek error(%s), "
1473 "offset(" ACL_FMT_I64D "), sys_offset("
1474 ACL_FMT_I64D ")", __FUNCTION__, __FILE__,
1475 __LINE__, acl_last_serror(),
1476 fp->offset, fp->sys_offset);
1477
1478 fp->errnum = acl_last_error();
1479 fp->flag |= ACL_VSTREAM_FLAG_ERR;
1480 return ACL_VSTREAM_EOF;
1481 }
1482 fp->offset = fp->sys_offset;
1483 }
1484
1485 n = fp->fwrite_fn(ACL_VSTREAM_FILE(fp), vptr, dlen,
1486 fp->rw_timeout, fp, fp->context);
1487 if (n > 0) {
1488 fp->sys_offset += n;
1489 fp->offset = fp->sys_offset;
1490
1491 /* ��ֹ�������ڵ�������ʵ�ʲ�һ��, �����ļ�IO��Ч */
1492 fp->read_cnt = 0;
1493 }
1494
1495 return n;
1496}
1497
1498static int write_once(ACL_VSTREAM *fp, const void *vptr, int dlen)
1499{

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…