本文整理汇总了C++中AsyncFio::open方法的典型用法代码示例。如果您正苦于以下问题:C++ AsyncFio::open方法的具体用法?C++ AsyncFio::open怎么用?C++ AsyncFio::open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AsyncFio
的用法示例。
在下文中一共展示了AsyncFio::open方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool Ps2ReadFile::open(const char *name) {
assert(_fd < 0);
_fd = fio.open(name, O_RDONLY);
if (_fd >= 0) {
_fileSize = fio.seek(_fd, 0, SEEK_END);
fio.seek(_fd, 0, SEEK_SET);
return true;
} else
return false;
}
示例2: if
bool Ps2File::open(const char *name, int mode) {
#if 1
_fd = fio.open(name, mode);
dbg_printf("open %s [%d]\n", name, _fd);
if (_fd >= 0) {
_mode = mode;
_filePos = 0;
if (_mode == O_RDONLY) {
_fileSize = fio.seek(_fd, 0, SEEK_END);
fio.seek(_fd, 0, SEEK_SET);
}
else
_fileSize = 0;
dbg_printf(" _mode = %x\n", _mode);
dbg_printf(" _fileSize = %d\n", _fileSize);
// dbg_printf(" _filePos = %d\n", _filePos);
return true;
}
return false;
#else
uint32 r;
// hack: FIO does not reports size for RW (?)
_fd = fio.open(name, O_RDONLY);
if (_fd >= 0) {
_fileSize = fio.seek(_fd, 0, SEEK_END);
fio.seek(_fd, 0, SEEK_SET); /* rewind ! */
if (_fileSize && mode != O_RDONLY) {
fio.read(_fd, _cacheBuf, _fileSize);
r = fio.sync(_fd);
dbg_printf(" sz=%d, read=%d\n", _fileSize, r);
assert(r == _fileSize);
}
fio.close(_fd);
}
else
_fileSize = 0; /* new file */
_fd = fio.open(name, mode);
dbg_printf("open %s [%d]\n", name, _fd);
if (_fd >= 0) {
_mode = mode;
_filePos = 0;
if (_fileSize) { /* existing data */
if (mode == O_RDONLY) {
/* DANGER: for w* modes it will truncate your fine files */
fio.seek(_fd, 0, SEEK_SET);
}
else if (_mode & O_APPEND) {
fio.seek(_fd, 0, _fileSize);
_filePos = _fileSize;
}
#if 0 /* file already trunc'd when opened as w* -> moved up */
if (mode != O_RDONLY) {
fio.read(_fd, _cacheBuf, _fileSize);
r = fio.sync(_fd);
dbg_printf(" sz=%d, read=%d\n", _fileSize, r);
assert(r == _fileSize);
// _fileSize = fio.seek(_fd, 0, SEEK_END);
}
#endif
}
dbg_printf(" _mode = %x\n", _mode);
dbg_printf(" _fileSize = %d\n", _fileSize);
dbg_printf(" _filePos = %d\n", _filePos);
return true;
} else
return false;
#endif
}
示例3:
void Ps2FilesystemNode::doverify(void) {
PS2Device medium;
int fd;
if (_verified)
return;
_verified = true;
dbg_printf(" verify: %s -> ", _path.c_str());
#if 0
if (_path.empty()) {
dbg_printf("PlayStation 2 Root !\n");
_verified = true;
return;
}
if (_path.lastChar() == ':') {
dbg_printf("Dev: %s\n", _path.c_str());
_verified = true;
return;
}
#endif
if (_path[3] != ':' && _path[4] != ':') {
dbg_printf("relative path !\n");
_isHere = false;
_isDirectory = false;
return;
}
medium = _getDev(_path);
if (medium == ERR_DEV) {
_isHere = false;
_isDirectory = false;
return;
}
switch (medium) {
#if 0
case HD_DEV: /*stat*/
case USB_DEV:
iox_stat_t stat;
fileXioGetStat(_path.c_str(), &stat);
fileXioWaitAsync(FXIO_WAIT, &fd);
if (!fd) {
dbg_printf(" yes [stat]\n");
return true;
}
break;
#endif
case CD_DEV: /*no stat*/
case HD_DEV:
case USB_DEV:
case HOST_DEV:
case MC_DEV:
#if 1
fd = fio.open(_path.c_str(), O_RDONLY);
dbg_printf("_path = %s -- fio.open -> %d\n", _path.c_str(), fd);
if (fd >=0) {
fio.close(fd);
dbg_printf(" yes [open]\n");
_isHere = true;
if (medium==MC_DEV && _path.lastChar()=='/')
_isDirectory = true;
else
_isDirectory = false;
return;
}
fd = fio.dopen(_path.c_str());
if (fd >=0) {
fio.dclose(fd);
dbg_printf(" yes [dopen]\n");
_isHere = true;
_isDirectory = true;
return;
}
#else
fileXioOpen(_path.c_str(), O_RDONLY, DEFAULT_MODE);
fileXioWaitAsync(FXIO_WAIT, &fd);
if (fd>=0) {
fileXioClose(fd);
fileXioWaitAsync(FXIO_WAIT, &fd);
return true;
}
fileXioDopen(_path.c_str());
fileXioWaitAsync(FXIO_WAIT, &fd);
if (fd>=0) {
fileXioDclose(fd);
fileXioWaitAsync(FXIO_WAIT, &fd);
return true;
//.........这里部分代码省略.........
示例4: return
bool Ps2WriteFile::open(const char *name) {
_fd = fio.open(name, O_WRONLY | O_CREAT | O_TRUNC);
return (_fd >= 0);
}