Пример #1
0
bool VMsgLog::saveLogAs()
{
    bool ok = FALSE;
    WFileName fn( "log" );
    MProject* project = _parent->project();
    if( project ) {
        project->filename().noPath( fn );
    }
    fn.setExt( ".txt" );
    WFileDialog fd( this, sFilter );
    fn = fd.getOpenFileName( fn, "Save Log as", WFSaveDefault );
    if( fn.legal() ) {
//        fn.toLower();
        WFile f;
        if( !f.open( fn, OStyleWrite ) ) {
            WMessageDialog::messagef( this, MsgError, MsgOk, _viperError, "Unable to save log file '%s'", (const char*)fn );
        } else {
            int icount  = _data.count();
            for( int i=0; i<icount; i++ ) {
                f.puts( *(WString*)_data[i] );
                f.puts( "\n" );
            }
            f.close();
            ok = TRUE;
        }
    }
    return ok;
}
Пример #2
0
bool MComponent::writeCBR( bool mustExist )
{
    bool found_a_mbr = false;
    if( mustExist )
        found_a_mbr = true;
    for( int i=0; i<_workFiles.count(); i++ ) {
        MWorkFile* w = (MWorkFile*)_workFiles[i];
        if( w->browseable() ) {
            WFileName browfile( _filename );
            browfile.setExt( ".cbr" );
            WFile brow;
            if( brow.open( browfile, OStyleWrite ) ) {
                WFileName tfile;
                _target->absResult( tfile );
                tfile.setExt( "dbr" );
                brow.printf( "d %s\n", (const char*)tfile );
                for( ; i<_workFiles.count(); i++ ) {
                    MWorkFile* w = (MWorkFile*)_workFiles[i];
                    if( w->browseable() ) {
                        w->item()->absResult( tfile );
                        tfile.setExt( "mbr" );
                        if( mustExist ) {
                            if( access( (const char*)tfile, F_OK ) == 0 )  {
                                // file must be there
                                brow.printf( "f %s\n", (const char*)tfile );
                                found_a_mbr = true;
                            }
                        } else {
                            brow.printf( "f %s\n", (const char*)tfile );
                        }
                    }
                }
                brow.close();
            }
            if( found_a_mbr ) return( true );
        }
    }
    return( false );
}