本文整理汇总了C++中IOError函数的典型用法代码示例。如果您正苦于以下问题:C++ IOError函数的具体用法?C++ IOError怎么用?C++ IOError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IOError函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: CommonRead
static
int/*boolean*/
CommonRead(int fd, int err, int/*boolean*/ mayBlock, INTEGER* len)
{
if (CommonError(err))
return FALSE;
switch (err)
{
case ECONNRESET:
*len = 0;
return TRUE;
case EPIPE:
case ENETRESET:
IOError(ConnLost);
return FALSE;
case EWOULDBLOCK:
#if EAGAIN != EWOULDBLOCK
case EAGAIN:
#endif
if (!mayBlock)
{
*len = -1;
return TRUE;
}
break;
default:
IOError(Unexpected);
}
SchedulerPosix__IOWait(fd, TRUE, 0);
return FALSE;
}
开发者ID:RodneyBates,项目名称:M3Devel,代码行数:35,代码来源:SocketPosixC.c
示例2: CommonError
static
int/*boolean*/
CommonError(int err)
{
switch (err)
{
#ifdef _WIN32
case WSAETIMEDOUT:
#else
case ETIMEDOUT:
#endif
IOError(Timeout);
return TRUE;
#ifdef _WIN32
case WSAENETUNREACH:
case WSAEHOSTUNREACH:
case WSAEHOSTDOWN:
case WSAENETDOWN:
#else
case ENETUNREACH:
case EHOSTUNREACH:
case EHOSTDOWN:
case ENETDOWN:
#endif
IOError(Unreachable);
return TRUE;
}
return FALSE;
}
开发者ID:RodneyBates,项目名称:M3Devel,代码行数:30,代码来源:SocketPosixC.c
示例3: _out
PipeImpl::PipeImpl()
: _out(PipeIODevice::Read)
, _in(PipeIODevice::Write)
{
MSGQUEUEOPTIONS writeOpts, readOpts;
memset(&writeOpts, 0, sizeof(writeOpts));
memset(&readOpts, 0, sizeof(readOpts));
writeOpts.dwSize = sizeof(MSGQUEUEOPTIONS);
writeOpts.dwFlags = MSGQUEUE_ALLOW_BROKEN;
writeOpts.dwMaxMessages = 100;
writeOpts.cbMaxMessage = 1024;
writeOpts.bReadAccess = FALSE;
readOpts = writeOpts;
readOpts.bReadAccess = TRUE;
HANDLE outputHandle = CreateMsgQueue(NULL, &writeOpts);
if (outputHandle == INVALID_HANDLE_VALUE)
throw IOError( PT_ERROR_MSG("Could not create message queue handle") );
HANDLE inputHandle = OpenMsgQueue(::GetCurrentProcess(), outputHandle, &readOpts);
if (inputHandle == INVALID_HANDLE_VALUE)
throw IOError( PT_ERROR_MSG("Could not open message queue handle") );
_out.open(inputHandle);
_in.open(outputHandle);
}
开发者ID:3Nigma,项目名称:frayon,代码行数:29,代码来源:PipeImpl.cpp
示例4: sqlite3_prepare_v2
void PaymentOperationStateHandler::deleteRecord(
const TransactionUUID &transactionUUID)
{
string query = "DELETE FROM " + mTableName + " WHERE transaction_uuid = ?;";
sqlite3_stmt *stmt;
int rc = sqlite3_prepare_v2(mDataBase, query.c_str(), -1, &stmt, 0);
if (rc != SQLITE_OK) {
throw IOError("PaymentOperationStateHandler::delete: "
"Bad query; sqlite error: " + to_string(rc));
}
rc = sqlite3_bind_blob(stmt, 1, transactionUUID.data, NodeUUID::kBytesSize, SQLITE_STATIC);
if (rc != SQLITE_OK) {
throw IOError("PaymentOperationStateHandler::delete: "
"Bad binding of TransactionUUID; sqlite error: " + to_string(rc));
}
rc = sqlite3_step(stmt);
sqlite3_reset(stmt);
sqlite3_finalize(stmt);
if (rc == SQLITE_DONE) {
#ifdef STORAGE_HANDLER_DEBUG_LOG
info() << "prepare deleting is completed successfully";
#endif
} else {
throw IOError("PaymentOperationStateHandler::delete: "
"Run query; sqlite error: " + to_string(rc));
}
}
开发者ID:GEO-Project,项目名称:GEO-Project,代码行数:27,代码来源:PaymentOperationStateHandler.cpp
示例5: IOError
std::size_t PipeIODevice::onRead(char* buffer, std::size_t count, bool& eof)
{
if( Read != _mode )
throw IOError( PT_ERROR_MSG("Could not read from write only pipe") );
DWORD readBytes = 0;
DWORD flags = 0;
eof = false;
DWORD timeout = _timeout == EventLoop::WaitInfinite ? INFINITE
: static_cast<std::size_t>(_timeout);
if(_bufferSize)
{
readBytes = _bufferSize;
}
else if ( FALSE == ReadMsgQueue(handle(), &_buffer[0], _msgSize, &readBytes, timeout, &flags) )
{
throw IOError("ReadMsgQueue failed");
}
memcpy(buffer, &_buffer[0], count);
_bufferSize = 0;
if (count >= readBytes)
return readBytes;
std::vector<char>::iterator beginData = (_buffer.begin() + count);
std::vector<char>::iterator endData = (_buffer.begin() + readBytes);
std::copy(beginData, endData, _buffer.begin());
_bufferSize = (readBytes - count);
return count;
}
开发者ID:3Nigma,项目名称:frayon,代码行数:34,代码来源:PipeImpl.cpp
示例6: if
// ===========================================================================
// static method definitions
// ===========================================================================
OutputDevice&
OutputDevice::getDevice(const std::string& name) {
// check whether the device has already been aqcuired
if (myOutputDevices.find(name) != myOutputDevices.end()) {
return *myOutputDevices[name];
}
// build the device
OutputDevice* dev = 0;
// check whether the device shall print to stdout
if (name == "stdout") {
dev = OutputDevice_COUT::getDevice();
} else if (name == "stderr") {
dev = OutputDevice_CERR::getDevice();
} else if (FileHelpers::isSocket(name)) {
try {
int port = TplConvert::_2int(name.substr(name.find(":") + 1).c_str());
dev = new OutputDevice_Network(name.substr(0, name.find(":")), port);
} catch (NumberFormatException&) {
throw IOError("Given port number '" + name.substr(name.find(":") + 1) + "' is not numeric.");
} catch (EmptyData&) {
throw IOError("No port number given.");
}
} else {
const size_t len = name.length();
dev = new OutputDevice_File(name, len > 4 && name.substr(len - 4) == ".sbx");
}
dev->setPrecision();
dev->getOStream() << std::setiosflags(std::ios::fixed);
myOutputDevices[name] = dev;
return *dev;
}
开发者ID:p1tt1,项目名称:sumo,代码行数:34,代码来源:OutputDevice.cpp
示例7: open
void ResultsInterface::writeResult(
const char *bytes,
const size_t bytesCount) {
if (mFIFODescriptor == 0){
#ifdef MAC_OS
mFIFODescriptor = open(
FIFOFilePath().c_str(),
O_WRONLY | O_DSYNC);
#endif
#ifdef LINUX
mFIFODescriptor = open(
FIFOFilePath().c_str(),
O_WRONLY | O_RSYNC | O_DSYNC);
#endif
if (mFIFODescriptor == -1) {
throw IOError(
"ResultsInterface::ResultsInterface: "
"Can't open FIFO file.");
}
}
if (write(mFIFODescriptor, bytes, bytesCount) != bytesCount) {
close(mFIFODescriptor);
#ifdef MAC_OS
mFIFODescriptor = open(
FIFOFilePath().c_str(),
O_WRONLY | O_DSYNC);
#endif
#ifdef LINUX
mFIFODescriptor = open(
FIFOFilePath().c_str(),
O_WRONLY | O_RSYNC | O_DSYNC);
#endif
if (mFIFODescriptor == -1) {
throw IOError(
"ResultsInterface::ResultsInterface: "
"Can't open FIFO file.");
}
if (write(mFIFODescriptor, bytes, bytesCount) != bytesCount) {
throw IOError(
"ResultsInterface::writeResult: "
"Can't write result to the disk.");
}
}
#ifdef TESTS__TRUSTLINES
Timestamp start_time_s = posix::microsec_clock::universal_time();
MicrosecondsTimestamp starttime_m = microsecondsTimestamp(start_time_s);
auto debug = mLog.debug("ResultsInterface");
debug << starttime_m;
#endif
}
开发者ID:GEO-Project,项目名称:GEO-Project,代码行数:58,代码来源:ResultsInterface.cpp
示例8: log_debug
void ClientImpl::readBody(std::string& s)
{
s.clear();
_chunkedEncoding = _replyHeader.chunkedTransferEncoding();
_chunkedIStream.reset();
if (_chunkedEncoding)
{
log_debug("read body with chunked encoding");
char ch;
while (_chunkedIStream.get(ch))
s += ch;
log_debug("eod=" << _chunkedIStream.eod());
if (!_chunkedIStream.eod())
throw IOError("error reading HTTP reply body: incomplete chunked data stream");
}
else
{
unsigned n = _replyHeader.contentLength();
log_debug("read body; content-size: " << n);
s.reserve(n);
char ch;
while (n-- && _stream.get(ch))
s += ch;
if (_stream.fail())
throw IOError("error reading HTTP reply body");
//log_debug("body read: \"" << s << '"');
}
if (!_replyHeader.keepAlive())
{
log_debug("close socket - no keep alive");
_socket.close();
}
else
{
log_debug("do not close socket - keep alive");
}
}
开发者ID:AndreasWelchlin,项目名称:cxxtools,代码行数:48,代码来源:clientimpl.cpp
示例9: IOError
size_t TcpSocket::onBeginWrite(const char* buffer, size_t n)
{
if (!_impl->isConnected())
throw IOError("socket not connected when trying to read");
return _impl->beginWrite(buffer, n);
}
开发者ID:jouven,项目名称:cxxtools,代码行数:7,代码来源:tcpsocket.cpp
示例10: if
std::size_t PipeIODevice::onEndRead(EventLoop& loop, char* buffer, std::size_t n, bool& eof)
{
loop.selector().disable(_ioh);
DWORD readBytes = 0;
DWORD flags = 0;
eof = false;
// TODO: can we receive EOF?
if (_bufferSize)
{
readBytes = _bufferSize;
}
else if ( FALSE == ReadMsgQueue(handle(), &_buffer[0], _msgSize, &readBytes, INFINITE, &flags) )
{
throw IOError( PT_ERROR_MSG("Could not read from message queue handle") );
}
DWORD bytesToCopy = std::min<DWORD>(_rbuflen, readBytes);
memcpy(_rbuf, &_buffer[0], bytesToCopy);
_bufferSize = 0;
if (_rbuflen >= readBytes)
return readBytes;
std::vector<char>::iterator beginData = (_buffer.begin() + bytesToCopy);
std::vector<char>::iterator endData = (_buffer.begin() + readBytes);
std::copy(beginData, endData, _buffer.begin());
_bufferSize = (readBytes - bytesToCopy);
return bytesToCopy;
}
开发者ID:3Nigma,项目名称:frayon,代码行数:34,代码来源:PipeImpl.cpp
示例11: TFile
ROOTNtuple::ROOTNtuple(const std::string& fileName_, const std::string& treeName_){
fROOTFile = new TFile(fileName_.c_str());
if (fROOTFile->IsZombie()){
delete fROOTFile;
throw IOError("ROOTNtuple::File Does not Exist! or is Zombie " + fileName_);
}
fNtuple = dynamic_cast<TNtuple*>(fROOTFile -> Get(treeName_.c_str()));
if(!fNtuple){
delete fROOTFile;
throw IOError(Formatter()<<"ROOTNtuple::Tree does not exist, or isn't an ntuple! tree : " << treeName_ << ", filename: "<<fileName_);
}
}
开发者ID:BillyLiggins,项目名称:oxsx,代码行数:16,代码来源:ROOTNtuple.cpp
示例12: IOError
std::vector<std::string> TextFile::read()
{
if(!isValid_() || !isReading()) {
throw IOError("File is not open for reading");
}
for(const auto& symbol : skipSymbols_)
{
if(boost::starts_with(next_line_, symbol))
{
advanceLine_();
return read();
}
}
std::vector<std::string> sline;
boost::split(sline, next_line_, boost::is_any_of(delimiter_));
for(auto& s : sline)
{
boost::trim(s);
}
// Prefetch the next line from the file.
advanceLine_();
return sline;
}
开发者ID:unisb-bioinf,项目名称:genetrail2,代码行数:27,代码来源:TextFile.cpp
示例13: OutputDevice
// ===========================================================================
// method definitions
// ===========================================================================
OutputDevice_File::OutputDevice_File(const std::string& fullName, const bool binary)
: OutputDevice(binary), myFileStream(0) {
#ifdef WIN32
if (fullName == "/dev/null") {
myFileStream = new std::ofstream("NUL");
#else
if (fullName == "nul" || fullName == "NUL") {
myFileStream = new std::ofstream("/dev/null");
#endif
} else {
myFileStream = new std::ofstream(fullName.c_str(), binary ? std::ios::binary : std::ios_base::out);
}
if (!myFileStream->good()) {
delete myFileStream;
throw IOError("Could not build output file '" + fullName + "'.");
}
}
OutputDevice_File::~OutputDevice_File() {
myFileStream->close();
delete myFileStream;
}
std::ostream&
OutputDevice_File::getOStream() {
return *myFileStream;
}
开发者ID:rudhir-upretee,项目名称:Sumo17_With_Netsim,代码行数:32,代码来源:OutputDevice_File.cpp
示例14: write_supertensor_index
void write_supertensor_index(const string& name, const vector<Ref<const supertensor_reader_t>>& readers) {
// Check consistency
GEODE_ASSERT(readers.size());
const uint32_t slice = readers[0]->header.stones;
const auto sections = descendent_sections(section_t(),slice).at(slice);
GEODE_ASSERT(sections->slice==int(slice));
Hashtable<section_t,Ref<const supertensor_reader_t>> section_reader;
for (const auto reader : readers) {
GEODE_ASSERT(int(reader->header.filter)==filter);
section_reader.set(reader->header.section,reader);
}
for (const auto section : sections->sections)
GEODE_ASSERT(section_reader.contains(section));
// Write index
FILE* file = fopen(name.c_str(),"wb");
if (!file)
throw IOError(format("write_supertensor_index: can't open '%s' for writing",name));
fwrite("pentago index \n",1,20,file);
fwrite(&slice,sizeof(uint32_t),1,file);
GEODE_ASSERT(ftell(file)==24);
for (const auto section : sections->sections) {
const auto reader = section_reader.get(section);
Array<compact_blob_t> blobs(reader->offset.flat.size(),uninit);
for (const int i : range(blobs.size())) {
const uint64_t offset = reader->offset.flat[i];
blobs[i].set_offset(offset);
blobs[i].size = reader->compressed_size_.flat[i];
}
fwrite(blobs.data(),sizeof(compact_blob_t),blobs.size(),file);
}
const auto index = new_<supertensor_index_t>(sections);
GEODE_ASSERT(uint64_t(ftell(file))==index->section_offset.back());
fclose(file);
}
开发者ID:Botrix,项目名称:pentago,代码行数:35,代码来源:index.cpp
示例15: SocketPosixC__Create
int
__cdecl
SocketPosixC__Create(int/*boolean*/ reliable)
{
int one = 1;
int fd = socket(AF_INET, reliable ? SOCK_STREAM : SOCK_DGRAM, 0);
if (fd == -1)
{
Exception e = Unexpected;
switch (GetSocketError())
{
#ifdef _WIN32
case WSAEMFILE:
#else
case EMFILE:
case ENFILE:
#endif
e = NoResources;
break;
}
IOError(e);
}
#ifndef _WIN32
MakeNonBlocking(fd);
#endif
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
return fd;
}
开发者ID:RodneyBates,项目名称:M3Devel,代码行数:29,代码来源:SocketPosixC.c
示例16: GetUChar
unsigned char GetUChar()
{
int c = ::fgetc(f_);
if(c == EOF)
IOError(name_, "fgetc EOF or read error");
return static_cast<unsigned char>(c);
}
开发者ID:retrography,项目名称:prs-plus.binaries,代码行数:7,代码来源:opentypefont.cpp
示例17: file
void AbstractReptile::load()
{
QFile file("temp.data");
if(!file.exists())
return;
if(file.open(QFile::ReadOnly|QFile::Text))
{
QTextStream in(&file);
QString line=in.readLine();
this->currentUrl.setUrl(line);
line=in.readLine();
this->analysisData.setPattern(line);
line=in.readLine();
this->analysisNextUrl.setPattern(line);
line=in.readLine();
while(line!=QString(""))
{
allUrl.insert(line,1);
line=in.readLine();
}
line=in.readLine();
while(!in.atEnd())
{
data.insert(line,1);
line=in.readLine();
}
}
else
{
emit IOError(QString("Read file error: open fall."));
}
file.close();
}
开发者ID:ZHE2018,项目名称:reptil,代码行数:33,代码来源:abstract_reptile.cpp
示例18: RoughEncoding
static const char* RoughEncoding(InStm *stm)
{
// usually it's enough to test the first byte only...
switch(stm->GetUChar())
{
case 0x00: return "UTF-32BE";
case 0x0E: return "SCSU";
case 0x2B: return "UTF-7";
case '<': return "UTF-8"; // temporary assume UTF-8 XML
case 0x84: return "GB-18030";
case 0xEF: return "UTF-8";
case 0xDD: return "UTF-EBCDIC";
case 0xF7: return "UTF-1";
case 0xFB: return "BOCU-1";
case 0xFE: return "UTF-16BE";
case 0xFF:
if(stm->GetUChar() != 0xFE)
break;
return stm->GetUChar() ? "UTF-16LE" : "UTF-32LE";
default:
break;
}
IOError(stm->UIFileName(), "bad XML or unknown encoding");
return NULL;
}
开发者ID:Yanpas,项目名称:fb2-to-epub-converter,代码行数:26,代码来源:streamutf8.cpp
示例19: updateInputs
void
NeuronsImageWriter::write() {
// make sure we have a recent id map
updateInputs();
unsigned int numSections = _idMap->size();
if (_annotation) {
_directory += std::string("_") + boost::lexical_cast<std::string>(*_annotation);
}
// prepare the output directory
boost::filesystem::path directory(_directory);
if (!boost::filesystem::exists(directory)) {
boost::filesystem::create_directory(directory);
} else if (!boost::filesystem::is_directory(directory)) {
BOOST_THROW_EXCEPTION(IOError() << error_message(std::string("\"") + _directory + "\" is not a directory") << STACK_TRACE);
}
// save output images
for (unsigned int i = 0; i < numSections; i++) {
std::stringstream filename;
filename << _directory << "/" << _basename << std::setw(4) << std::setfill('0') << i << ".tiff";
vigra::exportImage(srcImageRange(*(*_idMap)[i]), vigra::ImageExportInfo(filename.str().c_str()));
}
}
开发者ID:dlbrittain,项目名称:sopnet,代码行数:35,代码来源:NeuronsImageWriter.cpp
示例20: IOError
void FileDeviceImpl::resize(off_type size)
{
int ret = ::ftruncate(fd(), size);
if(ret != 0)
throw IOError( PT_ERROR_MSG("ftruncate failed") );
}
开发者ID:3Nigma,项目名称:frayon,代码行数:7,代码来源:FileDeviceImpl.cpp
注:本文中的IOError函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论