本文整理汇总了C++中ConfigFile::fsError方法的典型用法代码示例。如果您正苦于以下问题:C++ ConfigFile::fsError方法的具体用法?C++ ConfigFile::fsError怎么用?C++ ConfigFile::fsError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfigFile
的用法示例。
在下文中一共展示了ConfigFile::fsError方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConfParser_read
FALCON_FUNC ConfParser_read( ::Falcon::VMachine *vm )
{
CoreObject *self = vm->self().asObject();
ConfigFile *cfile = (ConfigFile *) self->getUserData();
Item *i_stream = vm->param(0);
bool bRes;
if( i_stream == 0 )
{
vm->idle();
bRes = cfile->load();
vm->unidle();
}
else {
bool bValid = false;
if ( i_stream->isObject() )
{
CoreObject *streamObj = i_stream->asObject();
if ( streamObj->derivedFrom( "Stream" ) )
{
Stream *base = (Stream *) streamObj->getUserData();
bRes = cfile->load( base );
bValid = true;
}
}
if ( ! bValid )
{
throw new ParamError( ErrorParam( e_inv_params, __LINE__ ).extra( "Stream" ) );
return;
}
}
if ( ! bRes )
{
// is this an I/O or a parsing error?
if ( cfile->fsError() != 0 )
{
throw new IoError( ErrorParam( e_loaderror, __LINE__ ).
sysError( cfile->fsError() ).
extra( cfile->errorMessage() ) );
}
else {
String msg = cfile->errorMessage() + " at ";
msg.writeNumber( (int64) cfile->errorLine() );
self->setProperty( "error", cfile->errorMessage() );
self->setProperty( "errorLine", (int64) cfile->errorLine() );
throw new ParseError( ErrorParam( FALCP_ERR_INVFORMAT, __LINE__ )
.desc( FAL_STR(cp_msg_invformat) )
.extra( msg ) );
}
}
}
示例2: ConfParser_write
/*#
@method write ConfParser
@brief Write the INI file.
@optparam stream An optional output stream on which to write the configuration file.
@raise IoError on write error.
Writes the content of a modified or entirely generated configuration file on the
given stream, that must be a valid Falcon stream opened for output. If a stream
is not given, then the file name provided to the ConfParser constructor is
opened for writing. In case the name has not been given in the constructor, the
method raises an error.
*/
FALCON_FUNC ConfParser_write( ::Falcon::VMachine *vm )
{
CoreObject *self = vm->self().asObject();
ConfigFile *cfile = (ConfigFile *) self->getUserData();
Item *i_stream = vm->param(0);
bool bRes;
if( i_stream == 0 )
{
bRes = cfile->save();
}
else {
bool bValid = false;
if ( i_stream->isObject() )
{
CoreObject *streamObj = i_stream->asObject();
if ( streamObj->derivedFrom( "Stream" ) )
{
Stream *base = (Stream *) streamObj->getUserData();
bRes = cfile->save( base );
bValid = true;
}
}
if ( ! bValid )
{
throw new ParamError( ErrorParam( e_inv_params, __LINE__ ).extra( "Stream" ) );
return;
}
}
if ( ! bRes )
{
// is this a file error?
if ( cfile->fsError() )
{
throw new IoError( ErrorParam( e_file_output, __LINE__ ).
sysError( cfile->fsError() ).
extra( cfile->errorMessage() ) );
}
else
{
// no -- it's a configuration file.d
self->setProperty( "error", cfile->errorMessage() );
self->setProperty( "errorLine", (int64) cfile->errorLine() );
throw new ParseError( ErrorParam( FALCP_ERR_STORE, __LINE__ ).
desc( FAL_STR(cp_msg_errstore) ).extra( cfile->errorMessage() ) );
}
}
}