本文整理汇总了C++中AsyncFio::write方法的典型用法代码示例。如果您正苦于以下问题:C++ AsyncFio::write方法的具体用法?C++ AsyncFio::write怎么用?C++ AsyncFio::write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AsyncFio
的用法示例。
在下文中一共展示了AsyncFio::write方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fclose
Ps2WriteFile::~Ps2WriteFile(void) {
if ((_fd >= 0) && (_bytesInCache)) {
fio.write(_fd, _cacheBuf, _bytesInCache);
int wrRes = fio.sync(_fd);
if (wrRes != (int)_bytesInCache) // too late to return an error
printf("Cache flush on fclose(): Unable to write %d cached bytes to mc, only %d bytes written\n", _bytesInCache, wrRes);
}
if (_fd >= 0)
fio.close(_fd);
free(_cacheBuf);
}
示例2:
Ps2File::~Ps2File() {
uint32 w;
if (_fd >= 0) {
if (_mode != O_RDONLY) {
fio.seek(_fd, 0, SEEK_SET);
fio.write(_fd, _cacheBuf, _filePos);
w = fio.sync(_fd);
dbg_printf("flushed wbuf: %x of %x\n", w, _filePos);
}
fio.close(_fd);
uint32 r = fio.sync(_fd);
dbg_printf("close [%d] - sync'd = %d\n", _fd, r);
}
free(_cacheBuf);
#ifdef __PS2_FILE_SEMA__
DeleteSema(_sema);
#endif
}
示例3:
uint32 Ps2WriteFile::write(const void *src, uint32 len) {
uint32 size = len;
uint8 *srcBuf = (uint8*)src;
while (size) {
uint32 doCpy = (len > CACHE_SIZE - _bytesInCache) ? (CACHE_SIZE - _bytesInCache) : len;
if (doCpy) {
memcpy(_cacheBuf + _bytesInCache, srcBuf, doCpy);
_bytesInCache += doCpy;
srcBuf += doCpy;
size -= doCpy;
}
if (_bytesInCache == CACHE_SIZE) {
fio.write(_fd, _cacheBuf, _bytesInCache);
if (fio.sync(_fd) != (int)_bytesInCache) {
printf("Unable to flush %d cached bytes to memory card!\n", _bytesInCache);
return 0;
}
_filePos += _bytesInCache;
_bytesInCache = 0;
}
}
return len;
}