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.
27 #include <sys/types.h>
36 #include "osdep/glob.h"
38 #include "osdep/strsep.h"
41 #include "stream/stream.h"
46 int mf_w
= 0; //352; // let codecs to detect it
49 char * mf_type
= NULL
; //"jpg";
51 mf_t
* open_mf(char * filename
){
52 #if defined(HAVE_GLOB) || defined(__MINGW32__)
60 mf
=calloc( 1,sizeof( mf_t
) );
62 if( filename
[0] == '@' )
64 FILE *lst_f
=fopen(filename
+ 1,"r");
67 fname
=malloc(MP_PATH_MAX
);
68 while ( fgets( fname
,MP_PATH_MAX
,lst_f
) )
70 /* remove spaces from end of fname */
71 char *t
=fname
+ strlen( fname
) - 1;
72 while ( t
> fname
&& isspace( *t
) ) *(t
--)=0;
73 if ( !mp_path_exists( fname
) )
75 mp_msg( MSGT_STREAM
,MSGL_V
,"[mf] file not found: '%s'\n",fname
);
79 mf
->names
=realloc( mf
->names
,( mf
->nr_of_files
+ 1 ) * sizeof( char* ) );
80 mf
->names
[mf
->nr_of_files
]=strdup( fname
);
86 mp_msg( MSGT_STREAM
,MSGL_INFO
,"[mf] number of files: %d\n",mf
->nr_of_files
);
89 mp_msg( MSGT_STREAM
,MSGL_INFO
,"[mf] %s is not indirect filelist\n",filename
+1 );
92 if( strchr( filename
,',') )
94 mp_msg( MSGT_STREAM
,MSGL_INFO
,"[mf] filelist: %s\n",filename
);
96 while ( ( fname
=strsep( &filename
,"," ) ) )
98 if ( !mp_path_exists( fname
) )
100 mp_msg( MSGT_STREAM
,MSGL_V
,"[mf] file not found: '%s'\n",fname
);
104 mf
->names
=realloc( mf
->names
,( mf
->nr_of_files
+ 1 ) * sizeof( char* ) );
105 mf
->names
[mf
->nr_of_files
]=strdup( fname
);
106 // mp_msg( MSGT_STREAM,MSGL_V,"[mf] added file %d.: %s\n",mf->nr_of_files,mf->names[mf->nr_of_files] );
110 mp_msg( MSGT_STREAM
,MSGL_INFO
,"[mf] number of files: %d\n",mf
->nr_of_files
);
115 fname
=malloc( strlen( filename
) + 32 );
117 if ( !strchr( filename
,'%' ) )
119 strcpy( fname
,filename
);
120 if ( !strchr( filename
,'*' ) ) strcat( fname
,"*" );
122 mp_msg( MSGT_STREAM
,MSGL_INFO
,"[mf] search expr: %s\n",fname
);
124 if ( glob( fname
,0,NULL
,&gg
) )
125 { free( mf
); free( fname
); return NULL
; }
127 mf
->nr_of_files
=gg
.gl_pathc
;
128 mf
->names
=calloc( gg
.gl_pathc
, sizeof( char* ) );
130 mp_msg( MSGT_STREAM
,MSGL_INFO
,"[mf] number of files: %d (%zd)\n",mf
->nr_of_files
, gg
.gl_pathc
* sizeof( char* ) );
132 for( i
=0;i
< gg
.gl_pathc
;i
++ )
134 if (mp_path_isdir(gg
.gl_pathv
[i
]))
136 mf
->names
[i
]=strdup( gg
.gl_pathv
[i
] );
137 // mp_msg( MSGT_STREAM,MSGL_DBG2,"[mf] added file %d.: %s\n",i,mf->names[i] );
143 mp_msg( MSGT_STREAM
,MSGL_INFO
,"[mf] search expr: %s\n",filename
);
145 while ( error_count
< 5 )
147 sprintf( fname
,filename
,count
++ );
148 if ( !mp_path_exists( fname
) )
151 mp_msg( MSGT_STREAM
,MSGL_V
,"[mf] file not found: '%s'\n",fname
);
155 mf
->names
=realloc( mf
->names
,( mf
->nr_of_files
+ 1 ) * sizeof( char* ) );
156 mf
->names
[mf
->nr_of_files
]=strdup( fname
);
157 // mp_msg( MSGT_STREAM,MSGL_V,"[mf] added file %d.: %s\n",mf->nr_of_files,mf->names[mf->nr_of_files] );
162 mp_msg( MSGT_STREAM
,MSGL_INFO
,"[mf] number of files: %d\n",mf
->nr_of_files
);
168 mp_msg(MSGT_STREAM
,MSGL_FATAL
,"[mf] mf support is disabled on your os\n");