예제 #1
0
void MItem::updateAttribs()
{
    if( _component && size() > 0 ) {
        WFileName fn;
        absName( fn );
        _exists = fn.attribs( &_attribs );
    }
}
예제 #2
0
bool Browse::makeFileName( char *buff )
//-------------------------------------
{
    WFileName   file;
    WFileName   nfile;
    char        *p;
    char        *q;

    file = buff;
    if( file.attribs() ) {
        // file exists
        return( true );
    }

    if( _searchPath.length() == 0 ) {
        return( false );
    }

    p = new char [_searchPath.length() + 1];
    if( p == NULL )
        return( false );
    strcpy( p, _searchPath );

    q = strtok( p, ";" );
    while( q != NULL ) {
        nfile = "";
        nfile.setDir( q );
        nfile.setFName( file.fName() );
        nfile.setExt( file.ext() );
        if( nfile.attribs() ) {
            strcpy( buff, nfile.gets() );
            delete[] p;
            return( true );
        }
        q = strtok( NULL, ";" );
    }
    delete[] p;
    return( false );
}
예제 #3
0
void EdModule::addButton( WWindow * )
//-----------------------------------
{
    int             i;
    int             fileIdx;
    WFileNameList   files;
    WFileDialog     fileSelect( this, EdModuleFilter );
    bool            result;
    WFileName *     file;
    bool            found;

    result = fileSelect.getOpenFileName( files, NULL,
                                        "Select Module File(s)",
                                        WFOpenNew );

    if( result ) {
        for( fileIdx = 0; fileIdx < files.count(); fileIdx += 1 ) {
            file = new WFileName( files.cStringAt( fileIdx ) );

            if( *( file->ext() ) == '\0' ) {
                file->setExt("mbr");
            }
            file->absoluteTo();
            file->toLower();

            found = false;

            if( !file->attribs() ) {
                errMessage( "Module %s%s does not exist", file->fName(), file->ext() );
                found = true;
            }

            for( i = 0; i < _moduleBox->count() && !found; i += 1 ) {
                WString * str = (*_moduleBox)[ i ]->_str;

                if( *str == *file ) {
                    errMessage( "Module %s%s already in project", file->fName(), file->ext() );
                    found = true;
                }
            }

            for( int i = 0; i < _removedModuleItems->entries() && !found; i++ ) {
                WString * str = (*_removedModuleItems)[ i ]->_str;

                if( *str == *file ) {
                    ModuleItem * item = _removedModuleItems->removeAt( i ) ;
                    item->_enabled = true;
                    _moduleBox->insert( item );

                    found = true;
                }
            }

            if( !found ) {
                ModuleItem * item = new ModuleItem( file, true );
                _moduleBox->insert( item );
            }

        } /* for( i < files.count() ) */

    } /* if( result ) */
    _moduleBox->reset();

}