Mercurial > mplayer.hg
comparison gui/ui/gtk/fileselect.c @ 35399:4d7adee0a7ba
Check stat() return value before utilizing its information.
author | ib |
---|---|
date | Wed, 28 Nov 2012 11:40:52 +0000 |
parents | d59cf5c869f4 |
children | 0c93b5400dc7 |
comparison
equal
deleted
inserted
replaced
35398:14aeceb6c267 | 35399:4d7adee0a7ba |
---|---|
196 clist_append_fname(list, "..", dpixmap, dmask); | 196 clist_append_fname(list, "..", dpixmap, dmask); |
197 | 197 |
198 glob( "*",0,NULL,&gg ); | 198 glob( "*",0,NULL,&gg ); |
199 for( i=0;i<gg.gl_pathc;i++ ) | 199 for( i=0;i<gg.gl_pathc;i++ ) |
200 { | 200 { |
201 stat( gg.gl_pathv[i],&fs ); | 201 if( ( stat( gg.gl_pathv[i],&fs ) != 0 ) || !S_ISDIR( fs.st_mode ) ) continue; |
202 if( !S_ISDIR( fs.st_mode ) ) continue; | |
203 clist_append_fname(list, gg.gl_pathv[i], dpixmap, dmask); | 202 clist_append_fname(list, gg.gl_pathv[i], dpixmap, dmask); |
204 } | 203 } |
205 | 204 |
206 for (fn = 1, i = 0; fsFilter[i]; i++) | 205 for (fn = 1, i = 0; fsFilter[i]; i++) |
207 if (fsFilter[i] == ',') fn++; | 206 if (fsFilter[i] == ',') fn++; |
224 | 223 |
225 for( i=0;i<gg.gl_pathc;i++ ) | 224 for( i=0;i<gg.gl_pathc;i++ ) |
226 { | 225 { |
227 char *ext; | 226 char *ext; |
228 | 227 |
229 stat( gg.gl_pathv[i],&fs ); | 228 if( ( stat( gg.gl_pathv[i],&fs ) != 0 ) || S_ISDIR( fs.st_mode ) ) continue; |
230 if( S_ISDIR( fs.st_mode ) ) continue; | |
231 | 229 |
232 ext = strrchr(gg.gl_pathv[i], '.'); | 230 ext = strrchr(gg.gl_pathv[i], '.'); |
233 | 231 |
234 if (ext || !fext[0]) | 232 if (ext || !fext[0]) |
235 { | 233 { |
330 dir = strdup( tmp ); | 328 dir = strdup( tmp ); |
331 | 329 |
332 do | 330 do |
333 { | 331 { |
334 char * c = strrchr( dir,'/' ); | 332 char * c = strrchr( dir,'/' ); |
335 stat( dir,&f ); | 333 if ( ( stat( dir,&f ) != 0 ) || S_ISDIR( f.st_mode ) ) break; |
336 if ( S_ISDIR( f.st_mode ) ) break; | |
337 if ( c ) *c=0; | 334 if ( c ) *c=0; |
338 } while ( strrchr( dir,'/' ) ); | 335 } while ( strrchr( dir,'/' ) ); |
339 | 336 |
340 if ( !dir[0] ) nfree( dir ); | 337 if ( !dir[0] ) nfree( dir ); |
341 } | 338 } |
488 GList * item; | 485 GList * item; |
489 int i = 1, l; | 486 int i = 1, l; |
490 struct stat fs; | 487 struct stat fs; |
491 gchar * selected; | 488 gchar * selected; |
492 | 489 |
493 stat( fsSelectedFile,&fs ); | 490 if( ( stat( fsSelectedFile,&fs ) == 0 ) && S_ISDIR( fs.st_mode ) ) |
494 if( S_ISDIR(fs.st_mode ) ) | |
495 { | 491 { |
496 chdir( fsSelectedFile ); | 492 chdir( fsSelectedFile ); |
497 fsSelectedFile=fsThatDir; | 493 fsSelectedFile=fsThatDir; |
498 CheckDir( fsFNameList ); | 494 CheckDir( fsFNameList ); |
499 gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)get_current_dir_name_utf8() ); | 495 gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)get_current_dir_name_utf8() ); |