static void getRelFname( HWND hwnd, const char *fname, WString *relname ) { WString fullpath; GetFilesInfo *info; WFileName tgt; WFileName filename; char drive[_MAX_DRIVE]; char dir[_MAX_DIR]; info = (GetFilesInfo *)GET_DLGDATA( hwnd ); getFullFname( hwnd, fname, &fullpath ); filename = fullpath.gets(); _splitpath( info->tgt_file, drive, dir, NULL, NULL ); if( !stricmp( drive, filename.drive() ) ) { formRelDir( filename.dir(), dir, relname ); relname->concat( filename.fName() ); relname->concat( filename.ext() ); } else { *relname = fullpath.gets(); } }
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 ); }
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(); }