/* * windowSwap - swap a windows data */ void static windowSwap( wind *w ) { int i, size; long pos; pos = (long)w->id * buffSize(); FileSeek( swapHandle, pos ); size = w->width * w->height; i = write( swapHandle, w->overlap, size ); if( i != size ) { return; } i = write( swapHandle, w->whooverlapping, size ); if( i != size ) { return; } i = write( swapHandle, w->text, size * sizeof( char_info ) ); if( i != sizeof( char_info ) * size ) { return; } MemFree2( &w->text ); MemFree2( &w->whooverlapping ); MemFree2( &w->overlap ); w->isswapped = TRUE; } /* windowSwap */
/* * getDir - get current directory list (no sorting) */ static vi_rc getDir( char *dname, bool want_all_dirs ) { DIR *d; struct dirent *nd; direct_ent *tmp; int i, j, len; char wild[FILENAME_MAX]; char path[FILENAME_MAX]; char ch; bool is_subdir; vi_rc rc; /* * initialize for file scan */ len = strlen( dname ); for( i = len - 1; i >= 0; i-- ) { if( dname[i] == '/' || dname[i] == '\\' || dname[i] == ':' ) { break; } } for( j = 0; j < i + 1; j++ ) { path[j] = dname[j]; } path[i + 1] = 0; if( i >= 0 ) { ch = path[i]; } else { ch = 0; } for( j = i + 1; j <= len; j++ ) { wild[j - i - 1] = dname[j]; } rc = FileMatchInit( wild ); if( rc != ERR_NO_ERR ) { return( rc ); } #ifndef __UNIX__ if( ch != '\\' && ch != '/' && ch != ':' && ch != 0 ) { strcat( path, FILE_SEP_STR ); } strcat( path, ALL_FILES_WILD_CARD ); #else if( ch == 0 ) { path[0] = '.'; path[1] = 0; } #endif for( i = 0; i < DirFileCount; i++ ) { MemFree2( &DirFiles[i] ); } DirFileCount = 0; d = opendir( path ); if( d == NULL ) { FileMatchFini(); return( ERR_FILE_NOT_FOUND ); } /* * loop through all directory entries */ while( (nd = readdir( d )) != NULL ) { if( DirFileCount >= MAX_FILES ) { break; } is_subdir = FALSE; #if defined( __QNX__ ) if( nd->d_stat.st_mode & S_IFDIR ) { is_subdir = TRUE; } #elif defined( __UNIX__ ) { struct stat st; stat( nd->d_name, &st ); if( st.st_mode & S_IFDIR ) { is_subdir = TRUE; } } #else if( nd->d_attr & _A_SUBDIR ) { is_subdir = TRUE; } #endif if( !(want_all_dirs && is_subdir) ) { if( !FileMatch( nd->d_name ) ) { continue; } } len = strlen( nd->d_name ); DirFiles[DirFileCount] = MemAlloc( sizeof( direct_ent ) + len ); tmp = DirFiles[DirFileCount]; GetFileInfo( tmp, nd, path ); memcpy( tmp->name, nd->d_name, len + 1 ); FileLower( tmp->name ); DirFileCount++; } FileMatchFini(); closedir( d ); return( ERR_NO_ERR ); } /* getDir */