2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include <sys/types.h>
34 #include "osdep/glob.h"
36 #include "osdep/strsep.h"
39 #include "stream/stream.h"
43 int mf_w
= 0; //352; // let codecs to detect it
46 char * mf_type
= NULL
; //"jpg";
48 mf_t
* open_mf(char * filename
){
49 #if defined(HAVE_GLOB) || defined(__MINGW32__)
58 mf
=calloc( 1,sizeof( mf_t
) );
60 if( filename
[0] == '@' )
62 FILE *lst_f
=fopen(filename
+ 1,"r");
66 while ( fgets( fname
,255,lst_f
) )
68 /* remove spaces from end of fname */
69 char *t
=fname
+ strlen( fname
) - 1;
70 while ( t
> fname
&& isspace( *t
) ) *(t
--)=0;
71 if ( stat( fname
,&fs
) )
73 mp_msg( MSGT_STREAM
,MSGL_V
,"[mf] file not found: '%s'\n",fname
);
77 mf
->names
=realloc( mf
->names
,( mf
->nr_of_files
+ 1 ) * sizeof( char* ) );
78 mf
->names
[mf
->nr_of_files
]=strdup( fname
);
84 mp_msg( MSGT_STREAM
,MSGL_INFO
,"[mf] number of files: %d\n",mf
->nr_of_files
);
87 mp_msg( MSGT_STREAM
,MSGL_INFO
,"[mf] %s is not indirect filelist\n",filename
+1 );
90 if( strchr( filename
,',') )
92 mp_msg( MSGT_STREAM
,MSGL_INFO
,"[mf] filelist: %s\n",filename
);
94 while ( ( fname
=strsep( &filename
,"," ) ) )
96 if ( stat( fname
,&fs
) )
98 mp_msg( MSGT_STREAM
,MSGL_V
,"[mf] file not found: '%s'\n",fname
);
102 mf
->names
=realloc( mf
->names
,( mf
->nr_of_files
+ 1 ) * sizeof( char* ) );
103 mf
->names
[mf
->nr_of_files
]=strdup( fname
);
104 // mp_msg( MSGT_STREAM,MSGL_V,"[mf] added file %d.: %s\n",mf->nr_of_files,mf->names[mf->nr_of_files] );
108 mp_msg( MSGT_STREAM
,MSGL_INFO
,"[mf] number of files: %d\n",mf
->nr_of_files
);
113 fname
=malloc( strlen( filename
) + 32 );
115 if ( !strchr( filename
,'%' ) )
117 strcpy( fname
,filename
);
118 if ( !strchr( filename
,'*' ) ) strcat( fname
,"*" );
120 mp_msg( MSGT_STREAM
,MSGL_INFO
,"[mf] search expr: %s\n",fname
);
122 if ( glob( fname
,0,NULL
,&gg
) )
123 { free( mf
); free( fname
); return NULL
; }
125 mf
->nr_of_files
=gg
.gl_pathc
;
126 mf
->names
=calloc( gg
.gl_pathc
, sizeof( char* ) );
128 mp_msg( MSGT_STREAM
,MSGL_INFO
,"[mf] number of files: %d (%d)\n",mf
->nr_of_files
, gg
.gl_pathc
* sizeof( char* ) );
130 for( i
=0;i
< gg
.gl_pathc
;i
++ )
132 stat( gg
.gl_pathv
[i
],&fs
);
133 if( S_ISDIR( fs
.st_mode
) ) continue;
134 mf
->names
[i
]=strdup( gg
.gl_pathv
[i
] );
135 // mp_msg( MSGT_STREAM,MSGL_DBG2,"[mf] added file %d.: %s\n",i,mf->names[i] );
141 mp_msg( MSGT_STREAM
,MSGL_INFO
,"[mf] search expr: %s\n",filename
);
143 while ( error_count
< 5 )
145 sprintf( fname
,filename
,count
++ );
146 if ( stat( fname
,&fs
) )
149 mp_msg( MSGT_STREAM
,MSGL_V
,"[mf] file not found: '%s'\n",fname
);
153 mf
->names
=realloc( mf
->names
,( mf
->nr_of_files
+ 1 ) * sizeof( char* ) );
154 mf
->names
[mf
->nr_of_files
]=strdup( fname
);
155 // mp_msg( MSGT_STREAM,MSGL_V,"[mf] added file %d.: %s\n",mf->nr_of_files,mf->names[mf->nr_of_files] );
160 mp_msg( MSGT_STREAM
,MSGL_INFO
,"[mf] number of files: %d\n",mf
->nr_of_files
);
166 mp_msg(MSGT_STREAM
,MSGL_FATAL
,"[mf] mf support is disabled on your os\n");