diff options
author | pontscho <pontscho@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-02-07 12:07:47 +0000 |
---|---|---|
committer | pontscho <pontscho@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-02-07 12:07:47 +0000 |
commit | 103a960925a147adb113e0e4aab1159caade126c (patch) | |
tree | 80a40bf0f24f67ee8cdc5aba49c0baf3a9e2278b /libmpdemux/mf.c | |
parent | c3c9527d3eccd66fd2ade4dfaddaa03a8b77e3eb (diff) | |
download | mpv-103a960925a147adb113e0e4aab1159caade126c.tar.bz2 mpv-103a960925a147adb113e0e4aab1159caade126c.tar.xz |
finalize mfi support.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4566 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux/mf.c')
-rw-r--r-- | libmpdemux/mf.c | 72 |
1 files changed, 45 insertions, 27 deletions
diff --git a/libmpdemux/mf.c b/libmpdemux/mf.c index c0b5afd331..0d2d0d8744 100644 --- a/libmpdemux/mf.c +++ b/libmpdemux/mf.c @@ -31,44 +31,62 @@ int stream_open_mf(char * filename,stream_t * stream) int i; char * fname; mf_t * mf; + int error_count = 0; + int count = 0; - fname=malloc( strlen( filename ) + 2 ); - strcpy( fname,filename ); strcat( fname,"*" ); + fname=malloc( strlen( filename ) + 32 ); + mf=calloc( 1,sizeof( mf_t ) ); + + if ( !strchr( filename,'%' ) ) + { + strcpy( fname,filename ); + if ( !strchr( filename,'*' ) ) strcat( fname,"*" ); + + mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] search expr: %s\n",fname ); - if ( glob( fname,0,NULL,&gg ) ) - { free( fname ); return 0; } + if ( glob( fname,0,NULL,&gg ) ) + { free( mf ); free( fname ); return 0; } - printf( "[mf] search expr: %s\n",fname ); + mf->nr_of_files=gg.gl_pathc; + mf->names=malloc( gg.gl_pathc * sizeof( char* ) ); - mf=malloc( sizeof( mf_t ) ); - mf->nr_of_files=gg.gl_pathc; - mf->names=malloc( gg.gl_pathc * sizeof( char* ) ); + mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d (%d)\n",mf->nr_of_files, gg.gl_pathc * sizeof( char* ) ); - printf( "[mf] number of files: %d (%d)\n",mf->nr_of_files, gg.gl_pathc * sizeof( char* ) ); + for( i=0;i < gg.gl_pathc;i++ ) + { + stat( gg.gl_pathv[i],&fs ); + if( S_ISDIR( fs.st_mode ) ) continue; + mf->names[i]=strdup( gg.gl_pathv[i] ); +// mp_msg( MSGT_STREAM,MSGL_DBG2,"[mf] added file %d.: %s\n",i,mf->names[i] ); + } + globfree( &gg ); + goto exit_mf; + } - for( i=0;i < gg.gl_pathc;i++ ) + mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] search expr: %s\n",filename ); + + while ( error_count < 5 ) { - stat( gg.gl_pathv[i],&fs ); - if( S_ISDIR( fs.st_mode ) ) continue; - mf->names[i]=strdup( gg.gl_pathv[i] ); -// printf( "[mf] added file %d.: %s\n",i,mf->names[i] ); + sprintf( fname,filename,count++ ); + if ( stat( fname,&fs ) ) + { + error_count++; + mp_msg( MSGT_STREAM,MSGL_V,"[mf] file not found: '%s'\n",fname ); + } + else + { + mf->names=realloc( mf->names,( mf->nr_of_files + 1 ) * sizeof( char* ) ); + mf->names[mf->nr_of_files]=strdup( fname ); +// mp_msg( MSGT_STREAM,MSGL_V,"[mf] added file %d.: %s\n",mf->nr_of_files,mf->names[mf->nr_of_files] ); + mf->nr_of_files++; + } } - globfree( &gg ); + mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d\n",mf->nr_of_files ); + +exit_mf: free( fname ); stream->priv=(void*)mf; - return 1; } -#if 0 - -stream_t stream; - -int main( void ) -{ - stream_open_mf( "tmp/a",&stream ); - return 0; -} - -#endif |