/************************************************************************/ // Удобная копировалка с флешки и на флешку /************************************************************************/ # include # include # ifdef __WIN__ # include #else # include #endif # include # include # include # include # include # include # include "video.h" struct t_File2 { char name[200] ; /* полное имя файла с расширением */ long size ; // размер файла long date ; long time ; char type ; /* 0-файл 1-каталог */ char status ; // 0 -такой-же, 1-совсем новый, 2-отличающийся char copy ; // копировать или нет } ; char Path1[200], // куда копировать Path2[200] ; // откуда копировать t_File2 *File1, *File2 ; long j_File1,j_File2 ; /************************************************************************/ // прочесть каталог (рекурсивная) /************************************************************************/ int read_file( char *Path, t_File2 *File, long &j_File ) { char path1[200] ; DIR *my_dir ; struct dirent *ent ; static struct stat stat1 ; my_dir = opendir( Path ); if( my_dir==NULL ) return 0 ; while( 1 ) { if( 1000<=j_File ) break ; ent = readdir( my_dir ) ; if( ent == NULL ) break ; strcpy(path1,Path); strcat(path1,"/"); strcat(path1,ent->d_name); stat( path1,&stat1 ) ; if( 0==(S_IFDIR&stat1.st_mode) ) { //if( 0==schablon( shabl,ent->d_name) ) continue ; strcpy( File[j_File].name,path1 ) ; File[j_File].type=0 ; File[j_File].date=stat1.st_mtime ; File[j_File].size=stat1.st_size ; j_File++ ; } else { if( 0==strcmp( ent->d_name,".") ) continue ; if( 0==strcmp( ent->d_name,"..") ) continue ; strcpy(path1,Path); strcat(path1,"/"); strcat(path1,ent->d_name); read_file( path1,File,j_File ); } } closedir( my_dir ) ; } /************************************************************************/ // прочесть два каталога // Path1 - старый каталог Path2 - новый каталог /************************************************************************/ void read_files( char *Path1, char *Path2 ) { long i,L ; File1=(t_File2 *)calloc( 1000,sizeof(t_File2) ); File2=(t_File2 *)calloc( 1000,sizeof(t_File2) ); j_File1=j_File2=0 ; read_file( Path1,File1,j_File1 ); read_file( Path2,File2,j_File2 ); L=strlen( Path1 ); for( i=0 ; i - отметить <Ввод> - начать копирование - выход" ); } /************************************************************************/ void loop( ) { long begin,current ; short sx,sy ; short key1,key2 ; begin=current=0 ; while( 1 ) { s_get_size( sx,sy ); paint( begin, current ); s_getch( &key1, &key2 ); switch( key2 ) { case S_key_Up : current-- ; break ; case S_key_Down : current++ ; break ; case S_key_PgUp : current-=sy-5 ; break ; case S_key_PgDn : current+=sy-5 ; break ; case S_key_Ins : File2[current].copy=1-File2[current].copy ; current++ ; break ; } switch( key1 ) { case S_key_Esc : exit( 0 ); break ; case ' ' : File2[current].copy=1-File2[current].copy ; current++ ; break ; case '\r' : return ; } if( current<0 ) current=0 ; if( j_File2<=current ) current=j_File2-1 ; if( begin>current ) begin=current ; if( begin+(sy-5)name,B->name ) ; } /************************************************************************/ void copy1( char *From, char *To ) { long L ; char Str[400] ; if( 390 \n"); return -1 ; } else { if( 199200) имена каталогов"); exit(-1); } strcpy( Path1,argv[1] ); strcpy( Path2,argv[2] ); } s_begin_schone( ); read_files( Path1,Path2 ); compare( ); reduce( ); qsort( File2,j_File2,sizeof(t_File2),compare1 ); loop(); copy( ); return 0 ; } /************************************************************************/